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

Reload optimizer params when loading bf16 ckpt #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion megatron/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def load_checkpoint(model, optimizer, opt_param_scheduler, load_arg='load', stri
'exiting ...'.format(checkpoint_name))
sys.exit()
else:
if args.fp16 and optimizer is not None:
if (args.fp16 or args.bf16) and optimizer is not None:
optimizer.reload_model_params()

# rng states.
Expand Down
2 changes: 1 addition & 1 deletion megatron/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def setup_model_and_optimizer(model_provider_func,
and hasattr(unwrapped_model[0], 'init_state_dict_from_bert'):
print_rank_0("Initializing ICT from pretrained BERT model")
unwrapped_model[0].init_state_dict_from_bert()
if args.fp16:
if args.fp16 or args.bf16:
optimizer.reload_model_params()

return model, optimizer, opt_param_scheduler
Expand Down