Repository navigation
[Triton/Gluon] [MLA] gfx1250 head-tiled prestored q_pe rope + bf16-round fp8 GEMM epilogue - #6288
Conversation
…nd fp8 GEMM epilogue DSR1 bf16-absorb (ATOM_MLA_ABSORB_BF16) decode q-side optimization for gfx1250. - Add _qpe_htile_kernel: a head-tiled gluon MLA q_pe kernel. With q_nope already prestored in q_out (bf16-absorb GEMM writing an fp8 q_out), each program ropes a 2D [BLOCK_H, qk_rope_head_dim] tile of one token's q_pe and the head-tile that owns kv-head 0 writes the KV cache once, reusing _rope_pe_2d + _store_mla_kv_cache. q_pe and the KV cache are therefore bit-identical to the full-rope kernel, while skipping the dominant q_nope read/write. - fused_qk_rope_cat_and_cache_mla: add q_nope_prestored; on gfx1250 pure-decode MLA route to the head-tiled kernel. - batched_gemm_bf16 (gfx1250 gluon): when the output is fp8 (8-bit), round the fp32 accumulator through bf16 (fp32->bf16->fp8) so a bf16-absorb q_nope written straight into an fp8 q_out is bit-identical to the split (bf16 GEMM epilogue + fp8 rope cast); 16-bit outputs unchanged. Decode q-side (ISL1024/OSL4096 shape, T=1536): rope 33->~11 us, q-side 59->~41 us (-29%); MLPerf DSR1 4388 accuracy exact_match 80.58 (baseline) -> 80.70 (PASS, gate 80.545). Numerics: q_pe + KV bit-identical to the full-rope kernel. 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: |
There was a problem hiding this comment.
🟡 Changes recommended
Split-K bypasses the new rounding semantics, and the new kernel lacks required tests, benchmark coverage, and tracing representation.
4 open findings
What changed in this PR
Adds a gfx1250 Gluon fast path for prestored MLA query data while preserving bf16-to-fp8 rounding semantics.
Changes:
- Adds head-tiled RoPE and KV-cache handling.
- Exposes
q_nope_prestoreddispatch. - Adds bf16 rounding before fp8 GEMM output conversion.
| File | Description |
|---|---|
aiter/ops/triton/fusions/fused_kv_cache.py |
Dispatches the prestored-query path. |
aiter/ops/triton/_gluon_kernels/gfx1250/fusions/fused_kv_cache.py |
Implements the head-tiled kernel. |
aiter/ops/triton/_gluon_kernels/gfx1250/gemm/batched/batched_gemm_bf16.py |
Adjusts fp8 epilogue rounding. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
psf/black@stable (Required 'Check Code Style with Black') expands the multi-arg def/launch lines in _qpe_htile_kernel to one-per-line. No logic change; ruff clean. Co-authored-by: Cursor <[email protected]>
…_prestored Addresses review findings on ROCm#6288: - batched_gemm_bf16 (gluon launcher): an fp8 YQ relies on the GEMM epilogue's fp32->bf16->fp8 round to stay bit-identical to the split (bf16 epilogue + fp8 rope cast) path. Split-K writes fp32 partials and the shared reduce kernel casts fp32->fp8 directly, bypassing that round. Force NUM_KSPLIT=1 when YQ is 8-bit so the bf16-absorb q_nope-into-fp8-q_out result stays bit-identical; the affected GEMM's K (kv_lora_rank) is small so split-K buys nothing. - fused_qk_rope_cat_and_cache_mla: document q_out and q_nope_prestored (semantics + the KH==1 / gfx1250 pure-decode restrictions already asserted). Co-authored-by: Cursor <[email protected]>
Keep the gfx1250 prestored q_pe path after main extracted the shared _cat_and_cache_mla launcher, and thread q_nope_prestored through it. Co-authored-by: Cursor <[email protected]>
torch.empty() follows the process default device, which is CUDA in the MI35X shard, so the CPU-rejection test never reached the device check and failed on the later bfloat16 requirement. Co-authored-by: Cursor <[email protected]>
main (#6288) added q_nope_prestored with a gfx1250 gluon head-tiled kernel restricted to pure decode. Keep it for that case and route everything else (other archs, mixed prefill + decode) to the Triton q_pe rope kernel from this PR instead of asserting.


Summary
Accuracy-preserving decode q-side speedup for DSR1 bf16-absorb (
ATOM_MLA_ABSORB_BF16) on gfx1250._qpe_htile_kernel(gluon): withq_nopeprestored inq_out(bf16-absorb GEMM writing an fp8q_out), each program ropes a 2D[BLOCK_H, qk_rope_head_dim]tile of one token'sq_pe; the head-tile that owns kv-head 0 writes the KV cache once. Reuses_rope_pe_2d+_store_mla_kv_cache, soq_peand the KV cache are bit-identical to the full-rope kernel while skipping the dominantq_noperead/write. GridB*cdiv(QH,BLOCK_H), num_warps=1.fused_qk_rope_cat_and_cache_mla: addsq_nope_prestored; on gfx1250 pure-decode MLA routes to the head-tiled kernel.batched_gemm_bf16(gfx1250 gluon): when the output is fp8 (8-bit), round the fp32 accumulator through bf16 (fp32→bf16→fp8) so a bf16-absorbq_nopewritten straight into an fp8q_outis bit-identical to the split path (bf16 GEMM epilogue + fp8 rope cast). 16-bit outputs unchanged.Motivation
Under bf16 absorb, the fp8-
q_nopepassthrough (#6239) drops MLPerf exact_match below the gate. Keepingq_nopebf16 forces a full rope kernel (~33 µs, grid-overhead bound). This prestored head-tiled path keeps the query/KV math bit-identical to the passing baseline while cutting the rope cost.Test plan / results
Decode shape ISL1024/OSL4096, T=1536, gfx1250:
q_peand KV cache bit-identical to the full-rope kernel (match 1.000000).Enable with
ATOM_MLA_ABSORB_BF16_FUSE_QOUT=1(ATOM-side flag; no ATOM code change).