Repository navigation
Use DistMuon for Kimi stacked feed-forward projections - #4812
Merged
Merged
Conversation
Contributor
Author
|
Stack from ghstack (oldest at bottom): |
weifengpy
added a commit
that referenced
this pull request
Sep 21, 2026
Kimi's dense and shared-expert fused w13 weights currently use AdamW. Select them for DistMuon and use Shard(0) compute to distribute the two complete [F, D] matrices in each native [2, F, D] parameter across ranks. Keep w2 on Owned compute. Enable the required Shard(1) storage -> Shard(0) compute transition on one mesh axis, with other non-unit storage axes replicated. The existing redistribution planner gathers complete matrices and returns update rows to the original storage ranks, including uneven row shards and empty compute participants. Parameters retain their native matrix-batch view; transport and Muon kernels are unchanged. A [2, F, D] batch uses at most two compute ranks; no performance improvement is claimed. This intentionally switches w13 from AdamW to Muon across the Kimi debug, Moonlight, Kimi-VL, and Kimi-K2.5 recipes. Model checkpoint names and shapes are unchanged, but old AdamW state for w13 does not supply Muon momentum state. Load old model weights with fresh optimizer state when adopting this change. Depends on the independent validation base #4813. This PR combines the redistribution support and the Kimi optimizer/layout change previously split across #4811 and #4812. Validation: - 41 CPU tests and five subtests pass, covering exact redistribution routes in both directions, uneven row shards, empty compute ranks, replicated mesh axes, unsupported-layout rejection, all four Kimi recipes, EP overrides, and optimizer assignment validation. - The combined production tree is identical to the previously tested stack at 3360775; only a CPU test function was renamed during consolidation. The six-test GPU DistMuon suite passed, covering Owned, BlockShard, checkpoint state, expert routing, and the new matrix-sharded compute path. - On H100, [2, 7, 5] matches Owned bitwise over 10 synthetic training steps with seed 42 and strict deterministic algorithms on two and four ranks, including loss, gradient norm, gradients, parameters, and momentum. An extra [3, 5, 7] case uses a 1e-6 absolute tolerance: local Newton-Schulz baddbmm batching can produce a one-FP32-ULP rounding difference. Every shape is not guaranteed bitwise equivalent to Owned. - Two 200-step C4 runs on eight H100s use the six-layer Kimi debug decoder, FSDP8/EP8, sequence length 256, seed 42, and strict deterministic algorithms. Both use the same 4,096 training documents and 512 held-out documents and train on 409,600 tokens. Runtime checks confirm optimizer assignments, Shard(1) storage, Shard(0) compute with six empty participants, and updated w13 weights on every rank. | w13 optimizer | Initial held-out loss | Held-out loss at step 200 | Mean training loss, last 20 steps | | --- | --- | --- | --- | | AdamW baseline | 8.0564976 | 2.7773604 | 2.7658222 | | DistMuon, Shard(0) | 8.0564976 | 2.7758863 | 2.7614102 | The C4 runs are a short learning check on the debug decoder, not full-model convergence or a performance comparison. Changed-file type checks pass. Full pre-commit reports the same 30 existing Pyrefly diagnostics as the validation base; all other hooks pass and unrelated automatic suppression removals are excluded.
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.
Kimi's Muon selection pattern still matches w[123], which excludes fused w13 weights. The dense and shared-expert w13 weights therefore fall through to AdamW even though the compute-layout map contains them.
Derive both FFN selection patterns from one projection-to-layout mapping. Select w13 for DistMuon and distribute its two complete [F, D] matrices with Shard(0) on dp_shard; keep w2 on Owned compute. This shared configuration applies to the Kimi debug, Moonlight, Kimi-VL, and Kimi-K2.5 recipes.
This intentionally switches w13 from AdamW to Muon. Model checkpoint names and shapes are unchanged, but old AdamW optimizer state for w13 does not supply Muon momentum state. Resume old model weights with fresh optimizer state for this change.
Depends on #4811 for Shard(1) storage -> Shard(0) compute redistribution.
Validation:
This is a short learning check on the debug decoder, not full-model convergence or evidence of a performance improvement.
Changed-file formatting/lint and the config's targeted type check pass. Full pre-commit reports the same 30 type errors at identical locations on parent 6bf49cc and this change; unrelated automatic suppression removals are excluded. Existing Kimi FSDP8/EP8 and PP2/FSDP2/EP2 integration recipes inherit the changed configuration.