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

Fix a bug in optimizer's mix_lr/max_lr when args.override_opt_param_scheduler==True #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 10 additions & 0 deletions megatron/training/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,16 @@ def load_checkpoint(model, optimizer, opt_param_scheduler, load_arg='load', stri
opt_param_scheduler.load_state_dict(state_dict['lr_scheduler'])
else:
opt_param_scheduler.load_state_dict(state_dict['opt_param_scheduler'])

if args.override_opt_param_scheduler:
from megatron.core.optimizer import _update_min_and_max_lr_in_param_groups
_update_min_and_max_lr_in_param_groups(
optimizer.param_groups,
opt_param_scheduler.max_lr,
opt_param_scheduler.min_lr,
args.decoupled_lr,
args.decoupled_min_lr,
)
except KeyError as e:
print_rank_0('Unable to load optimizer from checkpoint {}. '
'Specify --no-load-optim or --finetune to prevent '
Expand Down