Merge emerging-optimizers change from dev to main - #4060
Closed
skyw wants to merge 13 commits into
Closed
Conversation
Bring over optimizer improvements from the dev branch including: - Emerging optimizers registry and refactoring (Lion, AdaptiveMuon, etc.) - Optimizer state and master weight CPU offloading - Layer-wise optimizer improvements with --overlap-param-gather support - Muon optimizer cleanup and consolidation into emerging optimizers framework - Updated unit tests (new: emerging_optimizers, lion, state_offloading; removed: muon_optimizer) - Updated functional test golden values Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rad_buffer.py - arguments.py: Add CLI args for new optimizers (soap, adaptive_muon), --offload-optimizer-states flag, --muon-nesterov rename, dist_muon deprecation handling, use_layer_wise_distributed_optimizer logic, and emerging optimizer validation checks - param_and_grad_buffer.py: Add grad mode tracking for cached param views to avoid stale views when grad mode changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reverts: OptimizerStateOffloader, distrib_optimizer quantized tensor changes, offload_optimizer_states config/CLI arg, and offloading test. These will be merged separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lion is part of the emerging_optimizers package, so a single HAVE_EMERGING_OPTIMIZERS check is sufficient. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
skyw
marked this pull request as ready for review
March 30, 2026 16:54
Contributor
Author
|
/ok to test 04e0d35 |
Contributor
Author
|
@FDecaYed plz take a look. Pay attention to the muon-scalar-optimizer logic which could be breaking. And some uv settings may be out of sync. CI returned strange missing package errors. |
skyw
marked this pull request as draft
March 30, 2026 17:06
Signed-off-by: Hao Wu <skyw@nvidia.com>
skyw
marked this pull request as ready for review
March 30, 2026 17:19
Contributor
Author
|
/ok to test 0765b35 |
skyw
marked this pull request as ready for review
March 31, 2026 01:23
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Contributor
Author
|
/ok to test 2a21bba |
skyw
marked this pull request as draft
March 31, 2026 01:41
Signed-off-by: Hao Wu <skyw@nvidia.com>
skyw
marked this pull request as ready for review
March 31, 2026 03:41
Contributor
Author
|
/ok to test ce7174e |
FDecaYed
approved these changes
Mar 31, 2026
FDecaYed
left a comment
Contributor
There was a problem hiding this comment.
some minor issues. otherwise looks good to me
| if state_dict is not None: | ||
| if len(self.model_chunks) == 1: | ||
| state_dicts[0] = state_dict | ||
| # When there is only one global model chunk, all sub-optimizers |
Contributor
| # Muon optimizer check | ||
| if 'muon' in args.optimizer: | ||
| # emerging optimizer check | ||
| if not hasattr(args, 'use_layer_wise_distributed_optimizer'): |
Contributor
There was a problem hiding this comment.
maybe just add this as a usual parameter below, and set to default false there? it might help allow downstream properly set it(bridge for example). because sometime they just create args without running code logics here.
not a hard request though
skyw
marked this pull request as ready for review
March 31, 2026 15:27
…o-main # Conflicts: # pyproject.toml # uv.lock
Contributor
Author
|
/ok to test f4d9301 |
Contributor
Author
|
Closing. |
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.
What does this PR do ?
optimizers. Muon code consolidated from standalone muon.py (now a backward-compat shim) into the registry framework.
directly), improved error messages for pre-wrapped optimizers.
muon_nesterov, AdamOptimizerConfig/SGDOptimizerConfig simplified to aliases.
muon + layer-wise.
splitting for mixed optimizer types.
related:
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.