Skip to content

Commit

Permalink
[AutoParallel] Fix ernie auto_trainer error (#9753)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksheep-Aristotle authored Jan 8, 2025
1 parent 1d74d62 commit fb60645
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion paddlenlp/trainer/auto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ def loss_func(loss, outputs):
model = kwargs["model"]
for param in model.parameters():
if not param._is_initialized():
param.initialize()
try:
param.initialize()
except Exception as e:
# NOTE(zhangwl):maybe param is not initialized and param init_func is set in later.user need set_init_func before auto_trainer
logger.warning(
f"AutoTrainer requires all parameters to be initialized when auto_trainer init, but failed to initialize parameter {param.name} {param}.\n"
+ "Please check param init func.\n"
+ f"The original exception message is:\n{str(e)}"
)
kwargs["model"] = model

super().__init__(*args, **kwargs)
Expand Down

0 comments on commit fb60645

Please # to comment.