Repository navigation
[Triton/Gluon] [Bugfix] gfx1250 unified attention 2D: store decode outputs from registers - #7203
Conversation
…rs (gpt-oss shapes) For all-decode calls with gpt-oss's shapes (head 64, 8 queries per kv head, page 64, bf16 out) the 2D kernel stores its output with plain global stores from registers instead of staging it in LDS for tensor_store_from_lds, whose LDS read can miss the wave's ds_stores on gfx1250. Extend keeps the TDM store: the register path is not deterministic there at TP1 heads (open). CDNA4 buffer_store is not used on gfx1250. Serving (gpt-oss-120b base1028, in-graph attention pair counters, 8k/1k and 1k/1k at c16 and c64): sliding-window decode corrupted served rows TP1 472-535 per run before, 0 after (2 runs); TP2 4-7 before, 0 after. Extend unchanged (rare). GSM8K TP2 0.9583, TP1 see report. Co-Authored-By: Claude <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
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: |
There was a problem hiding this comment.
🟡 Changes recommended
The newly selected register path can overflow output offsets and write out of bounds for large-stride bf16 outputs, and the affected all-decode sliding-window branch lacks test coverage.
2 open issues
What changed in this PR
This PR updates gfx1250 unified attention dispatch to avoid stale output from LDS-staged TDM stores for specific gpt-oss decode shapes.
Changes:
- Enables the existing register-store path for all-decode calls with 64-element query/value heads, eight queries per KV head, 64-token pages, and bf16 output.
- Uses plain global stores rather than buffer stores for those calls.
- Leaves extend calls and other shapes on the existing TDM-store path.
| File | Description |
|---|---|
aiter/ops/triton/attention/unified_attention.py |
Adds the decode-shape gate and selects the existing register-store path. |
Review effort: Balanced
|
@akao-amd What is the Triton compiler version you are using? Can you provide a repro? I think this is more like a bug issue report rather than a PR simply to bypass it. |
…store epilogue The register store computed token index * output_stride_0 in int32. With a strided output (3 x 64 x 64 bf16, strides 2**30, 64, 1) row 2 wrapped and the store faulted (illegal memory access). Use an int64 row start, as the TDM store already does. Co-Authored-By: Claude <[email protected]>
…inst the reference and graph replays gpt-oss decode shapes (head 64, 8 query heads per KV head, page 64, bf16 out, sliding window 128) take the register-store epilogue. Check the output against ref_paged_attn and 32 CUDA graph replays bitwise against the eager call. Co-Authored-By: Claude <[email protected]>
|
@k50112113 Thanks for the review. Versions: validated with Triton Repro: |
|
The 10-30 Aiter Test Gate failure was an MI35X shard ("Standard Tests (1 GPU)") that timed out at 90 min; it does not run the changed gfx1250 path. The new head will run CI again. Could a maintainer add |
|
@k50112113 Following up on your question. Versions and the repro are in the comment above. The script is https://gist.github.com/akao-amd/bae984dabc2c1a38d756318ef784abcf ( @ROCm/team_aiter @ROCm/triton_kernels_team Could a maintainer add The red Aiter Test is shard 4 hitting the 90-minute limit in |
|
@azaidy Tagging you as a Gluon owner for the gfx1250 Gluon unified attention 2D decode register-store change in this PR. The open question from k50112113 is in the thread above. |
|
@k50112113 Filed as #7512. Re-ran the gist today, unedited (
The 11-03 clean run was a different MI450X. On this GPU the 20261102 image still shows the race on main, and the register store is clean. I would keep this PR open as the mitigation. The issue has the firmware block and the 10-30 numbers. The 10-30 writeup says window 127. Today's runs, the gist, and |
|
Latest upstream triton (commit
I pulled AITER main to test your repro_7203_tdm_store.py |
|
@k50112113 I reran the gist with Triton Setup: the gist
Eager warm-up was 0 in every run, so all the mismatches are CUDA-graph replays. This PR's head ( So Prior point, 2026-11-05, ctmocha-aris-e21-13 GPU 6, AITER main
Today's image differs from 11-05. Its Triton is plain The internal Triton ticket on this TDM-store behavior (triton-tickets#2164) measured the register-store fix on |
Drop the decode-shape gate that rejected configs without USE_TDM_STORE=false. The gpt-oss entries already set the flag, so the config alone selects the register-store epilogue. Other shapes keep TDM stores unless their config says otherwise. Update the gate test to check the flag per config entry, and remove the unflagged-leaf rejection test.
k50112113
left a comment
There was a problem hiding this comment.
LGTM, please resolve conflicts and we'll let CI run
# Conflicts: # aiter/ops/triton/attention/unified_attention.py # aiter/ops/triton/utils/unified_attention_utils.py # op_tests/triton_tests/attention/test_unified_attention.py
|
Please fix the black and ruff formatting required by the CI thanks |
# Conflicts: # aiter/ops/triton/attention/unified_attention.py # op_tests/triton_tests/attention/test_unified_attention.py
…tputs from registers (#7203) * gfx1250 gluon unified attention 2D: store decode outputs from registers (gpt-oss shapes) For all-decode calls with gpt-oss's shapes (head 64, 8 queries per kv head, page 64, bf16 out) the 2D kernel stores its output with plain global stores from registers instead of staging it in LDS for tensor_store_from_lds, whose LDS read can miss the wave's ds_stores on gfx1250. Extend keeps the TDM store: the register path is not deterministic there at TP1 heads (open). CDNA4 buffer_store is not used on gfx1250. Serving (gpt-oss-120b base1028, in-graph attention pair counters, 8k/1k and 1k/1k at c16 and c64): sliding-window decode corrupted served rows TP1 472-535 per run before, 0 after (2 runs); TP2 4-7 before, 0 after. Extend unchanged (rare). GSM8K TP2 0.9583, TP1 see report. * gfx1250 gluon unified attention 2D: int64 row offset in the register-store epilogue The register store computed token index * output_stride_0 in int32. With a strided output (3 x 64 x 64 bf16, strides 2**30, 64, 1) row 2 wrapped and the store faulted (illegal memory access). Use an int64 row start, as the TDM store already does. * op_tests: gfx1250 unified attention 2D: all-decode register store against the reference and graph replays gpt-oss decode shapes (head 64, 8 query heads per KV head, page 64, bf16 out, sliding window 128) take the register-store epilogue. Check the output against ref_paged_attn and 32 CUDA graph replays bitwise against the eager call. * gfx1250 UA2D: enforce safe register-store gate * gfx1250 UA2D: use the USE_TDM_STORE config flag as the only switch Drop the decode-shape gate that rejected configs without USE_TDM_STORE=false. The gpt-oss entries already set the flag, so the config alone selects the register-store epilogue. Other shapes keep TDM stores unless their config says otherwise. Update the gate test to check the flag per config entry, and remove the unflagged-leaf rejection test. * op_tests: fix black and ruff formatting in unified attention tests --------- Co-authored-by: akao-amd <[email protected]> Co-authored-by: Shao-Chun Lee <[email protected]>


Summary
For all-decode calls with gpt-oss's shapes,
_unified_attention_2d_gfx1250launches the 2D Gluon kernel withUSE_TDM_STORE=Falseand plaingl.store(not the CDNA4buffer_store). The LDS-staged TDM store of the output can write stale LDS on gfx1250, which silently corrupts served attention rows.Motivation
The kernel stages its output tile in LDS (
ds_store_b128), waitss_wait_dscnt 0and writes it withtensor_store_from_lds. Under load the TDM store sometimes writes what that LDS held before. The same defect, with the same epilogue, is fixed for the a8w4 MoE decode kernel in a companion PR (gfx1250 a8w4 MoE decode: store the output tile from registers). Here the wrong values are plausible (about 32 elements of one token's output off by up to 68, never NaN/Inf), so nothing downstream flags them.Context (the same paragraph in the three companion gfx1250 PRs). Three defects and a compiler bug hit gpt-oss-120b on gfx1250 together and hid one another. (1) The TDM store of an LDS-staged output tile can ship stale LDS: the a8w4 MoE decode and unified attention 2D register-store PRs. The rule for when a TDM store may read LDS written by
ds_storeneeds an answer from the LLVM AMDGPU / hardware side. (2) The Gluon 2D attention turns one NaN in a KV page tail into NaN for every query that reads the page: the V-masking PR. (3) LLVM placed the workgroup release'ss_wait_dscnt 0afters_barrier_signalat the top of a loop. That made attention extend non-deterministic and looked like (1). It is fixed by llvm/llvm-project#220357, which is in Triton main's LLVM and known to the compiler team (ROCm/rocm-libraries#10893). In serving, (1) in the MoE made one token's row NaN and (2) spread it to the whole batch. GSM8K failed only at TP2 and only after load. At TP1 the same race stayed finite and passed every gate. Related gfx1250 TDM/LDS ordering reports: #5712 (a TDM load racing ads_readof the slot it overwrites), #4537 (TDM ring wait counts), the note in #4894's gfx1250 quant kernel ("fp8 TDM async_store corrupted data in tiles wider than 1024"), and LLVM941a04e69ee8(keep the TDM counter low), which lowers (1)'s rate to ~0.6x but not to 0. Other gfx1250 users of the Gluon MoE decode kernel may be exposed to (1): vLLM's gpt-oss Gluon MoE path (ROCm/vllm#1327) and ATOM's FlyDSL-prefill + Gluon-decode split.Changes
_unified_attention_2d_gfx1250:REGISTER_STOREwhen head size 64 (q and v), 8 queries per kv head, page 64, bf16 output and the call is all-decode; thenUSE_TDM_STORE=FalseandUSE_STORE_BUFFER_OP=False. The kernel's existing register-store path is used; no kernel change.buffer_storeis not used: a gfx1250 GPU hung while AITER's attention tests ran on a variant that used it (cause not established).Performance
Test
gfx1250 only (the launcher path is gfx1250-only).
Extend rows remained (unchanged path, see above). Full-attention decode runs the 3D kernel (no TDM store): 0 in ~5.3M calls before and after.
Validated on the AITER tree of a gpt-oss gfx1250 recipe (base 2bb5491, with #6999) and the image's Triton (76940ad + revert); this commit is the same change on main. Not run: AITER's attention op tests on gfx1250, shapes other than gpt-oss's, end-to-end speed. The code comment says extend's register path "is not deterministic"; the cause was found later (compiler bug (3)).
MI355X (gfx950), 2026-11-05, image
rocm/sgl-dev:v0.5.23-rocm10-mi35x-20261102, ROCm 10.0.0.pytest op_tests/triton_tests/attention/test_unified_attention.pyat this head against merge-baseddb5085d31e2: 2500 passed, 0 failed. The 2 newtest_gfx1250_gluon_ua2d_decode_register_storecases skip with "gfx1250 Gluon 2D kernel only, not gfx950". No outcome change on the other cases. The launcher edit is inside_unified_attention_2d_gfx1250, which runs only whenDEVICE_ARCH == "gfx1250". CI shard 4 is the same 26 files as the green #7202 run (79.4 min against a 90 min cap). The cap fired intest_mha_varlen_large_kv.pyandtest_gemm_a8w8_blockscale_cktile_aq_rowmajor.py. On this box, after their one-time JIT, those two files take 42 s and 4 s on this head and on main.PR Self-Review
Reviewed revision
db9c253a72d89184525afdc81d670b043d08e0b9Behavior and intent
_unified_attention_2d_gfx1250stages the output tile in LDS (ds_store_b128), waitss_wait_dscnt 0, and writes it withtensor_store_from_lds. On gfx1250 that store sometimes writes what the LDS held before. The values are plausible, about 32 elements of one token off by up to 68, never NaN or Inf, so GSM8K does not see them. The same epilogue on the a8w4 MoE decode kernel is #7202.For gpt-oss decode the launcher now takes the kernel's existing register-store path:
USE_TDM_STORE=FalseandUSE_STORE_BUFFER_OP=False(plaingl.store, not the CDNA4buffer_store). The register-store row offset is int64, matching the TDM store, so a large output stride does not wrap. The gate is head size 64 for Q and V, 8 queries per KV head, page 64, bf16 output, andall_decode.Validation and unverified scope
gfx1250 only (MI450X, DPX partition). The launcher path is gfx1250-only. Recipe AITER
2bb549102plus #6999, Triton76940adplus its revert. This commit is that change on main.Offline, sliding window 127, the same inputs 64 times per CUDA graph, bitwise against eager. Before: 28,020 differing elements per million calls at 64 q / 8 kv heads and 64 requests, 22,700 at 128 requests; 488–6,300 per million with 32 / 4 heads. After: 0 in 640k calls at 64 requests (both head layouts), 0 in 320k at 128. One call is bitwise equal to the TDM-store path. Same-minute alternating kernel times: 0.981–1.000× the TDM store.
Serving, gpt-oss-120b, SGLang, every attention call recomputed in the graph and compared with the served output, 8k/1k and 1k/1k at c16 and c64. Corrupted sliding-window decode rows: TP2 4–7 per run to 0 of 1.74M calls (GSM8K 0.9583); TP1 GPU 6, 472–535 to 0 of 0.84M (GSM8K 0.9613); TP1 GPU 7, 472–535 to 0 of 0.83M (GSM8K 0.9568). Extend rows remained, on the unchanged path. Full-attention decode runs the 3D kernel, which has no TDM store: 0 in about 5.3M calls before and after.
Not run: AITER's attention op tests on gfx1250, shapes outside the gate, an end-to-end speed bracket.
PR-specific question
The boundary is the host predicate. A call that misses one conjunct keeps
USE_TDM_STORE=Trueand can still ship stale LDS. Extend is excluded on purpose, not because the race is absent there. With the register path, extend at 64 / 8 heads was non-deterministic: LLVM placed the workgroup release'ss_wait_dscnt 0afters_barrier_signalat the top of the loop (llvm/llvm-project#220357). Letting extend through before the Triton in use has that fix reintroduces that failure, which looks like this store race and is not. The serving counters are the check that the gate holds: sliding-window decode rows go to 0, and extend rows stay on the old path.USE_STORE_BUFFER_OPis forced false inside the gate. A gfx1250 GPU hung while AITER's attention tests ran on a variant that used the CDNA4buffer_store. The cause was not established, so the gated path uses plaingl.store.One eager call matching the TDM-store path bitwise is the check that the register path writes the same tile when the race does not fire. The replay counts (640k / 320k offline, and the serving counters above) are the check that it no longer fires under load. Full-attention decode never enters this kernel.
Changed op tests
op_tests/triton_tests/attention/test_unified_attention.py—test_gfx1250_gluon_ua2d_decode_register_store. gpt-oss all-decode shapes (head 64, 8 query heads per KV head, page 64, bf16 out) take the register-store epilogue. The test checks the output against the paged reference and compares CUDA-graph replays bitwise with the eager call. It does not run off gfx1250.🤖 Generated with Claude Code