[MoE] Generalize masked activation for padded layouts - #51217
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
/ci run |
|
✅ Triggered Buildkite CI #82656 for commit |
7f1e1ca to
215681a
Compare
fd7145b to
8a1ec76
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #82709 for commit |
76d4f5d to
af1eb3a
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #82773 for commit |
|
This pull request has merge conflicts that must be resolved before it can be |
af1eb3a to
d954c9c
Compare
|
/ci run |
|
✅ Triggered Buildkite CI #82928 for commit |
|
/ci run |
|
✅ Triggered Buildkite CI #83030 for commit |
|
/ci run |
|
✅ Triggered Buildkite CI #83815 for commit |
|
This pull request has merge conflicts that must be resolved before it can be |
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
24e145e to
ae334b4
Compare
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: mgoin <mgoin64@gmail.com>
|
/ci run |
|
✅ Triggered Buildkite CI #85147 for commit |
Summary
[T, D]) and per-expert valid prefixes ([E, T, D])NotImplementedErrorwhen a future activation lacks a masked implementationApplyMoEActivationConfiginstead of backend-specific SITU/clamped-SiLU branchesindexedwithout EP,grouped_contiguouswith EP, andgrouped_maskedfor batched experts; environment overrides remain available but are validated choicesexpert_mapin the Humming permute pathWhy
DeepEP v1 and v2 expose different padded layouts. Legacy/batched execution has one valid prefix per expert, while DeepEP v2 has one valid prefix in a flat cudagraph receive buffer. Backend-specific activation branches had diverged and made SITU especially expensive in Kimi K3.
The shared op makes the layout contract explicit and specializes the flat versus batched branch at compile time. The final Kimi investigation also found a correctness issue before activation: DeepEP v2 uses
-1for padding, but Humming's permute preprocessing readexpert_map[topk_id]before checking the ID. Invalid IDs now become the expert sentinel before any map access. The regression covers both-1and a positive out-of-range ID.Model validation
DeepSeek-V4 Flash
Tested
deepseek-ai/DeepSeek-V4-Flash-0731with automatic Humming selection and noVLLM_HUMMING_MOE_GEMM_TYPEoverride:indexed, eager GSM8K 100: 0.96 accuracy, 0 invalidgrouped_contiguous, eager GSM8K 100: 0.95 accuracy, 0 invalidThe close DP1/DP2 scores provide a model-level control for the new DeepEP v2 layout. A separate two-GPU correctness test covers the DSV4 topology (256 experts, top-k 6, K=4096, N=2048, MXFP4/BF16) including an idle DP rank.
Kimi K3
Served
mgoin/Kimi-K3-pruned75on four B300 GPUs with:DeepEPV2All2AllManagerand Humminggrouped_contiguousautomaticallyNONE, so this is CUDA-graph rather than TorchInductor validationBefore the invalid-ID guard, the same run emitted repeated
@tokens; GSM8K 100 was 0% accurate with 100% invalid responses and every request exhausted 256 tokens. After the guard, chat-mode GSM8K 100 was 15% accurate / 33% invalid with 18,611 output tokens. Inspection showed the remaining invalid responses were mostly coherent but unfinished reasoning from this 75%-pruned checkpoint; a 10-question diagnostic at 1,024 tokens improved to 30% / 20% invalid. I do not treat the latter small sample as a model-quality result, but the disappearance of repeated-token corruption plus the focused native regression isolates the kernel fix.Kimi required the 512-token batch cap on four B300s. A 2,048-token cap OOMed because DeepEP v2's worst-case receive/permute scratch must cover
max_tokens * dp_size * topkrows.Coverage and intentional exclusions
grouped_maskedGPU correctness testsapply_moe_activationpathThe full-model DSV4 and Kimi runs exercise DeepEP v2
grouped_contiguous. There is no fresh full-model run ofBatchedExperts -> grouped_maskedafter the final rebase; that layout is covered at the kernel/backend-test level. Legacy DeepEP v1 was tested earlier during development, while this final validation round focused on v2 because it is the important new layout.Tests
Also completed:
git diff origin/main...HEAD --checkDeepEP v2 model tests used an isolated user-space environment with NCCL 2.30.7 and NVSHMEM 3.3.24 plus
EP_DISABLE_GIN=1; no sudo was required. The shared development.venvcurrently has NCCL 2.29.7, so its automatic DeepEP refresh cannot compile v2 GIN types. This is an environment-version limitation, not a vLLM native-extension failure.Duplicate-work check
Open-PR searches for
masked MoE activation Humming,SITU Humming, andapply_moe_activation batchedfound only this PR, so this does not duplicate another open change.AI assistance
AI assistance was used to develop and test this change. The human submitter reviewed the changed lines, understands the implementation and validation, and is responsible for defending the change end to end.