Skip to content

Commit 79970fb

Browse files
fix
1 parent d53f14c commit 79970fb

File tree

2 files changed

+130
-329
lines changed

2 files changed

+130
-329
lines changed

llm/auto_parallel/llama/run_pretrain_auto.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import paddle
2727
import paddle.distributed as dist
2828
from paddle.distributed import fleet
29+
from paddle import in_dynamic_mode
2930

3031
from paddlenlp.ops import Topology
3132
from paddlenlp.trainer import (
@@ -450,17 +451,12 @@ def main():
450451
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
451452

452453
if training_args.enable_linear_fused_grad_add:
453-
from fused_layers import mock_layers
454-
455-
mock_layers()
456-
457-
if "replace_with_parallel_cross_entropy" in training_args.tensor_parallel_config:
458-
utils_path = "/workspace/PaddleNLP/llm/utils"
454+
utils_path = "/root/paddlejob/workspace/env_run/shenfangjian/PaddleNLP/llm/utils"
459455
sys.path.append(utils_path)
460456

461-
from replace_ops import replace_cross_entropy
457+
from fused_layers import mock_layers
462458

463-
replace_cross_entropy()
459+
mock_layers()
464460

465461
if model_args.tokenizer_name_or_path is None:
466462
model_args.tokenizer_name_or_path = model_args.model_name_or_path
@@ -564,6 +560,14 @@ def main():
564560

565561
print("Final pre-training config:", config)
566562

563+
if "replace_with_parallel_cross_entropy" in training_args.tensor_parallel_config and config.tensor_parallel_degree > 1 and in_dynamic_mode():
564+
utils_path = "/root/paddlejob/workspace/env_run/shenfangjian/PaddleNLP/llm/utils"
565+
sys.path.append(utils_path)
566+
567+
from replace_ops import replace_cross_entropy
568+
569+
replace_cross_entropy()
570+
567571
# # Set the dtype for loading model
568572
# dtype = "float32"
569573
# if training_args.fp16_opt_level == "O2":

0 commit comments

Comments
 (0)