Fix issue where parameter groups with different min/max LRs get overridden at checkpoint load time - #4705
Conversation
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
To summarize, I believe the main problem this PR solves is that we have a hard-coded set of optimizer states that are used to find commonalities between parameter group states that include entries not in the hard-coded set. This means, if you have a checkpoint that saves more than the hard-coded set: they end up being hashed into a look-up table and overwriting each others values: when we need to consider ALL states, not just the previous 4: Wouldn't having a union of all state values (as the common key) in both the initialized optimizer and loaded checkpoint be more comprehensive? where we find the checkpoint state that matches the most entries in any particular parameter group and choose that state as the one to load into this parameter group of the optimizer? @yuzhongw-nvidia @deepakn94 This code was previously touched by a rather old ADLR PR, am I completely off the dot here or what? |
…ving the same key at dist op load time which leads to different LRs on checkpoint resumption Signed-off-by: John St John <jstjohn@nvidia.com>
Signed-off-by: John St John <jstjohn@nvidia.com>
Signed-off-by: John St John <jstjohn@nvidia.com>
Signed-off-by: John St John <jstjohn@nvidia.com>
866e547 to
8503194
Compare
My ResponseTLDR it sounds like the risk here is that if we go with a "use all keys other than these X that we should not use" approach would be that if a new mutable key were added, it would not match and then result in groups getting dropped silently... Even worse than the current issue of groups getting over-merged and sharing the same state. Claude's responseWhat the matching code is doingBoth Goal: the tuple has to cover every per-group field that distinguishes one group's behavior from another. If two groups produce the same tuple they collide in the lookup, and the later writer silently overwrites the earlier saved group's override state ( Why not "all keys minus
|
|
/claude review |
| out.append(group[f"pre_{key}"]) | ||
| else: | ||
| # Treat missing and explicit None identifier values as equivalent. | ||
| out.append(None) |
There was a problem hiding this comment.
Could this break backward compatibility with older checkpoints that don’t contain max_lr or min_lr? Missing keys are normalized to None, but newly created parameter groups always have concrete default values for these fields, so their identifiers may still fail to match. Is there another migration path that handles this case?
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29541881254 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29577749870 |
What does this PR do ?
Adds some missing parameter scheduler keys (like min/max lr) to the distributed optimizer load so that those PGs do not get settings from other PGs overwriting them.
Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
Code review
Feel free to message or comment the @mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.
For MRs into `dev` branch
The proposed review process for `dev` branch is under active discussion.MRs are mergable after one approval by either
eharper@nvidia.comorzijiey@nvidia.com.