Repository navigation
[Triton/Gluon] [Perf] [gfx1250] unified attention 3D: tuned split for plain bf16 and fp8 decode - #7743
[Triton/Gluon] [Perf] [gfx1250] unified attention 3D: tuned split for plain bf16 and fp8 decode#7743akao-amd wants to merge 13 commits into
Conversation
…A3D_NHD_CFG Cherry-picked from perf1101 (no upstream PR yet). Co-Authored-By: Claude <[email protected]> (cherry picked from commit 1502c52)
…, head_dim <= 64 The plain (non-shuffled) bf16 KV cache fell to the 'any' entry (waves_per_eu 1). Occupancy 2 cuts the gpt-oss-120b full-attention decode kernel by ~35% in situ; outputs bitwise identical (only the launch's occupancy hint changes). Co-Authored-By: Claude <[email protected]> (cherry picked from commit 37d3490)
…ll to the generic 3D entry)
…ault The env AITER_GFX1250_UA3D_NHD_CFG still overrides it. waves_per_eu 2 alone was the old bf16 entry; the measured config is waves 2, num_stages 3, SEGMENTS_PER_CU 16, MIN_SEGMENTS 4, for bf16 and fp8 q/KV. 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: Reviews: |
The D<=64 entries matched every query length, so short prefill and verify batches that still launch the 3D kernel took the decode tuning. Key them on Q_LEQ_1 with Q after SHUF so shuffled entries still win, and drop the env override so this change is only the retune.
The env override is gone, and this branch does not need the dtype-tag edits that landed on main after it forked.
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 |
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
There was a problem hiding this comment.
🟡 Changes recommended
The tests do not exercise the new MIN_SEGMENTS=4 floor, so a high-program-count case must verify that a budget below four segments is clamped to four.
1 open issue
What changed in this PR
This PR tunes AITER’s gfx1250 Triton unified-attention 3D path for plain decode with head dimensions up to 64.
Changes:
- Adds decode-only bf16/fp8 entries with three pipeline stages, two waves per execution unit, and updated KV split settings.
- Preserves existing selection for shuffled caches, longer queries, and larger head dimensions.
- Adds config-selection tests, including fp16’s shared bf16 mapping.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_unified_attention_config.py |
Adds tests for tuned decode selection and fallback behavior. |
aiter/ops/triton/configs/gfx1250/triton/attention/unified_attention/DEFAULT.json |
Adds query-length matching and tuned attention and KV split entries. |
Review effort: Balanced
| self.assertEqual(_matched("kv_split", params), key) | ||
| attn = self._attn(params) | ||
| self.assertEqual((attn["num_stages"], attn["waves_per_eu"]), (3, 2)) | ||
| self.assertEqual(self._split(params)["NUM_SEGMENTS"], 16) |
…r fp8-KV decode The all-decode rows this PR adds for head dim <= 64 run num_stages 3. Over an fp8 KV cache (DT_bf16_fp8 and DT_fp8_fp8 Q_LEQ_1) num_stages 4 is faster at every context we measured and stores the same bits (num_warps 1, waves_per_eu 2 unchanged); bf16 KV keeps 3. Per call on one MI455X partition (96 CUs), gpt-oss TP2 decode shapes, 2.2 GHz: - bf16 Q: 32k c168 579 -> 513 us, 128k (graph batch 48) 595 -> 555 us, 1M c8 974 -> 871 us - fp8 Q: 32k 585 -> 480 us, 128k 579 -> 538 us, 1M 898 -> 786 us At the 1400 W serving cap, TP2 decode step: -0.37 / -0.39 / -0.28 ms at 32k / 128k / 1M. These are Triton attn_3d rows. The Gluon 3D kernel's num_stages == 2 requirement (ROCm#6730) reads the gluon table and is not affected. Upstream-PR: ROCm#7743 Co-Authored-By: Claude <[email protected]>
|
Refreshed onto current main ( |
…KV decode producer (GQA 8, head 64) Stacked on ROCm#7743 (pr-gfx1250-ua3d-nhd). Carries only the two-KV-head producer and its dispatch. The tuned-split and num_stages commits this branch used to repeat are dropped: ROCm#7743 already has them. Split-KV decode on gfx1250 runs kernel_unified_attention_3d with BLOCK_M 16. With 8 query heads per KV head (gpt-oss), half of every 16-row block is padding. kernel_unified_attention_decode_2h handles two adjacent KV heads per program, so the 16 rows are 8 query heads x 2 KV heads and none are padding. QK multiplies a block-diagonal Q [16, 128] (each row's query in its own head's 64 columns) by both heads' K at once. PV accumulates [16, 128], and each row keeps its own head's half. It writes the same split partials (segm_output / segm_max / segm_expsum) as the 3D kernel, so the same reduce follows and the results are bit-identical to the 3D kernel. Selection: - The producer is picked per call in _select_triton_split_decode, once the split (NUM_SEGMENTS, TILE_SIZE) is fixed and before its scratch is allocated; the 3D launch site calls the chosen launcher. It is a small producer table, so kernel_unified_attention_3d stays the default. - decode_2h_supported() checks only what the kernel computes: all-decode split KV (NUM_SEGMENTS > 1), GQA 8, head 64, page = tile = 64, an even KV-head count, plain NHD fp8 K/V, bf16 or fp8 Q, optional sinks, no window, softcap, alibi, qq_bias or output scale. - An arch opts in by shipping an attn_decode_2h section in its triton DEFAULT.json (has_unified_attention_config). gfx1250 ships one row: num_warps 1, num_stages 3, waves_per_eu 2, at every context length. - AITER_UA_DECODE_2H=0 turns the producer off (read at import, like AITER_UA2D_FUSED_EPILOGUE). Depends on ROCm#7743. Its all-decode split (MIN_SEGMENTS 4) is what gives gpt-oss TP2 4 / 8 / 64 segments at 32k c168 / 128k c44 / 1M c8. Main's split gives 1 / 2 / 16, and one segment never takes this producer. Tests (op_tests/triton_tests/attention/test_unified_attention.py): - exact parity with the 3D producer for 4 and 8 KV heads, bf16 and fp8 Q, sinks on and off, lengths 1/64/65 and two empty trailing slots; - a CUDA graph replay that moves tiles between partial and full; - a gate test on metadata mocks: predicate, table opt-in, kill switch, and the shipped gfx1250 / gfx950 tables. gpt-oss-120b TP2 decode step on one MI455X (1400 W), before the launch table: -2.42 / -1.37 / -3.30 ms at 32k / 128k / 1M; num_stages 3 adds -1.02 / -2.37 ms at 32k / 128k. At 1M, serving also runs faster with 3 stages than with the 4 that per-call sweeps had picked, so the table has one row. To be re-measured on this base for the PR. Co-Authored-By: Claude <[email protected]> Co-authored-by: Cursor <[email protected]>
…KV decode producer (GQA 8, head 64) Stacked on ROCm#7743 (pr-gfx1250-ua3d-nhd). Carries only the two-KV-head producer and its dispatch. The tuned-split and num_stages commits this branch used to repeat are dropped: ROCm#7743 already has them. Split-KV decode on gfx1250 runs kernel_unified_attention_3d with BLOCK_M 16. With 8 query heads per KV head (gpt-oss), half of every 16-row block is padding. kernel_unified_attention_decode_2h handles two adjacent KV heads per program, so the 16 rows are 8 query heads x 2 KV heads and none are padding. QK multiplies a block-diagonal Q [16, 128] (each row's query in its own head's 64 columns) by both heads' K at once. PV accumulates [16, 128], and each row keeps its own head's half. It writes the same split partials (segm_output / segm_max / segm_expsum) as the 3D kernel, so the same reduce follows and the results are bit-identical to the 3D kernel. Selection: - The producer is picked per call in _select_triton_split_decode, once the split (NUM_SEGMENTS, TILE_SIZE) is fixed and before its scratch is allocated; the 3D launch site calls the chosen launcher. It is a small producer table, so kernel_unified_attention_3d stays the default. - decode_2h_supported() checks only what the kernel computes: all-decode split KV (NUM_SEGMENTS > 1), GQA 8, head 64, page = tile = 64, an even KV-head count, plain NHD fp8 K/V, bf16 or fp8 Q, optional sinks, no window, softcap, alibi, qq_bias or output scale. - An arch opts in by shipping an attn_decode_2h section in its triton DEFAULT.json (has_unified_attention_config). gfx1250 ships one row: num_warps 1, num_stages 3, waves_per_eu 2, at every context length. - AITER_UA_DECODE_2H=0 turns the producer off (read at import, like AITER_UA2D_FUSED_EPILOGUE). Depends on ROCm#7743. Its all-decode split (MIN_SEGMENTS 4) is what gives gpt-oss TP2 4 / 8 / 64 segments at 32k c168 / 128k c44 / 1M c8. Main's split gives 1 / 2 / 16, and one segment never takes this producer. Tests (op_tests/triton_tests/attention/test_unified_attention.py): - exact parity with the 3D producer for 4 and 8 KV heads, bf16 and fp8 Q, sinks on and off, lengths 1/64/65 and two empty trailing slots; - a CUDA graph replay that moves tiles between partial and full; - a gate test on metadata mocks: predicate, table opt-in, kill switch, and the shipped gfx1250 / gfx950 tables. gpt-oss-120b TP2 decode step on one MI455X (1400 W), before the launch table: -2.42 / -1.37 / -3.30 ms at 32k / 128k / 1M; num_stages 3 adds -1.02 / -2.37 ms at 32k / 128k. At 1M, serving also runs faster with 3 stages than with the 4 that per-call sweeps had picked, so the table has one row. To be re-measured on this base for the PR. Co-Authored-By: Claude <[email protected]> Co-authored-by: Cursor <[email protected]>

Summary
Add gfx1250 Triton
kv_splitandattn_3drows for plain decode with head dimension <=64. The split budget is 16 segments per CU, with a minimum of four capped by the available KV tiles. The 3D rows use one warp, two waves per EU and three stages for BF16 KV or four for FP8 KV. FP16 shares the BF16 dtype tag.Root of #7743 -> #8883 -> #8884 -> #8885. The production change is configuration only; descendants add the paired producer, grid order and address hoisting.
Motivation and changes
Long-context decode needs more parallel work than the generic split budget supplies. Append
Qto the gfx1250attn_3d/kv_splitschema and add fourD_LEQ_64.DT_{bf16,fp8}_{bf16,fp8}.Q_LEQ_1rows. Existing shuffled, larger-head and longer-query rows retain precedence; reduce and Gluon tables keep their previous selection.At 96 CUs and four KV heads per partition:
Lengths 1/64 cap the split count at one; 65/128 cap it at two. The four-stage FP8-KV row belongs to the generic 3D producer. #8883 independently uses three stages.
At the measured gpt-oss TP1/TP2 serving batches, every full-attention decode call has more than one segment and takes #8883's producer; sliding-window layers use the 2D kernel. These 3D changes act with
AITER_UA_DECODE_2H=0, one-segment calls or other supported shapes, and were inactive in the default base1130_v3 serving measurements. Thekv_splitrows remain active and determine #8883's split counts.Performance
Earlier measurement (not re-run on this head): gpt-oss-120b TP2 on one MI455X (two 96-CU partitions), 1400 W, FP8 KV page 64 and FP8 decode Q, image
rocm/sgl-dev:v0.5.23-rocm101-mi45x-20261127, Tritond436c49e2f,bench_one_batch. Arms used the same build, fresh servers and bracketing measurements.The latter two include the paired producer's effect. Performance, including the generic 3D FP8-KV stages 3/4 choice, has not been re-measured on this head.
The base1130_v3 stack (MI450 gpt-oss measurements, December 1, 2026) carried this change as
26dcb37a4andac05876b8; the production JSON edits are identical. This pass strengthens CPU tests and integrates current main. V1/v3 contain the change in both A/B arms, so that comparison does not measure this PR alone. The older whole-stack greedy-identical claim is not current validation: base1130_v3 contains a separate dense-FP8 numerical change, and serving accuracy has not been checked on this head.Testing
GPU setup: MI455X (gfx1250) 96-CU partition, image
rocm/sgl-dev:v1.0.0-rocm101-mi45x-20261202, torch 2.12.0+rocm10.1.0, Triton 3.9.0.python -m pytest -q op_tests/triton_tests/attention/test_unified_attention_config.py: 8 passed, HIP 2,CU_NUM=96.89f173f53102a7b0a8984d7cc125b9337f2ab3d8, whose production JSON is identical,python -m pytest -q op_tests/triton_tests/attention/test_unified_attention.py -k "gfx1250 or decode": 495 passed / 96 skipped on both head and mainecfa616d80a17b4030feccb18da47df59dbca720, HIP 2. No new failures in that selection.MIN_SEGMENTSfails all four dtype checks at 384 sequences × four KV heads on 96 CUs.Other GPU architectures, unfiltered attention and current serving performance/accuracy remain unverified.
Documentation and dependencies
The config test documents standalone CPU invocation with a scoped architecture stub during imports. No new dependencies or public API signature changes. This root merges main
ecfa616d8; descendants are rebased onto it. Independent of #7744/#7745/#7746.PR Self-Review
Reviewed revision
4f3b711a29e139cb9e1443c6b7e9e417f1fa0e2dBehavior and intent
The four plain-decode rows increase split work and fix the generic 3D launch settings. Split/reduction scheduling changes relative to main; the regression comparison establishes no new failures in the tested selection.
Validation and unverified scope
Current config tests passed eight cases on CPU and GPU. The identical-production snapshot and pinned main each passed 495 attention cases with 96 skips. Current performance, stage optimality, serving accuracy and other architectures remain unverified.
PR-specific question
Consumers are
D_LEQ_64.DT_{bf16,fp8}_{bf16,fp8}.Q_LEQ_1in gfx1250 Tritonkv_splitandattn_3d. Config tests pin unchanged selection for shuffled KV, larger heads and longer queries, and distinguish literal c44 from graph48.Changed op tests
test_unified_attention_config.pypins selected keys, launch values, the high-program-count minimum, short-context caps and TP2 split counts. Numerical attention tests do not identify row selection; the previous budget-only check would pass withMIN_SEGMENTSremoved.