Skip to content

[Triton/Gluon] [MLA] gfx1250 head-tiled prestored q_pe rope + bf16-round fp8 GEMM epilogue - #6288

Merged
amd-ruitang3 merged 5 commits into
ROCm:mainfrom
karverma-amd:karverma-amd/gfx1250-mla-prestored-htile-rope
Oct 12, 2026
Merged

amd-ruitang3 merged 5 commits into
ROCm:mainfrom
karverma-amd:karverma-amd/gfx1250-mla-prestored-htile-rope

Conversation

@karverma-amd

Copy link
Copy Markdown
Contributor

Summary

Accuracy-preserving decode q-side speedup for DSR1 bf16-absorb (ATOM_MLA_ABSORB_BF16) on gfx1250.

  • New _qpe_htile_kernel (gluon): with q_nope 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; the head-tile that owns kv-head 0 writes the KV cache once. Reuses _rope_pe_2d + _store_mla_kv_cache, so q_pe and the KV cache are bit-identical to the full-rope kernel while skipping the dominant q_nope read/write. Grid B*cdiv(QH,BLOCK_H), num_warps=1.
  • fused_qk_rope_cat_and_cache_mla: adds q_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-absorb q_nope written straight into an fp8 q_out is bit-identical to the split path (bf16 GEMM epilogue + fp8 rope cast). 16-bit outputs unchanged.

Motivation

Under bf16 absorb, the fp8-q_nope passthrough (#6239) drops MLPerf exact_match below the gate. Keeping q_nope bf16 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:

  • rope 33 → ~11 µs; q-side (k-up GEMM + rope) 59 → ~41 µs (−29%).
  • Numerics: q_pe and KV cache bit-identical to the full-rope kernel (match 1.000000).
  • MLPerf DSR1 offline accuracy (4388 samples): exact_match 80.58 (baseline) → 80.70 (PASS, gate 80.545), tokens/sample 3910.3.

Enable with ATOM_MLA_ABSORB_BF16_FUSE_QOUT=1 (ATOM-side flag; no ATOM code change).

…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]>
@karverma-amd
karverma-amd requested a review from a team October 8, 2026 20:10
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6288 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title [Triton/Gluon][MLA] gfx1250 head-tiled prestored q_pe rope + bf16-round fp8 GEMM epilogue [Triton/Gluon] [MLA] gfx1250 head-tiled prestored q_pe rope + bf16-round fp8 GEMM epilogue Oct 8, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 8, 2026 21:33
amd-ruitang3 pushed a commit that referenced this pull request Oct 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_prestored dispatch.
  • 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.

@zufayu
zufayu requested review from a team and Dewei-Wang-sh October 9, 2026 01:54
karverma-amd and others added 4 commits October 10, 2026 07:01
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]>
@amd-ruitang3
amd-ruitang3 merged commit c53e9b3 into ROCm:main Oct 12, 2026
yuychang added a commit to yuychang/aiter that referenced this pull request Oct 12, 2026
- Take main's versions of test_pa_prefill.py and test_fused_qk_norm_rope_gate_fp8_quant.py.
- Main fixed the same default-device leak in ROCm#6406 and ROCm#6288, so this branch's test-only fix is no longer needed.
amd-ruitang3 pushed a commit that referenced this pull request Oct 12, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants