[Fix] Add GLM-5.2 MuonSplit and AdamW-only gradient clipping - #2001
Open
JT-Ushio wants to merge 1 commit into
Open
[Fix] Add GLM-5.2 MuonSplit and AdamW-only gradient clipping#2001JT-Ushio wants to merge 1 commit into
JT-Ushio wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Muon optimizer integration to support GLM-5.2-style “MuonSplit” (independent orthogonalization/LR scaling per logical row block) and adjusts training-time gradient clipping so only auxiliary (non-Muon) gradients are clipped while still computing the full global grad norm for safety checks.
Changes:
- Add MuonSplit support in Muon via per-parameter logical row block definitions and a split-aware Newton–Schulz callback.
- Plumb MuonSplit metadata from model modules (e.g., DSA MLA projections) into optimizer construction.
- Update
TrainEngine.clip_grad_normbehavior and add tests covering MuonSplit equivalence + AdamW-only clipping behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
xtuner/v1/optim/muon.py |
Adds MuonSplit grouping and split-aware Newton–Schulz orthogonalization with per-block LR scaling. |
xtuner/v1/module/attention/dsa_mla.py |
Exposes GLM MLA projection split sizes for MuonSplit via get_muon_split_sizes(). |
xtuner/v1/engine/train_engine.py |
Clips only auxiliary gradients when Muon is present while keeping full grad norm for checks/logging. |
xtuner/v1/config/optim.py |
Collects muon_split_sizes from modules and passes them into the Muon optimizer. |
tests/optim/test_muon.py |
Adds unit coverage for MuonSplit behavior and AdamW-only clipping semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+371
to
+372
| if sum(split_sizes) > p.shape[-2]: | ||
| raise ValueError(f"MuonSplit sizes {split_sizes} exceed parameter shape {tuple(p.shape)}") |
Comment on lines
+267
to
+272
| clip_params = ( | ||
| p | ||
| for group in self.optimizer.param_groups | ||
| if group.get("algorithm") != "muon" | ||
| for p in group["params"] | ||
| ) |
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.
Summary
Ortho(cG) = Ortho(G)(rationale).Tests