Repository navigation
[Triton/Gluon] [gfx1250] fused_kv_cache: fp8 q_nope passthrough - #6239
karverma-amd wants to merge 2 commits into
Conversation
In the fused qk-rope + cat + cache MLA kernel, always stage the roped q_pe into a q_out-dtype buffer, and when q_nope already matches the q_out dtype (e.g. pre-quantized to fp8) TDM-store its load buffer directly instead of reading it to registers and casting. Halves the dominant q_nope read when the KV cache is fp8. In-engine DSR1 1k4k conc6144 decode: rope-cache 34.6 -> 29.9 us. Bit-identical when dtypes match.
🏷️ 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
The new mixed FP8/BF16 path lacks targeted regression coverage.
1 open finding
What changed in this PR
Optimizes the gfx1250 Gluon MLA KV-cache kernel for pre-quantized FP8 query passthrough.
Changes:
- Adds output-typed staging for roped
q_pe. - Directly stores matching-dtype
q_nopewithout register conversion. - Preserves explicit casting when output dtypes differ.
| File | Description |
|---|---|
aiter/ops/triton/_gluon_kernels/gfx1250/fusions/fused_kv_cache.py |
Implements FP8 passthrough and independent q_pe staging. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
| qpe_smem_out = gl.allocate_shared_memory( | ||
| q_out_ptr.dtype.element_ty, [BLOCK_D_pe], SH | ||
| ) |
🏷️ 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 |
Add test_fused_qk_rope_cat_and_cache_mla_fp8_q_out covering the fp8 q_out paths the passthrough change introduced, which the existing test (bf16 q_nope + bf16 q_out) never exercises: - q_nope_fp8=True: pre-quantized fp8 q_nope with fp8 q_out hits Q_OUT_MATCHES, so q_nope is TDM-stored straight from its load buffer. Asserted bit-identical (uint8 view, atol=rtol=0). - q_nope_fp8=False: bf16 q_nope with fp8 q_out takes the load->cast->store path. - Both branches check that the roped q_pe is staged at the fp8 q_out dtype from its own buffer -- the independent qpe_smem_out allocation this PR added. Guards the Copilot "mixed FP8/BF16 path lacks targeted regression coverage" finding. gfx1250-only (the Gluon kernel); skipped elsewhere. Co-authored-by: Cursor <[email protected]>

Summary
In the fused qk-rope + concat + cache MLA kernel
(
_fused_qk_rope_cat_and_cache_mla_kernel), always stage the ropedq_peinto aq_out-dtype buffer, and whenq_nopealready matches theq_outdtype(
Q_OUT_MATCHES, e.g. pre-quantized fp8) TDM-store its load buffer directlyinstead of loading it to registers and casting.
Motivation
q_nopeis the dominant read in this kernel. When the KV cache is fp8 and theabsorb BMM now emits
ql_nopeas fp8 (companion PRgfx1250-mla-absorb-a16w8-fp8-out+ ROCm/ATOM wiring),q_nopearrives alreadyat the
q_outdtype, so the register round-trip + cast is pure overhead. The oldcode unconditionally allocated the
q_pecast buffer only on the non-matchingpath and cast
q_nopeeven when dtypes matched; this reorganizes the staging sothe matching path is a straight passthrough.
Test Plan
~35 µs → ~30 µs.
rope-cache 34.6 µs → 29.9 µs (−4.7 µs/step).
Accuracy
Bit-identical. On the passthrough path the bytes written are exactly the input
q_nopebytes (no cast); theq_pestaging dtype is unchanged. GSM8K 5-shot(1319 q, FAKE_EPLB=0) unchanged at 0.958.