Repository navigation
Fix/epv2 1250x r1 combine - #886
Merged
Merged
Conversation
At 4 < npes < topk (EP8 with topk 9) validAccumCount stayed topk while the pull has min(npes, topk) slots a warp, so every token below globalWarpNum fell to WarpAccumLF. R1 EP8 bf16 combine C8+C16, 3 alternating rounds: 256 tokens 349.2 -> 31.8 us, 384 633.0 -> 47.3 us; 512 and up and topk 6 unchanged.
…rows The kRows loops of the 1250x push combine leave at the row count of the token with break. LLVM fully unrolls a loop that can leave early only up to -unroll-max-upperbound (8) trips, so at kRows = min(worldSize, topk) = 9 (DeepSeek-R1, topk 9, at EP16 and up) these loops stay rolled, and the per-row arrays pk[] and sb[] are indexed at run time and placed in scratch: fp8 ws16 k9 64x8 has 304 B private, 70 scratch stores and 14 loads; fp4 ws16 k9 64x8 has 160 B, 162 and 18. Past 8 rows the loops now skip the trips past the row count of the token (continue), which gives them an exact trip count; both kernels then use no scratch (VGPRs 141 to 172 and 192 to 186). Configurations with kRows <= 8 keep break and compile to the same instructions as before (all 52 combine kernels of a JIT cache rebuilt and compared).
EpMultiWarpIter splits a token over ceil(globalWarpNum / numTokens) warps, so with few tokens the hidden slice of a warp falls under 128 B (7168 bf16 over 512 warps is 14 elements), and the TDM stage of the pull combine then takes _cFoldPeers, one scalar load per lane per peer. When the pull path is usable the warps of a token are now capped at hiddenDim / (128 / sizeof(TokT)), 112 for 7168 bf16, so every slice keeps the TDM path. R1 (topk 9, 64 experts a rank) EP4 bf16 pull combine, one MI450 node, graph mode, 3 alternating rounds, median: 1 token 18.17 -> 12.10 us, 2 tokens 18.69 -> 12.27 us; 4 to 512 tokens, whose slices were already 128 B or more, within 0.16 us in every round. V4-Pro (topk 6) unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(ep/v2): three 1250x combine slow paths at topk 9 (DeepSeek-R1)
Three fixes in src/ops/dispatch_combine_v2/ep_intranode_1250x.hpp, each
found as a cell far off its neighbours in the EP4 / EP8 / EP16 dtype x
token combine latency table of main on gfx1250. All three are hit by
topk 9 (DeepSeek-R1, hidden 7168). No new switches or env vars.
Pull combine: compact sources where npes < topk (EP8 bf16).
Dispatch sends a token to a rank at most once, so at most npes of
its topk source pointers are non-null. The null ones were squeezed
out only at npes <= 4. At EP8 with topk 9 the source count stayed
at 9, above the min(npes, topk) = 8 that the TDM path takes, so both
TDM branches were skipped and every token count below globalWarpNum
fell back to WarpAccumLF. Sources are now compacted at
npes <= 4 || npes < topk.
Push combine: keep the row arrays out of scratch past 8 rows (EP16
fp8 / fp4). The kRows loops left at the row count of the token with
break. LLVM fully unrolls a loop with an early exit only up to 8
trips (-unroll-max-upperbound), so at kRows = min(worldSize, topk)
= 9 they stayed rolled and the per-row arrays pk[] / sb[] went to
scratch. Past 8 rows the loops continue instead, which gives them an
exact trip count. kRows <= 8 keeps break and compiles to the same
instructions as before.
Pull combine: give every warp at least 128 B of a token (bf16, few
tokens). EpMultiWarpIter splits a token over
ceil(globalWarpNum / numTokens) warps, and a slice under 128 B takes
_cFoldPeers, one scalar load per lane per peer. When the pull path
is usable, the warps of a token are now capped at
hiddenDim / (128 / sizeof(TokT)), 112 for 7168 bf16.
MI450, HIP graph mode, CHECK passed at every measured point. Combine
latency in us, median of 3 alternating rounds, main -> this change;
every speed-up below held in all 3 rounds.
4 tokens get 56 / 112 / 224 B slices): 1 token 18.17 -> 12.10,
2 tokens 18.69 -> 12.27; 4 to 512 tokens within 0.16 us every round.
384 tokens 633.0 -> 47.3; 512 and 16384 tokens unchanged.
and 1388.3 -> 605.1 (fp4); faster at every measured token count from
1 to 16384.
EP8 and EP16 were measured with fix 1 alone and fix 2 alone; those
combine kernels compile to the same instructions as this change
(without fix 3 for EP8). Against main, 16 of the 54 combine kernels of
a rebuilt JIT cache change (the 12 bf16 pull combines and the 4 EP16
topk 9 fp8 / fp4 push combines); the other 38 are identical and none
uses scratch. 43 of the 53 dispatch kernels differ, only in the
immediates of s_add_nc_u64 (PC-relative addresses of read-only data).
Not measured: EP8 / EP16 bf16 at 1 to 4 tokens, and EP32.