mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[GH-ISSUE #595] [Feature Request] Support Expert-Choice Routing via Native Expert-Centric API ([num_experts, capacity]) #366
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#366
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?
Originally created by @niyunsheng on GitHub (Mar 30, 2026).
Original GitHub issue: https://github.com/deepseek-ai/DeepEP/issues/595
Background
Expert-Choice routing (Zhou et al., Mixture-of-Experts with Expert Choice Routing, NeurIPS 2022) inverts standard Token-Choice routing: instead of tokens selecting experts, each expert selects its top-C preferred tokens.
This paradigm is increasingly adopted in large-scale models, such as EC-DiT (EC-DIT: Scaling Diffusion Transformers with Adaptive Expert-Choice Routing, ICLR 2025). In configurations with 64 or 128 experts, a popular token can be selected by well over 32 experts.
Current Limitation & Performance Bottleneck
DeepEP currently enforces a Token-centric design where
topk_idxexpects a shape of[num_tokens, num_topk]. Mapping Expert-Choice outputs back to this Token-centric format introduces two critical issues:EP_DEVICE_ASSERT(num_topk <= 32)(e.g.,intranode.cu#L408).[num_tokens, num_topk],num_topkmust equal the maximum number of times any single token is selected. Because token selection distribution is highly skewed in EC routing, the resultingtopk_idxtensor will be extremely sparse, filled with padding (e.g.,-1). Processing this padded tensor through the current dense kernels wastes registers, shared memory, and memory bandwidth.Proposed Solutions
Solution 1: Native Expert-Centric API (Preferred)
Introduce a new set of dispatch/combine APIs that natively accept Expert-centric indices.
Input Shape:
token_indicesof shape[num_experts, expert_capacity].Advantages: Directly aligns with the output format of Expert-Choice models, avoiding expensive inverse mapping.
num_topk <= 32constraint naturally, as the iteration is over capacity rather than a variable number of experts per token.Expected API Behavior:
Solution 2: Relax num_topk Limit with Sparse Branching (Alternative / Fallback)
If adding a new API surface is temporarily out of scope, the existing
[num_tokens, num_topk]API can be modified to tolerate EC routing.EP_DEVICE_ASSERT(num_topk <= 32). To mitigate the padding overhead described above, the CUDA kernels (intranode.cu/internode.cu) must be updated with dynamic branching to early-exit (break) warp execution when encountering padding indices (-1), minimizing invalid memory accesses.num_topkloops.@0z5a commented on GitHub (Sep 19, 2026):
I’d like to work on this.
@niyunsheng
For a first PR, I’d prefer to keep the scope around the routing contract and metadata path rather than immediately modifying every transport kernel.