Skip to content

feat(gfx950): config-gated BLOCK_Q fp8_mqa_logits for DSA indexer prefill - #4180

Open
YukioZzz wants to merge 1 commit into
ROCm:mainfrom
YukioZzz:feat/gfx950-fp8-mqa-logits-blockq2
Open

YukioZzz wants to merge 1 commit into
ROCm:mainfrom
YukioZzz:feat/gfx950-fp8-mqa-logits-blockq2

Conversation

@YukioZzz

Copy link
Copy Markdown
Contributor

Motivation

Add a BLOCK_Q Gluon specialization of fp8_mqa_logits for the gfx950 (CDNA4) DSA / lightning-indexer prefill shape (short query x long KV) under context-parallel ragged ranges, as used by GLM-5.x / DeepSeek-V3.2 sparse attention. It shares one double-buffered KV tile across 2 adjacent query rows, reusing the existing gfx950 building blocks (MQAAsyncKVLoader / _mqa_dot / _weighted_sum_fma_fold / _load / _store), so the MFMA layout and head reduction match the stock single-row path. General ragged (reads real cu_start/cu_end), handles an odd tail row, writes only the valid [start,end) span (clean_logits=False).

Technical Details

fp8_mqa_logits() dispatches via a tuned config table keyed by (num_heads, head_dim); unsupported shapes fall back to the stock row-per-program kernel. Design note vs DeepGEMM/TileLang: those fix UMMA_N=128 (BLOCK_Q=128/num_heads) since the accumulator lives in Tensor Memory; on gfx950 the MFMA accumulator is in registers, so the fill target is one MFMA M-tile (32) and KV-share / BLOCK_KV / waves_per_eu are separate occupancy knobs - over-packing rows loses here.

Test Plan

Test Result

Validated on MI355X (Q=6156,K=49243,CP ke=1+row*8), median vs stock, all max_abs<=3e-5: (32,128) 1.35x, (16,128) 1.45x, (8,128) 1.48x, (32,64) 1.23x, (16,64) 1.33x. num_heads==64 spans 2 M-tiles (register pressure) and loses (0.92x), so it is excluded and falls back. E2E validated through the top-level fp8_mqa_logits.

Submission Checklist

…fill

Add a BLOCK_Q Gluon specialization of fp8_mqa_logits for the gfx950 (CDNA4) DSA / lightning-indexer prefill shape (short query x long KV) under context-parallel ragged ranges, as used by GLM-5.x / DeepSeek-V3.2 sparse attention. It shares one double-buffered KV tile across 2 adjacent query rows, reusing the existing gfx950 building blocks (MQAAsyncKVLoader / _mqa_dot / _weighted_sum_fma_fold / _load / _store), so the MFMA layout and head reduction match the stock single-row path. General ragged (reads real cu_start/cu_end), handles an odd tail row, writes only the valid [start,end) span (clean_logits=False).

fp8_mqa_logits() dispatches via a tuned config table keyed by (num_heads, head_dim); unsupported shapes fall back to the stock row-per-program kernel. Design note vs DeepGEMM/TileLang: those fix UMMA_N=128 (BLOCK_Q=128/num_heads) since the accumulator lives in Tensor Memory; on gfx950 the MFMA accumulator is in registers, so the fill target is one MFMA M-tile (32) and KV-share / BLOCK_KV / waves_per_eu are separate occupancy knobs - over-packing rows loses here.

Validated on MI355X (Q=6156,K=49243,CP ke=1+row*8), median vs stock, all max_abs<=3e-5: (32,128) 1.35x, (16,128) 1.45x, (8,128) 1.48x, (32,64) 1.23x, (16,64) 1.33x. num_heads==64 spans 2 M-tiles (register pressure) and loses (0.92x), so it is excluded and falls back. E2E validated through the top-level fp8_mqa_logits.
@YukioZzz
YukioZzz requested a review from a team July 10, 2026 07:02
@github-actions

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:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
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 4180 --add-label <label>

@zufayu
zufayu requested a review from yzhou103 July 13, 2026 01:37
@zufayu
zufayu removed the request for review from yzhou103 July 21, 2026 02:40
@zufayu
zufayu requested a review from vgokhale August 5, 2026 02:48
@azaidy
azaidy requested review from cagrikymk and k50112113 August 24, 2026 21:08
@cagrikymk

Copy link
Copy Markdown
Contributor

@YukioZzz Can you do a head-to-head comparison against the main aiter? The existing kernel has similar idea so I would like to see how it compares.

If you notice there are cases main is not performing, I think it is better to fix the existing kernel instead of creating a specific one unless it is structurally very different.

@cagrikymk

Copy link
Copy Markdown
Contributor

For example, the following patch seems to resolve the gap in a cleaner way:

diff --git a/aiter/ops/triton/attention/fp8_mqa_logits.py b/aiter/ops/triton/attention/fp8_mqa_logits.py
index 8d33e29e4..fadf823e2 100644
--- a/aiter/ops/triton/attention/fp8_mqa_logits.py
+++ b/aiter/ops/triton/attention/fp8_mqa_logits.py
@@ -205,6 +205,17 @@ def fp8_mqa_logits(
             block_kv = 64 if num_heads <= 32 else 32
             block_m = 2 if (num_heads <= 32 and seq_len > 4096) else 1
             mfma_nonk_dim = 32 if (head_size <= 64 or num_heads == 32) else 16
+
+            # A 128-wide KV tile with 4 warps on the 32x32x64 MFMA amortizes the
+            # async-copy -> LDS round trip far better than the narrow tiles above.
+            if num_heads > 32 or (head_size > 64 and seq_len_kv >= 32768):
+                block_kv = 128
+                num_warps = 4
+                waves_per_eu = 3
+                mfma_nonk_dim = 32
             other = {
                 "USE_PADDED_SHARED_LAYOUT": ASYNC_COPY_SUPPORTS_DISTRIBUTED,
                 "BLOCK_M": block_m,

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants