Repository navigation
[Triton/Gluon] KDA cleanup - #7034
Conversation
🏷️ 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
An unused BF16 output-state buffer can incorrectly reject a valid output-only call.
1 open issue
What changed in this PR
This PR updates recurrent KDA dispatch to select configurations for BF16 resident state earlier, improves validation messages, and simplifies the KDA test suites.
Changes:
- Align configuration selection with BF16 resident-state requirements and reject conflicting overrides.
- Add descriptive state-dtype assertions and targeted guard checks.
- Consolidate BF16 test skips and reduce test cases.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_kda.py |
Consolidates dtype skips, updates guard checks, and reduces test coverage cases. |
op_tests/triton_tests/attention/test_chunk_kda.py |
Consolidates dtype skips and trims sequence cases. |
aiter/ops/triton/attention/kda.py |
Moves BF16 dispatch selection earlier and improves state validation. |
Review effort: Balanced
c0ff7cf to
45113b9
Compare
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
45113b9 to
a1acb89
Compare
Conflicts in op_tests/triton_tests/attention/test_kda.py: #7034 gave test_fused_conv_rms_gate_spec and test_fused_recurrent_kda_packed_decode the shared STATE_DTYPES list and dropped their seed parameter. Both changes are kept, together with this branch's conv1d_layout and padded_weight parameters. Signed-off-by: Rony Leppänen <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Conflict in aiter/ops/triton/attention/kda.py: keep the bf16 resident-state assert of main (ROCm#7034) and put the resident_state guard of the gate fold after it.

Motivation
Addressed the follow copilot comments & cleanup of some unit tests:
MINOR — the forced resident_state runs with a config bucket picked for the other pathget_kda_config picks its bucket from avg_T > 1 (kda_decode.py:576), and the defaultresident_state uses the same test (kda.py:208). Setting resident_state = True atkda.py:307 after the lookup breaks that link: your own benched row "Fused decode 64 / 1" gets bucket "fused" (num_warps 4, num_buffers 8) while running the resident path, which"fused_t_gt1" tunes at num_warps 8. bench_kda.py:55 always passes cu_seqlens, so that row is varlen with T = 64 and avg_T = 1. Suggested fix: decide the BF16 condition before line 196 and pass it into get_kda_config, or add a BF16 bucket to configs/gfx950/gluon/attention/kda_decode/DEFAULT.json.
MINOR — the forced value silently beats an explicit config={"resident_state": False}Line 208 honours a caller override, line 307 replaces it with no warning. Suggested fix: assert when a caller asks for False with BF16 and T > 1, instead of overriding in silence.
MINOR — the new dtype assert has no messageassert initial_state.dtype in state_dtypes (kda.py:249) andassert final_state.dtype in state_dtypes (kda.py:271) print a bare AssertionError. The matching guard in chunk_kda.py:242 has a good message. Because of that,test_state_dtype_guards has to use a bare pytest.raises(AssertionError), which any assertion in the function satisfies. Suggested fix: add , f"state dtype must be one of {state_dtypes} on {_ARCH}" to both, then give the first pytest.raises a match=.
PR Self-Review
Reviewed revision
a1acb89
Behavior and intent
On gfx950, a bf16 state with T > 1 now selects the resident-state config before
get_kda_configruns (bucket_T = max(avg_T, 2)). Before, the wrapper silently forcedresident_state = Trueafter config selection, so a tuned T = 1 bucket could run with the wrong setting and a user override ofresident_state=Falsewas ignored. Now a conflicting override fails with "bf16 state with T > 1 needs resident_state". The state dtype comes frominitial_state, or fromstate_outonly whenstate_outreceives the final state. An unused bf16state_outwith an fp32 scratch therefore does not select the bf16 path (Copilot finding). The dtype asserts now give a message.Validation and unverified scope
gfx950 (MI355X), GPU 0, triton 3.8.0, rebased on main:
pytest op_tests/triton_tests/attention/test_kda.py op_tests/triton_tests/attention/test_chunk_kda.py-> 134 passed, 205 skipped. The skips are gfx1250-only cases (cache_state_updatesand gfx1250 features).The new unused-
state_outcheck failed with "needs resident_state" before the fix and passed after it.Not tested: gfx1250. The gfx1250 path is not changed (bf16 state is gfx950 only), but I did not run the suite on gfx1250. No performance run, because kernels and configs are not changed.
PR-specific question
test_state_dtype_guardsfails before this PR on two checks: a bf16 state with an override ofresident_state=Falsewas accepted silently, and an output-only call with an unused bf16state_outand noinitial_statewas rejected. No other test passes a config override with a bf16 state, so no other test sees these cases.Changed op tests
op_tests/triton_tests/attention/test_kda.py:test_state_dtype_guardsadds the two checks above and matches the new assert messages. A sharedSTATE_DTYPES/bf16_state_onlymarker replaces the copied in-body bf16 skips. Removed duplicates: theallow_neg_eigvalandBV*SKguard checks are also intest_guards. The fp32 variants oftest_varlen_state_precision_with_short_sequences,test_no_final_stateandtest_paged_state_outare covered by the other fp32 tests. The extra seed parametrizations repeat the same paths with other random data.test_paged_state_restore_stridedis removed: [confirm: which test now covers bf16 spec restore with a hybrid-page stride on the decode path?test_fused_recurrent_vllm_decodecovers bf16 spec restore, andtest_chunk_kda_paged[padded]covers the stride, but only on the chunk path.]op_tests/triton_tests/attention/test_chunk_kda.py: the sameSTATE_DTYPESmarker replaces the in-body skips. Removed seqlens:[300]and[4096]repeat the multi-chunk path that[1000]covers, and[5, 0, 70]intest_chunk_kda_metadatarepeats the zero-length case of[0, 64, 0, 0, 129, 1]and is still intest_chunk_kda. [confirm these reasons match yours]Test Plan & result
Unit tests all pass, no perf regression
Submission Checklist