Repository navigation
[ASM] [HIP] [FlyDSL] Optimize gfx1250 PS1 FP8 MLA decode for Kimi-K3 target and draft workloads - #8736
[ASM] [HIP] [FlyDSL] Optimize gfx1250 PS1 FP8 MLA decode for Kimi-K3 target and draft workloads#8736xiangM99 wants to merge 4 commits into
Conversation
…s several qo tiles (head64 不再补零到 96)
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
… 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]>
|
@xiangM99 Thanks for this PR; its QH64 objects and q5 row packing are already in the The shapes (k=7 instead of this PR's k=4)
What we measured (gfx1250,
|
| batch / context | q1 | q4 | q8 |
|---|---|---|---|
| 16 / 98K | 94 µs | 304 µs | 571-617 µs |
| 24 / 98K | 134 µs | 453 µs | 895-990 µs |
| 32 / 98K | 168 µs | 585 µs | 1091-1197 µs |
| 24 / 128K | 1323 µs |
2. q8 row packing pays at long context, not at 32K. Packed vs generic, both built with the public FlyDSL 0.5.3
toolchain:
| batch | 32K | 48K | 64K | 98K | 128K |
|---|---|---|---|---|---|
| 16 | +13% | +3% | -1% | -5% | -8% |
| 24 | +13% | +6% | +1% | -8% | -14% |
| 32 | +3% | -3% | -6% | -8% | -7% |
- We have a draft: branch
zejun/k3-455-mla-q8, with (96, 7) and (96, 8) inROW_PACKED_SHAPESand the C++ gate, plus
8 code objects (16mx42/16mx48, causal x lse) and an exporter that reproduces the checked-in objects byte for
byte. - But our exports use the public LLVM, which is ~13-15% slower than the toolchain that built this PR's objects
(same generic kernel: b16/98K 571 µs as shipped vs 656 µs from the public build). That cancels the packing gain. - The planner gate (
kMlaPs1PackMinBatches = 16, cost model tuned on q5) also rejects q8 at these shapes.
3. Where the time goes in generic q8:
- Not LDS bandwidth. Measured 214-222 B/clk/CU. Cutting K or V LDS reads 4x in a JIT build makes it slower, not
faster. - Not HBM re-reads of the same KV. Co-scheduling a request's 8 row items on one XCD for L2 reuse: <= 3% for QH96,
7-15% for the QH64 draft. - Our estimate: per-pass efficiency. ~43% WMMA utilization, with 3 of 4 waves computing and softmax/LDS latency
not fully hidden.
4. Draft, QH64 q7 non-causal: b16/98K 324 µs, b24/98K 490 µs (q1: 92 µs).
The ask
- Row packing for QH96 q7/q8 with objects built by your toolchain (feel free to take our branch), plus a
context-aware pack decision: pack from ~64K mean context (~48K at 32+ requests), keep generic at 32K. - The QH64 q7 non-causal draft path at b16-24, 64-130K.
- Beyond packing: per-pass efficiency for 7-8 query rows (QK/PV overlap, hiding softmax and LDS latency), if
there is headroom.
Rough target: -20-30% MLA time at b16-24 x 96-128K. That would shorten the late-window decode step by ~8-12%.
Repro:
AITER_MLA_PS1_PACK_ROWS=0|1 python3 op_tests/test_mla_flydsl.py --mode ps1-asm --num-heads 96 --q-seq-len 8 \
-b 16 24 32 -c 32768 65536 98304 131072
python3 op_tests/test_mla_flydsl.py --mode ps1 --num-heads 64 --q-seq-len 7 --causal 0 -b 16 24 -c 65536 98304 131072
We can share our timing-only harness and the full tables, and can run validation on our side. Thanks!
… 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)
Summary
Optimize gfx1250 PS1 FP8 MLA decode for Kimi-K3 target and draft workloads, adding native multi-token QH64 execution and automatic QH96/q5 row packing.
This PR also picks the following prerequisite changes:
get_mla_decode_num_heads: the head count to pad a decode query toMotivation
existing K3 draft path pads 64 query heads to 96 for qlen=4, wasting compute on 32 zero heads. The QH96/q5 target path also processes query rows independently, causing repeated KV passes on large-batch, long-context workloads.
Changes
Performance (if applicable)
Measured on gfx1250 using the K3 grid:
Additional results:
Testing
Documentation
Dependencies
Breaking Changes
PR Self-Review
Reviewed revision
Behavior and intent
Validation and unverified scope
PR-specific question
Changed op tests