Conversation
Naive DP all-gathers per-rank token batches before the monolithic MoE kernel, so allocate routing replay output for the gathered maximum. Assisted-by: OpenAI Codex <noreply@openai.com> Signed-off-by: tbarnatan <tbarnatan@nvidia.com>
TomerBN-Nvidia
marked this pull request as ready for review
August 3, 2026 13:21
TomerBN-Nvidia
requested review from
mgoin,
pavanimajety and
zyongye
as code owners
August 3, 2026 13:21
Contributor
Author
|
@aoshen02 Can you please take a look? |
Collaborator
Will take a look today. |
Under DP+EP the gathered routing tensor carries sequence-parallel shards whose sizes include CUDA-graph/SP padding, so size the monolithic replay buffer for the larger of the DP and EP dispatch groups and locate this DP rank's contiguous shard group from the exact all-gatherv layout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: tbarnatan <tbarnatan@nvidia.com>
Contributor
Author
|
@aoshen02 I added some more logic that I needed. Can you please take another look? It passes my tests that include DP. |
Collaborator
|
aoshen02
reviewed
Aug 4, 2026
| return | ||
| # Naive DP and DP+EP prepare paths all-gather per-rank batches before | ||
| # invoking the monolithic kernel. ``max_num_tokens`` is the scheduler | ||
| # limit for one rank, so the replay output must cover the largest |
aoshen02
reviewed
Aug 4, 2026
| # dispatch group rather than only the local batch. Under EP that group | ||
| # can also contain sequence-parallel shards flattened into the EP | ||
| # group, including padding. | ||
| dispatch_group_size = max( |
Collaborator
There was a problem hiding this comment.
I think it would be more clearer to change to
if self.moe_config.use_ep:
self.moe_config.ep_size
else:
self.moe_config.dp_size
Collaborator
|
LGTM in general. |
Assisted-by: OpenAI Codex Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Collaborator
|
/ci run |
|
✅ Triggered Buildkite CI #83664 for commit |
ZJY0516
approved these changes
Aug 13, 2026
ywang96
approved these changes
Aug 13, 2026
zyp2014
pushed a commit
to zyp2014/vllm
that referenced
this pull request
Aug 21, 2026
…ct#50874) Signed-off-by: tbarnatan <tbarnatan@nvidia.com> Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: zjy0516 <riverclouds.zhu@qq.com>
zufangzhu
pushed a commit
to zufangzhu/vllm
that referenced
this pull request
Aug 24, 2026
…ct#50874) Signed-off-by: tbarnatan <tbarnatan@nvidia.com> Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: zjy0516 <riverclouds.zhu@qq.com> Signed-off-by: Zhu, Zufang <zufang.zhu@intel.com>
khushali9
pushed a commit
to khushali9/vllm
that referenced
this pull request
Aug 29, 2026
…ct#50874) Signed-off-by: tbarnatan <tbarnatan@nvidia.com> Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: zjy0516 <riverclouds.zhu@qq.com> Signed-off-by: khushali9 <khushali.desai9@gmail.com>
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.
Purpose
Fix routing-replay capture for the FlashInfer monolithic MoE kernel under naive
data parallelism, including padded sequence-parallel shards when expert
parallelism is enabled.
Two related assumptions fail in a TP2/DP2 deployment:
Replay buffer capacity.
max_num_tokensis a per-rank scheduler limit,while the naive dispatch path all-gathers rank-local batches before invoking
the monolithic kernel. This produced an 8192-row replay buffer for a
16384-row kernel input and failed during warmup. The buffer is now sized for
the larger of the DP and EP dispatch groups, since under EP the gathered
batch is the flattened EP group rather than the DP group.
Gathered shard layout. Under DP+EP,
topk_idscan contain gatheredsequence-parallel shards whose
dp_metadata.local_sizesincludeCUDA-graph/SP padding. Those rows do not match the unpadded per-DP token
counts used by the existing capture paths, so the batch-dimension assertion
fired. When the gathered tensor matches
sum(local_sizes), we locate thecurrent DP rank's contiguous shard group using that exact all-gatherv layout
and copy only its real token count, trimming trailing padding.
Existing naive-DP, modular-local, and modular-SP layouts are unchanged, and no
routing or model-output semantics change.
Duplicate check
I searched open upstream PRs for
routing replay buffer,routed experts capture,routing replay all-gather, andlocal_sizes routing; none fixesthis allocation or the padded-shard capture:
routing replay output added by [RL Infra][FlashInfer] Enable router replay output from FlashInfer monolithic MoE kernel #44214.
routed_experts_capturer.py, but only the shapeconfiguration; it leaves the
capture()batch-layout branches alone.gathered-batch layout handled here.
Validation
git diff --check: passedRuff check/format,
mypy-3.10, typos, SPDX, root-lazy-import,forbidden-import, torch-CUDA-API, config-validation, and sign-off hooks all
passed. (Under a host Python 3.9 two of these hooks crash on 3.10+ syntax;
that is an environment artifact, not a finding.)
run on the corresponding branch of my fork on GB200: mixed and decode
CUDA-graph capture completed, both API servers started, and a
/v1/completionsrequest was served with routed-experts capture enabled. Theoriginal routing batch-dimension assertion did not fire.
unchanged by this fix.
AI assistance was used. As the human submitter I have reviewed every changed
line and the recorded runtime validation.