Add Muon Optimizer [cherry-pick from dev]#78679
Merged
sneaxiy merged 7 commits intoPaddlePaddle:release/3.3from Apr 15, 2026
Merged
Add Muon Optimizer [cherry-pick from dev]#78679sneaxiy merged 7 commits intoPaddlePaddle:release/3.3from
sneaxiy merged 7 commits intoPaddlePaddle:release/3.3from
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Add Muon optimizer implementation with Newton-Schulz orthogonalization for distributed training: - Muon optimizer (python/paddle/optimizer/muon.py): - Newton-Schulz iteration for orthogonal gradient updates - QKV split modes: per_head, qkv_sep, full - FFN gate_up split support - Multiple NS coefficient types: simple, quintic, polar_express, aol - MuonShardingOptimizer: - Whole-tensor assignment for 2D parameters (Muon) - Element-wise sharding for non-2D parameters (AdamW) - Hybrid memory balancing across ranks - Test coverage: - All 24 parameter combinations tested - 2-GPU sharding validation against single-GPU reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MuonShardingOptimizer is a dygraph-only optimizer designed for Muon optimizer with distributed sharding support. It should not be loaded by the static graph meta optimizer factory, similar to: - HybridParallelOptimizer - HeterParallelOptimizer - DGCMomentumOptimizer This fix prevents static graph tests (e.g., test_static_model_parallel, test_raw_program_optimizer) from crashing when MuonShardingOptimizer tries to access dynamic-graph-only attributes like _parameter_list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…grad - Use MixPrecisionLayer + MixPrecisionOptimizer pattern so params have main_grad before MuonShardingOptimizer init, enabling the safe main_grad path in the refactored clear_grad (which now iterates over all parameters instead of only 2D params) - Add paddle.amp.auto_cast in train_batch for proper BF16 forward pass - Use np.random.randn for weight init (zero-centered, better NS stability) - Cast params to float32 before numpy comparison to avoid BF16 uint16 bit-pattern comparison issues Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…l parameter list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add MLAInfo dataclass and MLA split_head orthogonal update in muon.py - Add clear_param_storage/reset_param_storage methods in MuonShardingOptimizer - Support MoE expert param storage management via _color_to_comm_buffer_list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
/re-run all-failed |
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (12.99%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## release/3.3 #78679 +/- ##
==============================================
Coverage ? 12.99%
==============================================
Files ? 7
Lines ? 877
Branches ? 0
==============================================
Hits ? 114
Misses ? 763
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sneaxiy
approved these changes
Apr 15, 2026
Collaborator
sneaxiy
left a comment
There was a problem hiding this comment.
LGTM for coverage due to lack of BF16.
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.
PR Category
Execute Infrastructure
PR Types
New features
Description
Add Muon Optimizer
devPR:#78335
是否引起精度变化
否