Repository navigation
Fix ChainedOptimizer step sync when a chained member is itself chained - #7354
Merged
ericharper merged 1 commit intoSep 17, 2026
Merged
Conversation
|
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. |
_synchronize_steps reaches through optimizer.optimizer.param_groups, which asserts when a chained member is itself a ChainedOptimizer. LayerWiseDistributedOptimizer is one whenever --muon-tp-mode and --muon-expert-tp-mode resolve differently, so those runs die at their first checkpoint save. Use the param_groups property instead: it aggregates nested chains and hands back the same dicts the write loop mutates. Signed-off-by: Deepak Narayanan <dnarayanan@nvidia.com>
deepakn94
force-pushed
the
dnarayanan/chained_optimizer_step_sync
branch
from
September 15, 2026 17:42
70a39ae to
f55cf4a
Compare
deepakn94
marked this pull request as ready for review
September 15, 2026 17:45
cspades
approved these changes
Sep 15, 2026
jaredcasper
approved these changes
Sep 15, 2026
ericharper
approved these changes
Sep 16, 2026
ericharper
enabled auto-merge
September 16, 2026 14:54
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/35155420871 |
This branch was previously deployed
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?
Fixes a crash at the first checkpoint save when a
ChainedOptimizerholds anotherChainedOptimizer._synchronize_stepsreaches throughoptimizer.optimizer.param_groups(megatron/core/optimizer/optimizer.py:2110and:2117). The.optimizerproperty asserts when the chained member is itself aChainedOptimizer.LayerWiseDistributedOptimizersubclassesChainedOptimizerand holds more than one inner optimizer whenever the model mixes optimizers, muon plus AdamW for instance. Nesting one inside an outer chain therefore kills the run at its first checkpoint save.The change
Use the
param_groupsproperty instead of.optimizer.param_groups. It aggregates nested chains and returns the sameparam_groupdicts the loop below mutates, so the writes still land on the real groups.Tests
tests/unit_tests/test_optimizer.pygains coverage for a chain whose member is itself a chain.Pre-checks
black, isort, pylint (10.00/10) and ruff clean. Unit tests need a GPU and were not run locally.
🤖 Generated with Claude Code