Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Speculative decode + DCP is gated on the decode's own persistent predicate, so ATOM_MLA_PAGE_SIZE > 1 is refused rather than run non-persistent. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Both aiter queries (persistent support and the gfx1250 width) describe the call through mla_dcp_decode_call: a causal verify takes the round-robin kernel, the DSpark draft's non-causal block (causal_decode=False) does not. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Both aiter queries (persistent support and the gfx1250 width) describe the call through mla_dcp_decode_call: a causal verify takes the round-robin kernel, the DSpark draft's non-causal block (causal_decode=False) does not. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Both aiter queries (persistent support and the gfx1250 width) describe the call through mla_dcp_decode_call: a causal verify takes the round-robin kernel, the DSpark draft's non-causal block (causal_decode=False) does not. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Update: 64 heads vs padded 96 heads — small batches with skewed contexts still lose Measured the full
Still slower: small batches with skewed contexts (first row)
Next steps
Correctness on the same build
|
The PS1 kernel serves a multi-token query only at some head counts, and which depends on the query length, the KV dtype and the call (16 heads only up to 4 rows; 32/64 up to 8 with ROCm/aiter#7913). Instead of a width table of its own, ATOM asks aiter's get_mla_decode_num_heads (ROCm/aiter#7913) with the call it makes: LSE for the merge, round-robin KV shards over the DCP group. - The layer and both metadata builders (native and vLLM plugin) size the gathered width from one query length, mla_dcp_decode_query_len. - Both aiter queries (persistent support and the gfx1250 width) describe the call through mla_dcp_decode_call: a causal verify takes the round-robin kernel, the DSpark draft's non-causal block (causal_decode=False) does not. - Speculative decode + DCP is refused in the layer, where the head width is known: aiter's shape-support query at that width and query length, plus ATOM_MLA_PAGE_SIZE <= 1. The config-time gate is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n row's stage-2 k-tile to K (#7963) kimik3tp8_tuned_grouped_fmoe.csv runs the token=16384 row's stage 2 (K = inter_dim = 384 per TP8 expert slice) with tile_k2 = 512, larger than K. The gfx1250 TDM grouped GEMM then reads past the expert slice and the GPU faults in mxfp4_tdm_fp4_t128x128x512_..._K384_e896 ("Page not present"). ATOM's warmup prefills 2 x 8192 tokens, so Kimi-K3 TP8 hits this row at every server start. Use tile_k2 = 128, which every other row of the table uses and which divides 384. The row came from #7296; the other 14 rows are unchanged. Verified on two MI455X nodes (Kimi-K3 TP8 + DCP8 with DSpark, ATOM main 9fec99786 + ROCm/ATOM#2647 + #2760, aiter main b6f1ff6 + #7912 + #7913 + this change). The server starts where it faulted in warmup before. GSM8K 5-shot is 0.9606 flexible / 0.9613 strict, and the MLPerf Endpoints agentic bench completes 293/293 samples at c4 and 1703/1703 at c64.
c6aeb29 to
89b36a8
Compare
get_mla_decode_num_heads now comes from its own aiter PR, ROCm/aiter#8181. ROCm/aiter#7913 keeps only the 32/64-head multi-token PS1 tiles: with it the 64-head draft block runs unpadded, without it the draft pads to 96 heads.
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
89b36a8 to
067fee3
Compare
967a3e3 to
5fb8410
Compare
…eral qo tiles get_mla_decode_num_heads now keeps 32/64 heads for these shapes (32 and 64 heads up to qlen 8) instead of padding to 96; its test expectations move with the routing.
…he tile loop compute_tile_state decided at run time whether a tile is the work item's first one (no pending PV yet) with `if tile_start > kv_start`. The branch sat between the tile's QK and the previous tile's PV, so every iteration of the tile loop was two basic blocks, and the sched_group_barrier interleave of the QK / PV WMMAs and the V loads could not span them. run_tiles now runs the first full tile before the loop (first_tile=True), the loop body with first_tile=False, and compiles the masked last tile for both cases behind `last_tile_start > kv_start`. first_tile is a compile-time argument of process_tile / compute_tile_state; None keeps the run-time check. Gather-only waves are unchanged.
5fb8410 to
51bb7c6
Compare
…#3889) mla_min_query_heads padded every gfx1250 draft block wider than one row to 96 query heads. It now asks aiter's get_mla_decode_num_heads for the call the draft makes without DCP (non-causal, no LSE, persistent PS1) and keeps the fixed rule only for an aiter without that query or with no answer. With ROCm/aiter#7913 (in aiter k3-455-dev) the Kimi-K3 DSpark draft at TP 1 (DP8 EP8 decode: 64 heads, T = 4) runs at its 64 heads instead of 96. DCP layers already size their gathered width with aiter; this stays their lower bound.
… VGPR pins (#8736 @ 13b071f, head 2026-11-26T06:02:59Z) (#8743) Port of #8736's commits d9926d2 and 13b071f onto k3-455-dev; its first commit (#8181 + #7913) is already here. Conflicts: - mla_pagesize1_fp8_fp8.py: #8736's file. It carries #7913 @ 51bb7c6 (k3-455-dev had 067fee3), the only difference in that file. - mla_reduce_kernels.cuh: k3-455-dev's file (keeps #7876 and #7914) plus #8736's row-parallel reducer and its dispatch, checked first as in #8736. Co-authored-by: xiangM99 <[email protected]>
…@ 067fee3, head 2026-11-19T06:16:26Z) Applied as the diff 2d34816..067fee3 (7 files) onto the rebased 1116 tree; PR state: open, author gbyu-amd, base gyu/mla-decode-num-heads. (cherry picked from commit 9d4e935) Updated 12-03 to the PR head #7913 @ 51bb7c6: folds in the PR's later commits 51bb7c6 [FlyDSL] [gfx1250] MLA PS1: run a work item's first KV tile outside the tile loop.
… VGPR pins (#8736 @ 13b071f, head 2026-11-26T06:02:59Z) (#8743) Port of #8736's commits d9926d2 and 13b071f onto k3-455-dev; its first commit (#8181 + #7913) is already here. Conflicts: - mla_pagesize1_fp8_fp8.py: #8736's file. It carries #7913 @ 51bb7c6 (k3-455-dev had 067fee3), the only difference in that file. - mla_reduce_kernels.cuh: k3-455-dev's file (keeps #7876 and #7914) plus #8736's row-parallel reducer and its dispatch, checked first as in #8736. Co-authored-by: xiangM99 <[email protected]> (cherry picked from commit 5b18892)
…#3889) mla_min_query_heads padded every gfx1250 draft block wider than one row to 96 query heads. It now asks aiter's get_mla_decode_num_heads for the call the draft makes without DCP (non-causal, no LSE, persistent PS1) and keeps the fixed rule only for an aiter without that query or with no answer. With ROCm/aiter#7913 (in aiter k3-455-dev) the Kimi-K3 DSpark draft at TP 1 (DP8 EP8 decode: 64 heads, T = 4) runs at its 64 heads instead of 96. DCP layers already size their gathered width with aiter; this stays their lower bound. (cherry picked from commit 9b6bb9d)
Stacked on #8181 (
get_mla_decode_num_heads), whose test expectations this PR moves with the new routing; retarget tomainonce it merges.Summary
On gfx1250 the FlyDSL PS1 MLA decode kernel takes a 32- or 64-head query only while
heads x max_seqlen_q <= 128(32 heads up to 4 tokens, 64 heads up to 2). This lets it take 32 and 64 heads up to 8 query tokens, as the several qo tiles the metadata planner already cuts such a query into. A 64-head, 4-token decode (e.g. a speculative draft block) no longer has to be padded to 96 heads: stage 1 is 13–45% faster than the padded 96-head JIT kernel and 6–32% faster than the 96-head code object on MI455X.Motivation
mla_v12_num_qo_tilesalready splits a request whoseheads x max_seqlen_qrows exceed the 128-row budget intoceil(rows / 128)tiles ofceil(max_seqlen_q / tiles)positions, e.g. 64 heads x 4 tokens into two 2-row tiles. The PS1 kernel did not take those tiles:q_tile_rows = max_seqlen_q) below 64 heads;kv_end, which the planner trims by the tiles after it, not by rows;_validate_pagesize1_inputsandmla_decode_backend/mla_decode_head_plan_v1_2stop atheads x max_seqlen_q <= 128, so these shapes leave PS1 on gfx1250.So a caller with 64 query heads and a multi-token query (an MTP verify, or a draft block with the query all-gathered over decode context parallel) pads the heads to 96. A third of stage 1's work then goes to pad heads, and with one query row per work item each request's KV is read once per token.
Changes
mla_gfx1250/mla_common.py).planner_q_tile_rows(heads, max_seqlen_q)mirrorsmla_v12_num_qo_tiles;wave_layoutsizes a work item to one planner tile. It still rejects tiles of more than 4 rows or 128 head-rows, and caps a tiled query atMAX_TILED_SEQLEN_Q = 8(what is tested).mla_pagesize1_fp8_fp8.py,mla_pagesize1_bf16_bf16.py). When the query is cut into several multi-row tiles, a row's distance from the request's last row comes fromqo_indptr[batch + 1](the work's batch fromwork_info), not from the trimmedkv_end. Single-tile layouts compile as before.aiter/ops/flydsl/mla_kernels.py). Validation defers towave_layout; a tiled causal decode requires and passesqo_indptr(as round-robin CP already does).csrc/include/mla_decode_shape.h).mla_decode_head_plan_v1_2andmla_decode_backendsend 32/64 heads withmax_seqlen_qo <= 8to FlyDSL PS1 without a 16-head fold; 16 heads stay at<= 4, 96/128 unchanged. There is no code object for these shapes, so they run on the FlyDSL JIT.test_mla_flydsl.py:PS1_Q_SEQ_LENS32/64 → 1–8, the metadata check accepts a shorter last tile,--causal 0 1runs the non-causal (draft block) form, and--q-seq-lenchoices followPS1_Q_SEQ_LENS.test_mla_shape_support.py: (64,3) (64,4) (64,8) (32,5) (32,8) route to FlyDSL PS1 with fold 1; (64,9) does not;get_mla_decode_num_headsnow keeps 32/64 heads up to qlen 8 (heads(16, 5)32,heads(64, 8)64) instead of padding to 96.The routing header and the kernel change go together: the header only admits the shapes the kernel now takes, and without it the new layouts are unreachable through
mla_decode_fwd.Performance (if applicable)
MI455X (gfx1250), one GPU. Whole call: CUDA graph replay with a 2 GB cache flush before each, median of 50. Stage 1 and reduce: torch profiler kernel times over 30 of those replays. 64 query heads, a 4-token non-causal draft block (
max_seqlen_q 4), fp8 Q/KV, page size 1, persistent metadata as built for decode, per-rank KV of 512 or 8192 tokens. "96 heads" is the same query padded to 96 heads (what callers do today): FlyDSL JIT, or the 96-head code object (AITER_MLA_DECODE_PS1_ASM=1,mla_a8w8_qh96_1tg_16mx6_64nx1_msk0_lse_ps).Stage 1:
Whole call (stage 1 +
kn_mla_reduce_v1), same runs:Known cost: at batch 8 x 8192 tokens the reduce takes 13.2 us instead of 8.5 us. 64 heads give 16 two-row tiles of ~13 splits, which
kn_mla_reduce_v1walks row by row, against 32 one-row tiles at 96 heads. The call is still 0.7 us faster than the padded JIT path but 3.2 us slower than the 96-head code object there. #7876 now has a multi-row instance of its wave-per-head reduce for exactly these tiles: rows over row parts, one head per wave, 4 split loads in flight. With it, the 64-head draft block's reduce drops from 7.7 / 13.3 to 6.6 / 12.7 us at batch 8 (512 / 8192 KV tokens), 13.6 → 10.8 us at batch 32 and 19.6 → 10.6 us at batch 64 (8192 tokens); see #7876. Forcedkn_mla_reduce_v1_widedoes not help (14.9 us at batch 8 x 8192).Where 64 heads is slower. A caller that picks the narrowest width aiter reports (for example the DCP decode path in ROCm/ATOM#2760, through
get_mla_decode_num_heads) gathers 64 heads with this PR instead of padding to 96. On the full draft-block sweep (batch 8–128 x 4k–256k context, measured with #7876 and #7912 applied), 64 heads is faster than the padded 96-head code object in 27 of 35 cells and slower in 8:This PR changes neither the planner nor the code objects.
Needs #7912 (on
mainsince 2026-11-18). These shapes reduce multi-row tiles onkn_mla_reduce_v1's massive path. That path had an LDS race once a workgroup reduces more than one row; #7912 fixes it. Without the fix, synthetic 64-head 2-row and 32-head 4-row reduces of 64+ tiles give wrong output in many runs on gfx1250. The numbers above are unchanged with #7912 applied (64-head draft block: 22.1 / 42.8 / 32.2 / 66.5 / 22.3 / 148.5 us).Testing
On MI455X, aiter
mainatffd4a3f(which has #7912) plus #8181 and this change, every case against the torch reference:op_tests/test_mla_shape_support.py: 20 passed, 2 skipped.test_mla_flydsl.py --mode ps1 --num-heads 32 64 --q-seq-len 1 2 3 4 5 6 7 8 --causal 0 1 -b 1 4 -c 1 64 65 2048 --varlen(fp8): 256 cases, all pass.--dtype bf16 --q-seq-len 3 4 5 8 -b 4 -c 65 2048: 32 cases, all pass.--mode cp(round-robin, causal), 64 heads q 3/4/8 and 32 heads q 5/8,--cp-world-size 2 8 -c 64 1200 --varlen: 20 cases, all pass (merged output exact in all; one per-rank partial has 1 element of ~1M outside the tolerance, within the test's 5% gate).--mode ps116/96/128 heads at q 1/2/4, causal 0/1,-b 4 -c 65 2048: 28 cases, all pass.Earlier, on
mainat111fbd8: the--mode cprun at all tiled lengths (64 heads q 3–8, 32 heads q 5–8, 40 cases) and--mode ps1-asm96 heads at q 1/4 passed; with #7912, #7876 and #7914,test_mla_reduce.pyALL PASSED, and the 64-head draft-block benchmark above checked two sampled requests per case against a torch reference with 0 mismatches.gfx9 is not affected: the routing change is under the gfx1250 FlyDSL PS1 branch and the kernels are gfx1250-only.
Documentation
The shapes are selected automatically; the bounds are documented next to the routing code and in
mla_common.py.Dependencies
Breaking Changes
None. Shapes PS1 took before keep their layout and code path (16/96/128 heads, and 32/64 heads within 128 rows: the regression runs above). 32/64-head queries of 3–8 tokens that went elsewhere now run on FlyDSL PS1, and
get_mla_decode_num_headsreturns 32/64 for them instead of 96.Update 2026-11-22: a work item's first KV tile runs outside the tile loop (967a3e3)
compute_tile_statedecided at run time whether a tile is the work item's first one (no pending PV yet) withif tile_start > kv_start. The branch sat between the tile's QK and the previous tile's PV, so every iteration of the tile loop was two basic blocks, and thesched_group_barrierinterleave of the QK / PV WMMAs and the V loads could not span them.run_tilesnow runs the first full tile before the loop (first_tile=True), the loop body withfirst_tile=False, and compiles the masked last tile for both cases behindlast_tile_start > kv_start.first_tileis a compile-time argument ofprocess_tile/compute_tile_state(Nonekeeps the run-time check); gather-only waves are unchanged. Onlymla_pagesize1_fp8_fp8.pychanges; the BF16 kernel is untouched.Stage-1 kernel time, MI455X (gfx1250, 256 CUs), one GPU, FlyDSL JIT (
AITER_MLA_DECODE_PS1_ASM=0), this branch's kernel before / after the commit, FP8, page size 1:cp, max rank)ps1)DCP 8 geomean 0.923. The 96-head JIT kernel gains 4-13% as well (its code object path is unchanged).
Testing (same build):
op_tests/test_mla_flydsl.pyagainst its reference, JIT only, allerr0:--mode ps1for 16 / 32 / 64 / 96 / 128 heads (q_seq up to 4 / 8 / 8 / 4 / 1, batch 8 / 128, ctx 1000 / 8192: 52 rows) and--mode cpwith DCP 2 / 8 for 32 / 64 / 96 / 128 heads (72 rows).black26.10.1 andruff0.16.0 are clean on the changed file.