Skip to content

[DistMuon] turn on pipeline parallelism (again) - #4263

Merged
weifengpy merged 1 commit into
mainfrom
weifengpy/kimi-distmuon-pp
Aug 21, 2026
Merged

weifengpy merged 1 commit into
mainfrom
weifengpy/kimi-distmuon-pp

Conversation

@weifengpy

@weifengpy weifengpy commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate of #4102. That PR was accidentally merged into its ghstack base
branch gh/weifengpy/51/base instead of main, so the change never reached
main. Re-submitting

we used to gate PP because OptimizersContainer requires non-empty param_group matching. it's fine as long as each PP stage owns one layer at least (non-empty muon param_groups)

Duplicate of #4102. That PR was accidentally merged into its ghstack base
branch `gh/weifengpy/51/base` instead of `main`, so the change never reached
`main`. Re-submitting the identical content here as a plain single-commit PR
against `main`.

Drop the config gate that rejected Kimi DistMuon under pipeline parallelism,
and add a 4-GPU PP+FSDP+EP single-step integration smoke test. Nothing outside
the Kimi model folder changes.

DistMuon needs no changes for PP, and neither does the optimizer container.
torchtitan/distributed/flex_shard/ and torchtitan/components/ are untouched
here. DistMuon's math and collectives were already PP-safe: Newton-Schulz runs
per matrix, so splitting layers across stages changes no update; `pp` is its
own mesh axis, so every transport group it reduces over -- dp_shard, efsdp, ep
-- lives inside a single PP coordinate, and ranks in a group own identical
layers; and its FQN-keyed inputs are already subset-tolerant, since bucket
resolution iterates only the parameters present, empty buckets are dropped, and
the compute-layout map is a superset of what a stage holds.

The gate's stated reason -- that PP "gives each stage only a subset of the
optimizer's parameter-group patterns" -- described OptimizersContainer's
strictness rather than a DistMuon limitation, and overstated it. The container
rejects a `param_groups` pattern that claims no parameter. Kimi configures two
patterns: the DistMuon matrix pattern and an AdamW catch-all. The catch-all
always claims something, and the matrix pattern claims something on any stage
holding at least one transformer layer. Verified across stage counts on the
debug model: every stage builds its param groups at 2 and 4 stages, the shipped
test's layout included.

The precondition is that every stage owns at least one transformer layer.
A stage holding only norm and lm_head has no matrix parameters and raises
"matched no parameters" while building the optimizer. Reaching that needs the
stage count to approach the layer count -- it first appears at 6 stages over
the 6-layer debug model, and would need roughly 60 stages for Kimi K2. No real
configuration does that, so it is left as a loud build-time failure rather than
loosening a check that every torchtitan optimizer shares. Relaxing that check
safely means restoring an equivalent one against the unsplit model, which is a
separate concern.

The precondition goes in the README's Supported Parallelisms table, beside the
existing TP row, since that is where someone configuring PP will look. The
registry carries only a short note on why there is no PP gate.

The recipe also moves off `training.local_batch_size`, which no longer exists;
the microbatch count is now `parallelism.num_pp_microbatches`.

Test plan:
- Four GPU Kimi PP+FSDP+EP integration smoke (kimi_k2_5_muon_pp+fsdp+ep),
  PP=2 with Interleaved1F1B over four virtual stages, FSDP=2, EP=2. NOT run
  locally -- needs a CI run before landing.
- Param groups build on every stage at 2 and 4 stages against an unmodified
  OptimizersContainer; at 6 stages the layer-less last stage raises, matching
  the documented precondition.
- Rebased onto current `main` and re-verified there:
  `kimi_k2_5_debugmodel_muon_fsdp2_pp2_ep2` builds with PP=2 /
  Interleaved1F1B / FSDP=2 / EP=2 / 4 microbatches and the PP gate no longer
  fires; all 16 recipes in torchtitan_recipes/tests/models.py still build; the
  integration test list builds with the Kimi entry at ngpu=4, timeout=600.
- `pre-commit` clean on the four changed files.
- Unit suite is unaffected: no shared code is touched.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 21, 2026
@weifengpy weifengpy changed the title [Kimi K2.7] Support DistributedMuon with pipeline parallelism [DistMuon] turn on pipeline parallelism (again) Aug 21, 2026
@weifengpy
weifengpy merged commit 63dc89c into main Aug 21, 2026
18 checks passed
acisseJZhong pushed a commit that referenced this pull request Sep 2, 2026
Handle non-contiguous HF MoE inputs under context parallelism and remove the Kimi DistMuon pipeline-parallel test, which is unsupported on release/0.3 without #4263.
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.

2 participants