Scaling for MuP over Muon optimizer. - #3715
Conversation
ba2dc02 to
00462e7
Compare
|
Thanks for your PR! The loss v. lr graph looks great! |
|
@BoxiangW thank you for the review! Added the arguments.py help string. Should be good for merge now, I think. |
|
@skyw, I've updated the warn behavior on |
skyw
left a comment
There was a problem hiding this comment.
some left over needs to be cleaned. otherwise LGTM
|
@skyw thanks! Made the changes. |
|
@BoxiangW not sure why the CI is still failing... I actually ran out of compute 😭, but I'll try to get some more and update this. Update: I asked Codex, and it suggested that the newer GB200 workflow is getting skipped, since this is a non-maintainer PR, but I'm unsure if that's the case. Edit: the exact diagnosis is: |
|
/ok to test 9849e84 |
|
The MLA-Yarn unit test fail looks unrelated to the MuP changes. Perhaps a transient error? |
|
/ok to test a86e420 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/23463249846 |
|
Thanks everyone! |
Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Boxiang Wang <boxiangw@nvidia.com>
Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Boxiang Wang <boxiangw@nvidia.com> Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Boxiang Wang <boxiangw@nvidia.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
Co-authored-by: Antoni-Joan Solergibert <asolergibert@nvidia.com> Co-authored-by: Boxiang Wang <boxiangw@nvidia.com>

What does this PR do ?
Addresses #3177, make default Muon scaling when conducting MuP transfer behave as it should.$\sqrt{\max(\text{fan}_{in}, \text{fan}_{out})}$ ($\sqrt{\frac{\text{fan}_{out}}{\text{fan}_{in}}}$ .
By default, Megatron scales Muon's matrix sign directions by
spectral). An alternate option is to useunit_rms_norm, orEarlier, as a bug, turning MuP on would also apply Adam-wise LR/eps updates on the Muon-managed matrices, making MuP unprincipled on Muon (the matrices would be scaled both by Muon and by MuP). This has been fixed.
In addition, even without double scaling, Muon-managed matrices scaled with the default$\sqrt{n}$
spectral, loses width-invariance due to themax(). For square-matrices, for example, it grows asThe principled way to go forward seems to be to set Muon scaling to$\sqrt{\frac{\text{fan}_{out}}{\text{fan}_{in}}}$ , and so, we default to Muon with
unit_rms_norm, i.e,unit_rms_normwhen MuP is active.L to R: SP, MuP+

spectral, MuP+unit_rms_norm(new default), old MuP double-scaling +spectral(old default)L: SP, R: MuP+

spectralvs MuP +unit_rms_norm. As expected,unit_rms_normshows MuP transfer better thanspectralon these sweeps.Experiments on a slice of
wikitext-103, 12 layer transformer, 100 iterations, if not stated otherwise. Confidence bounds from 5 runs with random seeds.Contribution process
flowchart LR A[Pre-checks] --> B[PR Tests] subgraph Code Review/Approval C1[Expert Review] --> C2[Final Review] end B --> C1 C2 --> D[Merge]Pre-checks
Core 0.8)Code review
The following process is enforced via the CODEOWNERS file for changes into
megatron/core. For changes outside ofmegatron/core, it is up to the PR author whether or not to tag the Final Reviewer team.For MRs into `main` branch
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!
(Step 1): Add PR label
Expert Review(Step 2): Collect the expert reviewers reviews
Expert Reviewlabel when your PR is ready for review.Final Review might get declined if these requirements are not fulfilled.
(Step 3): Final Review
Final Reviewlabel(Optional Step 4): Cherry-pick into release branch
If this PR also needs to be merged into
core_r*release branches, after this PR has been merged, selectCherry-pickto open a new PR into the release branch.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.Merging your PR
Any member of core-adlr and
core-nemowill be able to merge your PR.