Refactor emerging optimizer integration#4113
Conversation
Signed-off-by: Hao Wu <skyw@nvidia.com>
|
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. |
|
/ok to test 5275694 |
| Handles both standard optimizers (Adam, SGD) and emerging optimizers (e.g. Muon). | ||
| We use separate optimizers for expert parameters and non-expert parameters. | ||
| For emerging optimizers with ``config.use_layer_wise_distributed_optimizer=True``, | ||
| the optimizer is automatically wrapped with :class:`LayerWiseDistributedOptimizer`. |
There was a problem hiding this comment.
I think we should eventually re-name DistributedOptimizer to something else (maybe ParameterWiseDistributedOptimizer)?
There was a problem hiding this comment.
(can be done in a separate PR)
There was a problem hiding this comment.
I've been using element wise. can debate when we actually do it.
…LayerWise wrapping The test was manually extracting base optimizers from Float16OptimizerWithFloat16Params wrappers and re-wrapping them in LayerWiseDistributedOptimizer, but the fp32 master param updates never propagated back to the bf16 model params. Use use_layer_wise_distributed_optimizer=True in the config instead, which lets _get_megatron_emerging_optimizer handle wrapping correctly.
|
/ok to test c74dd1a |
Signed-off-by: Hao Wu <skyw@nvidia.com>
|
/ok to test 90c5747 |
|
/ok to test 16f2e53 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/23927338034 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/23928037174 |
This reverts commit 5b512b4. Signed-off-by: oliver könig <okoenig@nvidia.com>
This reverts commit 5b512b4. Signed-off-by: oliver könig <okoenig@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
What does this PR do ?
Cherry-picks three related PRs from dev that refactor the optimizer infrastructure to generalize beyond Muon and support additional emerging optimizers (SOAP, Lion, etc.):
combined those instead cherry picking 1-by-1 because there are immediate changes among them that is not needed anymore.
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.