Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[AutoParallel]:fix ernine auto_trainer error #9753

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
model = kwargs["model"]
for param in model.parameters():
if not param._is_initialized():
param.initialize()
try:
param.initialize()
except Exception as e:

Check warning on line 110 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L108-L110

Added lines #L108 - L110 were not covered by tests
# 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(

Check warning on line 112 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L112

Added line #L112 was not covered by tests
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