mirror of
https://github.com/deepseek-ai/DeepEP.git
synced 2026-11-05 00:47:32 +00:00
[PR #723] Fix legacy normal kernels trapping when hidden exceeds the TMA staging buffer #731
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#731
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/723
Author: @yashkgp
Created: 8/12/2026
Status: 🔄 Open
Base:
main← Head:fix/legacy-normal-tma-hidden-limit📝 Commits (2)
4e38668Fix legacy normal kernels trapping when hidden exceeds the TMA staging bufferba6a33bRun format.sh📊 Changes
2 files changed (+61 additions, -28 deletions)
View changed files
📝
csrc/kernels/legacy/internode.cu(+42 -17)📝
csrc/kernels/legacy/intranode.cu(+19 -11)📄 Description
Fixes #722.
The legacy normal
dispatch/combinekernels stage each token through a fixed-size per-warp TMAbuffer, but the staged payload grows with
hidden. The only guard isEP_DEVICE_ASSERT, whichtraps inside the kernel, so an oversizedhiddensurfaces as an asynchronousCUDA error: an illegal instruction was encounteredrather than a diagnosable failure. With BF16 andnum_topk=8the effective caps werehidden <= 8184(intranode dispatch),<= 8144(internodedispatch) and
<= 8160(internode combine sender), sohidden = 8192could not run on the normalpath at all — while the low-latency kernels explicitly instantiate
case 8192.Changes
intranode.cudispatch — lift the cap. Stage each token in as many TMA chunks as the buffer canhold instead of hard-coding two halves:
Any
hiddenthat fitted in two chunks before yieldsnum_tma_chunks == 2andtma_chunk_int4 == hidden_int4 / 2, i.e. the identical split, so behaviour and shared memory usageare unchanged for every configuration that works today. Larger
hiddensimply uses more chunks. Thisalso drops the
hidden_int4 % 2 == 0requirement, sinceceil_divhandles the remainder.internode.cucombine — free headroom. The forwarder warps already set this kernel's dynamicshared memory to
9248 * 24 = 221952 B, while the senders claimed only16384 * 8 = 131072 B.Deriving the sender budget from the forwarder one gives
27744 Bper sender warp and raises the capfrom 8160 to 13840, with
smem_sizestaying byte-for-byte identical at221952 B(
max(27744 * 8, 9248 * 24) == max(16384 * 8, 9248 * 24)). AnEP_STATIC_ASSERTpins the budget soit can never shrink below the previous 16384.
internode.cudispatch — host-side check only. This one stages a whole token (data +SourceMeta+ scales + top-k) in a single TMA, so lifting its cap needs chunking or a bigger budget;16384 -> 24576would grow dynamic shared memory from 128KB to 217KB and shrink L1, which wants abenchmark I cannot run. Left as is, but the limit is now checked on the host so it raises an
immediate, actionable
EP_HOST_ASSERTinstead of trapping in the kernel. Same check added for thecombine sender.
The second commit is just
bash format.sh(clang-format 15.0.7, as pinned inrequirements-lint.txt) normalizing the pre-existing lines of the two touched files, sinceformat.shreformats whole files. It contains no functional change and touches none of the new code.Verification — please read
I could not build or run this: no NVIDIA GPU available. What I did verify, by deriving both the host
and kernel formulas from the source and checking them exhaustively:
kNumTMABytesPerWarpfor everyhidden_int4in[1, 200000];bit-identical for
hidden <= 8184;smem_sizeis unchanged at221952 B.Runtime check for a reviewer with hardware — this traps on
mainand should pass here:A throughput sanity check at
hidden = 7168would also be worth doing, to confirm the intranodedispatch loop becoming dynamically bounded costs nothing measurable.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.