Open
Conversation
At step 0, num_iters is 0 so the warmup formula `start_lr * num_iters / warmup_iter` yields LR=0. This means the very first training step is a no-op: the step-1 checkpoint is identical to the step-0 checkpoint. Fix by using max(1, num_iters) in the warmup formula so step 0 gets the same small nonzero LR that step 1 would have received (start_lr / warmup_iter). Fixes EleutherAI#1373
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1373
The learning rate warmup formula in
megatron/learning_rates.pyproduces LR=0 at step 0, causing the first training step to be a complete no-op. The step-1 checkpoint is identical to the step-0 checkpoint.The Bug
The warmup formula on line 70 is:
At step 0,
num_iters_is0, so:This means the gradient update at step 0 is multiplied by zero -- the model parameters don't change at all.
The Fix
Using
max(1, num_iters_)ensures step 0 gets the same small nonzero LR that step 1 would have received (start_lr / warmup_iter), rather than zero. This is the minimal fix -- it avoids introducing new parameters or changing the config API.Before/After behavior (warmup_iter=1000, start_lr=1e-3):
Steps 1+ are completely unchanged. Only step 0 is affected.
Impact
This bug affects all models trained with gpt-neox using LR warmup, including all Pythia models on the HuggingFace Hub (as noted by @StellaAthena in the issue). In every case, the step-1 checkpoint is identical to the step-0 checkpoint because the first training step does nothing.