Skip to content

[Triton/Gluon] [gfx1250] fused_kv_cache: fp8 q_nope passthrough - #6239

Closed
karverma-amd wants to merge 2 commits into
ROCm:mainfrom
karverma-amd:karverma-amd/gfx1250-rope-cache-fp8-passthrough
Closed

karverma-amd wants to merge 2 commits into
ROCm:mainfrom
karverma-amd:karverma-amd/gfx1250-rope-cache-fp8-passthrough

Conversation

@karverma-amd

Copy link
Copy Markdown
Contributor

Summary

In the fused qk-rope + concat + cache MLA kernel
(_fused_qk_rope_cat_and_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
(Q_OUT_MATCHES, e.g. pre-quantized fp8) TDM-store its load buffer directly
instead of loading it to registers and casting.

Motivation

q_nope is the dominant read in this kernel. When the KV cache is fp8 and the
absorb BMM now emits ql_nope as fp8 (companion PR
gfx1250-mla-absorb-a16w8-fp8-out + ROCm/ATOM wiring), q_nope arrives already
at the q_out dtype, so the register round-trip + cast is pure overhead. The old
code unconditionally allocated the q_pe cast buffer only on the non-matching
path and cast q_nope even when dtypes matched; this reorganizes the staging so
the matching path is a straight passthrough.

Test Plan

  • Standalone kernel bench at the decode shape (per-rank ~1536 tokens):
    ~35 µs → ~30 µs.
  • In-engine DSR1 1k4k conc6144 bs1536 (TP4/DP4/EP4) decode trace:
    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_nope bytes (no cast); the q_pe staging dtype is unchanged. GSM8K 5-shot
(1319 q, FAKE_EPLB=0) unchanged at 0.958.

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.
@karverma-amd
karverma-amd requested a review from a team October 8, 2026 00:28
@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
multigpu 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 6239 --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 [gfx1250] fused_kv_cache: fp8 q_nope passthrough [Triton/Gluon] [gfx1250] fused_kv_cache: fp8 q_nope passthrough Oct 8, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 8, 2026 01:33

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

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_nope without 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.

Comment on lines +464 to +466
qpe_smem_out = gl.allocate_shared_memory(
q_out_ptr.dtype.element_ty, [BLOCK_D_pe], SH
)
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
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: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
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 6239 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 13, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 395aeababddd · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/triton_tests/fusions/test_fused_kv_cache.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

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]>
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