fix(muon): muon_use_nesterov silently dropped (arg/config name mismatch)#9599
Merged
Jintao-Huang merged 1 commit intoJun 18, 2026
Merged
Conversation
…erov The user-facing arg is muon_use_nesterov but Megatron's OptimizerConfig field is muon_nesterov. trainers/base.py builds the optimizer config by copying kwargs keyed on the config field name, so muon_use_nesterov never matches and the user's setting is silently dropped (nesterov stays False). Alias it in _check_muon so the flag takes effect. Signed-off-by: yuchenwang3 <eang333cms@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates swift/megatron/arguments/megatron_args.py to alias the user-facing argument muon_use_nesterov to self.muon_nesterov. This ensures that the setting is correctly passed to Megatron's OptimizerConfig and not silently dropped. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Jintao-Huang
approved these changes
Jun 18, 2026
Collaborator
|
thanks It looks like a breaking change from mcore 0.16 to 0.17. |
Jintao-Huang
pushed a commit
that referenced
this pull request
Jun 29, 2026
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
ms-swift exposes a user-facing Muon argument
muon_use_nesterov(swift/megatron/arguments/megatron_args.py), but Megatron'sOptimizerConfigfield is namedmuon_nesterov. The optimizer config is built inswift/megatron/trainers/base.pyby copying kwargs by the config field name:Because the loop keys off the Megatron field name (
muon_nesterov) and checkshasattr(args, 'muon_nesterov')— which is False (the arg ismuon_use_nesterov) — the user's setting is silently dropped.--muon_use_nesterov trueis a no-op:muon_nesterovstays at its defaultFalse.All of the other
muon_*args (muon_momentum,muon_split_qkv,muon_scale_mode,muon_coefficient_type, ...) match the MegatronOptimizerConfigfield names 1:1 and transfer correctly through this same loop —muon_use_nesterovis the only one whose name diverges.Change
Add a one-line alias in
_check_muon(inside theif 'muon' in self.optimizer:block) so the user's value reaches Megatron:This is additive and non-breaking (the public CLI arg
--muon_use_nesterovis unchanged).Testing
py_compileclean. Traced the consumption path (megatron_argsarg →_check_muon→trainers/base.pyfield-name copy → MegatronOptimizerConfig.muon_nesterov). Confirmedmuon_use_nesterovhas no other consumer in the tree, andmuon_nesterovis the actual Megatron field (megatron/core/optimizer/optimizer_config.py).Note
Alternative: rename the arg
muon_use_nesterov→muon_nesterovto match the 1:1 convention of the othermuon_*args. That is cleaner but a breaking CLI change, so I went with the additive alias. Happy to switch to the rename if you prefer.