Add FSDP-aware hybrid Muon optimizer - #717
Draft
maocheng23 wants to merge 1 commit into
Draft
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Motivation
SpecForge's unified trainer currently exposes only AdamW. DSpark ablations also
need an opt-in Muon setup without moving embedding/head parameters to Muon or
replicating optimizer state under FSDP.
Modifications
training.optimizer: adamw | muonconfiguration plus independentMuon/AdamW learning-rate, weight-decay, momentum, Nesterov, and Newton--Schulz
controls. AdamW remains the default.
nn.Linear.weightmatrices into Muon while keeping embeddingprojections, Markov/confidence/output heads, norms, and biases on auxiliary
AdamW. Capture the classification and logical matrix shapes before FSDP wraps
the draft.
torch.optim.Muonfor replicated parameters. For FSDP local shards, keepFP32 masters and momentum sharded, gather one BF16 update at a time for the
same PyTorch 2.11 Newton--Schulz transform, and write back only the local
slice.
format with strict parameter-partition validation and independent scheduler
state for both optimizer groups.
lr_muonandlr_adamw, validate incompatible CPU offload settings, anddocument the new training configuration.
Related Issues
None.
Accuracy Test
The unit suite compares a three-rank sharded update against native full-matrix
torch.optim.Muonusing uneven(7, 5, 0)shards, including an emptyrank-local parameter. It also checks the concrete DSpark backbone/head
partition and hybrid checkpoint continuation.
Validation with the repository's pinned PyTorch 2.11 environment:
pytest -q tests/test_optimizer: 17 passed, 1 skippedpytest -q tests/test_config: 55 passed, 431 subtests passedinstallation: 542 passed, 20 skipped, 1 expected failure, 68 subtests passed
No end-to-end model accuracy run has been performed yet.
Benchmark & Profiling
Not yet measured. The implementation keeps persistent optimizer state sharded,
but Newton--Schulz adds one transient BF16 logical-matrix gather per Muon
parameter. An H200/NCCL smoke run and step-time/memory profile are still needed
before marking this PR ready for review.
Checklist