[DeepEP V2] Fill invalid recv_topk_idx with -1#46432
Merged
Merged
Conversation
In do_expand=False (decode/cudagraph) mode, DeepEPV2 dispatch writes only rows [0, num_recv_tokens) of the worst-case-allocated recv buffer; the rest is left UNINITIALIZED. The previous globalization only added the rank expert offset to local ids >= 0, leaving the uninitialized padding rows with stale contents that can alias valid expert ids. Experts that build routing over *all* rows (e.g. the Triton MoE backend's make_routing_data) then treat them as real routed tokens, polluting the per-expert token lists and corrupting real tokens. Replace the torch where-chain with a fused Triton kernel that, in one pass, converts valid local ids to global and forces everything else to -1: non-local / out-of-range expert slots, and every row past num_recv_tokens (read on-device from the recv prefix sum, so it stays cudagraph-safe). Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
6171f86 to
0bd0f36
Compare
nkzhenhua
pushed a commit
to nkzhenhua/vllm
that referenced
this pull request
Jun 24, 2026
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
qli88
pushed a commit
to qli88/vllm
that referenced
this pull request
Jun 26, 2026
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai> 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.
DeepEP V2 can currently leave portions of the
recv_topk_idxbuffer uninitialized. Some MoE backends (e.g.,triton_unfused) may then interpret those uninitialized entries as valid slots. This PR fixes the issue by using a fused Triton kernel to fill invalid slots with-1.