mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #787] perf: reuse compact dispatch sort permutations for cached handles #785
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#785
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/787
Author: @yuweih205
Created: 10/17/2026
Status: 🔄 Open
Base:
main← Head:perf/cache-compact-sort-1017📝 Commits (1)
b363adeSort once per handle in deterministic dispatch📊 Changes
1 file changed (+13 additions, -10 deletions)
View changed files
📝
deep_ep/buffers/ep.py(+13 -10)📄 Description
Compact deterministic dispatch sorts the received rows by source index on every call. For a cached dispatch the handle already fixes that order: the same slots are refilled, the receive counts are the same, and
topk_idxis asserted immutable. This stores the permutation on the handle next tocached_recv_src_metadata_before_sortat the first dispatch and reuses it, so cached compact dispatch no longer builds the sort keys, masks the unused capacity, or sorts.The stored permutation follows the same stream and lifetime rules as the handle's existing cached metadata, so no per-call checks are needed and the reuse also holds under CUDA Graph capture and for deferred epilogues waited on another stream. Each handle keeps one extra int64 tensor of capacity rows (128 KiB at 16k rows). No API, default, native or test-file changes;
tests/ep/test_ep.pyalready compares repeated cached dispatch against the reference, and the EP8 suite passes on this branch with CPU counts (direct and deferred epilogues) and in the sync-free mode.Measured on 8×H200 (PyTorch 2.13.0+cu132), one cached dispatch per rank, 2048 tokens/rank, hidden 4096, top-2, BF16, deterministic,
do_cpu_sync=False, under bothEP_AVOID_RECORD_STREAMpolicies; outputs (payload,topk_idx, weights, source index) are bitwise identical to main across 608 fresh/cached/deferred/graph cases per policy:The removed kernels (radix sort,
arange, compare,clone,masked_fill, memsets) account for about 46 µs of device time per call; the wall-time reduction is mostly host overhead and is a component measurement, not a training-throughput claim. Independent of #786, which removes the unused sorts of the expanded layout; both touchdeterministic_sortand the later one needs a trivial rebase.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.