Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BugFix] Fix load rng compatibility. #8451

Merged
merged 1 commit into from
May 16, 2024
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
15 changes: 6 additions & 9 deletions paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,16 +1591,13 @@ def _load_rng_state(self, checkpoint):
if os.path.isfile(rng_file):
rng_file_list = paddle.load(rng_file, return_numpy=True)
paddle.distributed.broadcast_object_list(rng_file_list, src=0)
# if rng_file_list still empty, then use old style rng_state
# if rng_file_list still empty, not log rng state.
if rng_file_list[0] is None:
rng_file = os.path.join(checkpoint, f"rng_state_{process_index}.pth")
if not os.path.isfile(rng_file):
logger.info(
f"Didn't find an RNG file for process {process_index}, if you are resuming a training that "
"wasn't launched in a distributed fashion, reproducibility is not guaranteed."
)
return
checkpoint_rng_state = paddle.load(rng_file, return_numpy=True)
logger.info(
f"Didn't find an RNG file for process {process_index}, if you are resuming a training that "
"wasn't launched in a distributed fashion, reproducibility is not guaranteed."
)
return
else:
checkpoint_rng_state = rng_file_list[process_index]
else:
Expand Down
Loading