Skip to content

[Triton/Gluon] KDA cleanup - #7034

Merged
azaidy merged 2 commits into
mainfrom
omuhamma/kda-bf16-state-cleanup
Nov 5, 2026
Merged

azaidy merged 2 commits into
mainfrom
omuhamma/kda-bf16-state-cleanup

Conversation

@omuhamma

@omuhamma omuhamma commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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_config runs (bucket_T = max(avg_T, 2)). Before, the wrapper silently forced resident_state = True after config selection, so a tuned T = 1 bucket could run with the wrong setting and a user override of resident_state=False was ignored. Now a conflicting override fails with "bf16 state with T > 1 needs resident_state". The state dtype comes from initial_state, or from state_out only when state_out receives the final state. An unused bf16 state_out with 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_updates and gfx1250 features).
The new unused-state_out check 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_guards fails before this PR on two checks: a bf16 state with an override of resident_state=False was accepted silently, and an output-only call with an unused bf16 state_out and no initial_state was 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_guards adds the two checks above and matches the new assert messages. A shared STATE_DTYPES / bf16_state_only marker replaces the copied in-body bf16 skips. Removed duplicates: the allow_neg_eigval and BV*SK guard checks are also in test_guards. The fp32 variants of test_varlen_state_precision_with_short_sequences, test_no_final_state and test_paged_state_out are covered by the other fp32 tests. The extra seed parametrizations repeat the same paths with other random data. test_paged_state_restore_strided is removed: [confirm: which test now covers bf16 spec restore with a hybrid-page stride on the decode path? test_fused_recurrent_vllm_decode covers bf16 spec restore, and test_chunk_kda_paged[padded] covers the stride, but only on the chunk path.]
  • op_tests/triton_tests/attention/test_chunk_kda.py: the same STATE_DTYPES marker replaces the in-body skips. Removed seqlens: [300] and [4096] repeat the multi-chunk path that [1000] covers, and [5, 0, 70] in test_chunk_kda_metadata repeats the zero-length case of [0, 64, 0, 0, 129, 1] and is still in test_chunk_kda. [confirm these reasons match yours]

Test Plan & result

Unit tests all pass, no perf regression

Submission Checklist

@omuhamma
omuhamma requested a review from a team October 27, 2026 14:57
@omuhamma omuhamma self-assigned this Oct 27, 2026
@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: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 gfx1201 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 7034 --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 KDA cleanup [Triton/Gluon] KDA cleanup Oct 27, 2026
@azaidy
azaidy self-requested a review October 27, 2026 15:17
@Boss2002n
Boss2002n requested a balanced review from Copilot October 27, 2026 17: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

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

Comment thread aiter/ops/triton/attention/kda.py Resolved
@omuhamma
omuhamma force-pushed the omuhamma/kda-bf16-state-cleanup branch from c0ff7cf to 45113b9 Compare October 29, 2026 14:46
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision a1acb89d9c2e · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

On gfx950, a bf16 state with T > 1 now selects the resident-state config before `get_kda_config` runs (`bucket_T = max(avg_T, 2)`). Before, the wrapper silently forced `resident_state = True` after config selection, so a tuned T = 1 bucket could run with the wrong setting and a user override of `resident_state=False` was ignored. Now a conflicting override fails with "bf16 state with T > 1 needs resident_state". The state dtype comes from `initial_state`, or from `state_out` only when `state_out` receives the final state. An unused bf16 `state_out` with 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_updates` and gfx1250 features).
The new unused-`state_out` check 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_guards` fails before this PR on two checks: a bf16 state with an override of `resident_state=False` was accepted silently, and an output-only call with an unused bf16 `state_out` and no `initial_state` was 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_guards` adds the two checks above and matches the new assert messages. A shared `STATE_DTYPES` / `bf16_state_only` marker replaces the copied in-body bf16 skips. Removed duplicates: the `allow_neg_eigval` and `BV*SK` guard checks are also in `test_guards`. The fp32 variants of `test_varlen_state_precision_with_short_sequences`, `test_no_final_state` and `test_paged_state_out` are covered by the other fp32 tests. The extra seed parametrizations repeat the same paths with other random data. `test_paged_state_restore_strided` is removed: **[confirm: which test now covers bf16 spec restore with a hybrid-page stride on the decode path? `test_fused_recurrent_vllm_decode` covers bf16 spec restore, and `test_chunk_kda_paged[padded]` covers the stride, but only on the chunk path.]**
- `op_tests/triton_tests/attention/test_chunk_kda.py`: the same `STATE_DTYPES` marker replaces the in-body skips. Removed seqlens: `[300]` and `[4096]` repeat the multi-chunk path that `[1000]` covers, and `[5, 0, 70]` in `test_chunk_kda_metadata` repeats the zero-length case of `[0, 64, 0, 0, 129, 1]` and is still in `test_chunk_kda`. **[confirm these reasons match yours]**

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

@omuhamma
omuhamma force-pushed the omuhamma/kda-bf16-state-cleanup branch from 45113b9 to a1acb89 Compare October 29, 2026 14:47

@azaidy azaidy 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.

LGTM!

@azaidy
azaidy merged commit 3ba5ff7 into main Nov 5, 2026
60 checks passed
@azaidy
azaidy deleted the omuhamma/kda-bf16-state-cleanup branch November 5, 2026 12:26
eppaneamd added a commit that referenced this pull request Nov 9, 2026
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]>
dungthai414 added a commit to moreh-dev/rocm-aiter that referenced this pull request Nov 12, 2026
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.
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