[DeepEP V2] Bound num_max_tokens_per_rank in do_expand=False#46404
Merged
Conversation
In do_expand=False (decode/cudagraph) mode, DeepEPV2 dispatch left num_max_tokens_per_rank unset, so the recv buffer defaulted to the buffer's init capacity (= max_num_batched_tokens). The experts then processed ~R * 8192 rows even for a handful of decode tokens, which dominated decode step time. Bound it to the DP-padded batch size (max(num_tokens_across_dp), uniform across ranks), rounded up to a power of 2. The pow2 bucketing keeps DeepEP's per-size dispatch-kernel JIT to a small bounded set of values (compiled once, then cached) instead of recompiling for every per-step size, which otherwise causes a cicc recompile storm that starves the GPU at high concurrency. Measured on DeepSeek-V4-Flash, GB200 x4, dp=4 -ep: concurrency=1 decode step time 100.7ms -> 16.4ms (6.1x), no recompile storm at concurrency=64, GSM8K accuracy unchanged. Signed-off-by: Woosuk Kwon <woosuk@inferact.ai> Co-Authored-By: Roy Wang <jasonailu87@gmail.com> Co-Authored-By: gnovack <novackgm@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>
42691d1 to
55feb4b
Compare
esmeetu
approved these changes
Jun 23, 2026
nkzhenhua
pushed a commit
to nkzhenhua/vllm
that referenced
this pull request
Jun 24, 2026
…oject#46404) Signed-off-by: Woosuk Kwon <woosuk@inferact.ai> Co-authored-by: Roy Wang <jasonailu87@gmail.com> Co-authored-by: gnovack <novackgm@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
qli88
pushed a commit
to qli88/vllm
that referenced
this pull request
Jun 26, 2026
…oject#46404) Signed-off-by: Woosuk Kwon <woosuk@inferact.ai> Co-authored-by: Roy Wang <jasonailu87@gmail.com> Co-authored-by: gnovack <novackgm@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Signed-off-by: Qiang Li <qiang.li2@amd.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
In
do_expand=False(decode / cudagraph) mode,DeepEPV2PrepareAndFinalize._do_dispatchleftnum_max_tokens_per_rankunset, soElasticBuffer.dispatchfell back to the buffer's init capacity (= max_num_batched_tokens). The recv buffer was therefore sized to the worst caseR * max_num_batched_tokens, and the expert kernels processed ~R * 8192rows even when only a handful of decode tokens were present — which dominated decode step time.This PR bounds
num_max_tokens_per_rankto the DP-padded batch size (max(num_tokens_across_dp), uniform across ranks), rounded up to a power of two.The pow2 bucketing is important: DeepEP JIT-compiles a separate dispatch kernel per distinct
num_max_tokens_per_rank. Feeding the raw per-step size makes it recompile for every batch size — aciccrecompile storm that starves the GPU at high concurrency. Rounding up to a power of two bounds the compiled set to ~log2(max_num_batched_tokens)values (compiled once, then cached), while staying small for decode (e.g. 1 token → 1) and capped at the buffer's init capacity for prefill.Prefill (
do_expand=True) is unchanged — it keeps the existingnum_max_tokens_per_rank=None/ CPU-sync path.Not a duplicate
Searched open PRs for
num_max_tokens_per_rank,DeepEPV2,DeepEP v2, anddeepep_v2. The related open DeepEP v2 PRs — #45282 (NVFP4 dispatch), #40718 (combine_v2), #45193 (topk_ids optional for do_expand), #45321 (Dockerfile version bump) — address different areas. None touch decode-mode recv-buffer sizing.Test plan
ruff check,ruff format, andmypy(via pre-commit) pass on the touched file.dp=4 -ep, DeepEP v2 + Triton MoE:ciccrecompile storm (previously ~0% GPU utilization during the storm)Note
AI assistance (Claude) was used in preparing this change.
Signed-off-by: Woosuk Kwon woosuk@inferact.ai