mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #739] [CLOSED] fix: invalidate non-sync dispatch padding metadata #744
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepEP#744
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepEP/pull/739
Author: @waizuichougou
Created: 8/26/2026
Status: ❌ Closed
Base:
main← Head:fix/elastic-dispatch-padding-metadata📝 Commits (2)
69db086fix: invalidate non-sync dispatch padding metadatab6a8911test: clarify dispatch padding allocator poisoning📊 Changes
2 files changed (+36 additions, -2 deletions)
View changed files
📝
deep_ep/include/deep_ep/impls/dispatch_copy_epilogue.cuh(+20 -2)📝
tests/elastic/test_ep.py(+16 -0)📄 Description
Summary
Initialize the unused suffix of
recv_topk_idxto-1for non-expanddispatches that allocate worst-case output buffers without a CPU
synchronization.
This fixes a correctness issue encountered by vLLM's DeepEP V2
decode/CUDA Graph path, where stale padding entries can be interpreted as
valid expert IDs and corrupt routing data. vLLM currently works around the
issue by sanitizing the metadata downstream:
github.com/vllm-project/vllm@04c2a8deacThe initialization is performed by the existing dispatch copy epilogue, so it
does not add another kernel launch or require a host synchronization.
Problem
When
ElasticBuffer.dispatchruns withdo_cpu_sync=Falseanddo_expand=False, its output tensors are allocated for the worst-case numberof received tokens. The dispatch copy epilogue reads the actual received token
count from the GPU prefix sum, but it only writes the valid prefix of each
output tensor.
Because
recv_topk_idxis allocated withtorch::empty, rows after the actualreceived count may contain stale allocator data. A consumer that processes the
complete fixed-shape CUDA Graph buffer can interpret a stale, non-negative
value as a valid local expert ID. This can add padding rows to expert routing
lists and corrupt the results of valid tokens.
The linked vLLM fix sanitizes the same uninitialized DeepEP V2 metadata in its
downstream decode/CUDA Graph integration.
DeepEP's legacy dispatch kernels also use
-1for unusedrecv_topk_idxentries, so the fix makes the elastic path follow the existing invalid-expert
sentinel convention.
Fix
Before replacing the worst-case
num_recv_tokensargument with theGPU-resident actual count, record whether the epilogue received a worst-case
output allocation. For non-expand dispatch, use the existing epilogue
kernel/grid to write
-1torecv_topk_idx[actual_count:capacity].This change:
topk_idx_t.Tests
non-sync dispatch.
topk_idx_t.GPUs for actual counts
0,1,2,capacity - 1, andcapacity.compute-sanitizer --tool memcheck; result:ERROR SUMMARY: 0 errors.git diff --check.CI note
The repository's current
format.shreports pre-existingB023findings intests/elastic/test_ep.pyand YAPF formatting differences against the currentmainversion of that file. This change does not introduce a new Ruff finding;the focused syntax and whitespace checks listed above pass.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.