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

Conversation

lyuwen
Copy link

@lyuwen lyuwen commented Nov 12, 2024

  1. In the current setting, OptimizerParamScheduler uses the max_lr and min_lr from optimizer instead of its own attributes to compute the learning rate at a certain step.
  2. When --override-opt_param_scheduler is used, user expects to override the learning rate schedule that is stored in the checkpoint. However, the optimizer still loads the max_lr, min_lr and the decoupled versions from the checkpoint.
  3. Therefore, when --override-opt_param_scheduler is used, the learning rate in training is computed using the old max_lr and the new init_lr, a mixture of old and new setting. This can be confusing for user to figure out the issue.

Here I propose an fix that during the load_checkpoint, when --override-opt_param_scheduler is set to True, the function megatron.core.optimizer._update_min_and_max_lr_in_param_groups is invoked to update the optimizer loaded from the checkpoint with the new learning rate boudaries. Thus the training would be carried out using the updated learning rate setting in situations like CPT, etc.

…ates settings in optimizer.param_groups still uses the old settings from the checkpoint. This results in wrong learning rate setup being used in CPT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant