Skip to content

Use DistMuon for Kimi stacked feed-forward projections - #4812

Merged
weifengpy merged 1 commit into
pr/dist-muon-stacked-shard0from
gh/weifengpy/73/head
Sep 21, 2026
Merged

weifengpy merged 1 commit into
pr/dist-muon-stacked-shard0from
gh/weifengpy/73/head

Conversation

@weifengpy

Copy link
Copy Markdown
Contributor

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:

  • Five CPU tests pass. They build all four recipe models on meta, exercise the actual optimizer parameter partition, verify complete bucket/layout coverage and AdamW fallback, and check EP overrides.
  • 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. The vision tower is disabled for text-only C4. Both runs use the same 4,096 training documents and 512 held-out documents; each trains on 409,600 tokens.
  • Runtime checks confirm all six w13 weights use the selected optimizer, retain Shard(1) storage, and change during training. The new path keeps the identity matrix view and assigns complete matrices to two ranks, with six empty compute participants.
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

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.

[ghstack-poisoned]
@weifengpy

weifengpy commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Stack from ghstack (oldest at bottom):

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 21, 2026
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.
@weifengpy
weifengpy merged commit 781521d into pr/dist-muon-stacked-shard0 Sep 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant