Skip to content

Support MoE aux losses and expert sync under dynamic context parallelism - #7146

Draft
ilml wants to merge 1 commit into
NVIDIA:mainfrom
ilml:pr3791-split/moe
Draft

ilml wants to merge 1 commit into
NVIDIA:mainfrom
ilml:pr3791-split/moe

Conversation

@ilml

@ilml ilml commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

MoE under dynamic CP: packed_seq_params is plumbed through TransformerLayer → MoELayer → router so TopKRouter reduces aux/seq-aux losses over the runtime [cp_group, tp_group]; get_tokens_per_expert_and_token_count accepts a list of process groups; gpus_needed() clamps the minimum CP size for expert-rank sync (HACK/TODO preserved from the original); training_log scales MoE/MTP metrics by the hybrid-CP group count with a fallback to get_num_microbatches() so this PR is independently mergeable before the packing PR.

Series (split of #3791)

Split of #3791 ("Update Dynamic CP to support sequence packing, MXFP8 and Mamba") against current main, tracked in the Dynamic Context Parallelism project. Original changes by @parthmannan in #3791; hunks already covered by main (via the merged sequence-packing series and hybrid-CP fixes) were dropped, and the rest re-implemented against main's current structure. All PRs target main; merge order:

Order PR Content
any #7143 Mamba dynamic CP SSM wiring for runtime CP groups
1 #7144 Hybrid-CP sequence packing packed microbatches in the hybrid-CP dataloader + schedule
2 #7145 MTP dynamic CP multi-token-prediction loss on the runtime CP group
2 #7146 MoE dynamic CP aux-loss reduction, dispatcher padding, EP sync, loss-scale logging

Contribution process

  • Draft PR per contributing guidelines
  • Commits signed off (DCO)

Split from NVIDIA#3791; original changes by @parthmannan.

Plumb packed_seq_params through the transformer layer MLP call sites,
MoELayer.forward/route, and the TopKRouter so that, under dynamic
(hybrid) context parallelism, aux and seq-aux losses are reduced over
the per-sequence CP sub-group followed by the TP group instead of the
static TP-CP group, with a logging-only scale correcting the sub-group
overcounting in the reduced metrics. Extend
get_tokens_per_expert_and_token_count to accept a list of process
groups and all-reduce sequentially over them. Clamp the hybrid CP
scheduler's gpus_needed to a minimum CP size of EP/TP so expert ranks
stay in sync, and scale MoE/MTP logged metrics in training_log by the
hybrid-CP per-iteration group count when available.

Co-authored-by: Parth Mannan <pmannan@nvidia.com>
Signed-off-by: ilml <tolong@nvidia.com>
@ilml

ilml commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 78d7e90

@copy-pr-bot

copy-pr-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch was previously deployed

2 inactive deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant