Skip to content

[MHA] Test that a varlen attention sink does not take the v3 ASM kernel - #6893

Merged
shay-li77 merged 2 commits into
ROCm:mainfrom
jatseng-ai:fix-varlen-fmha-v3-sink-routing
Dec 3, 2026
Merged

shay-li77 merged 2 commits into
ROCm:mainfrom
jatseng-ai:fix-varlen-fmha-v3-sink-routing

Conversation

@jatseng-ai

@jatseng-ai jatseng-ai commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The original kernel gate in this PR is already on main as of #6906 (merged Oct 27). This branch is rebased onto current main and no longer retouches aiter/ops/mha.py.
  • What remains is extra coverage #6906 does not have: hdim 192, North Mini (32/4) and Command A Plus (32/2) GQA ratios, and a numeric check that a set sink_ptr actually moves the output.

Motivation

#6906 spies dispatch on hdim 128 only. A later change could keep that spy green while hdim 192 or a GQA-ratio call still dropped the sink, or while CK was selected but ignored sink_ptr. This test fails in those cases.

Changes

  • Add op_tests/test_fmha_v3_varlen_sink_route.py: wrap fmha_v3_varlen_fwd / mha_varlen_fwd, assert the route, and compare against an fp32 reference that includes the sink.

Performance (if applicable)

Not a kernel change. Dispatch with a set sink already goes to CK via #6906.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • No documentation change is needed, with the reason stated below

Test-only follow-up to a gate that is already documented in can_impl_fmha_v3_fwd.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None

PR Self-Review

Reviewed revision

b4fdbcd

Behavior and intent

No runtime change versus current main. #6906 already routes a set sink_ptr / sink_size away from fmha_v3_varlen_fwd. This PR only adds a test that the original hotfix did not: hdim 192, two production GQA ratios, and a numeric sink vs no-sink check.

Validation and unverified scope

  • Local gfx942 MI300X: pytest op_tests/test_fmha_v3_varlen_sink_route.py → 12 passed.
  • Unverified: gfx950 runtime (OPUS vs v3 on hdim 192 is asserted in the test but not run here), sink_size without sink_ptr (covered by #6906's test_mha_varlen.py spy).

PR-specific question

What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?

op_tests/test_mha_varlen.py::test_flash_attn_varlen_func_sink_bypasses_v3_asm only spies hdim 128 dispatch. It would stay green if hdim 192 or a 32/4 or 32/2 GQA call still took fmha_v3_varlen_fwd, and it would stay green if CK was selected but ignored sink_ptr. This file fails on those cases by wrapping both launchers and comparing against an fp32 reference that includes the sink.

Changed op tests

op_tests/test_fmha_v3_varlen_sink_route.py is new. op_tests/test_mha_varlen.py::test_flash_attn_varlen_func_sink_bypasses_v3_asm already spies hdim 128 dispatch. This file adds hdim 192, North Mini / Command A Plus GQA, and numeric correctness.

@jatseng-ai
jatseng-ai requested a review from a team October 23, 2026 21:11
@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 6893 --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.

The v3 ASM gate itself landed in ROCm#6906. This covers hdim 192, North Mini
and Command A Plus GQA ratios, and a numeric check that the sink moves
the output.

Co-authored-by: Cursor <[email protected]>
@jatseng-ai
jatseng-ai force-pushed the fix-varlen-fmha-v3-sink-routing branch from 6e1501a to b4fdbcd Compare November 2, 2026 21:00
@aiter-bot

aiter-bot commented Nov 2, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 1b322c95699d · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA

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

@jatseng-ai jatseng-ai changed the title [MHA] Route varlen FMHA v3 to CK when an attention sink is set [MHA] Test that a varlen attention sink does not take the v3 ASM kernel Nov 2, 2026
@jatseng-ai

Copy link
Copy Markdown
Contributor Author

The kernel gate this originally shipped is already on main as of #6906 (merged Oct 27). I rebased onto current main and dropped the duplicate mha.py hunk so this no longer races that fix.

What is left is extra coverage that #6906's hdim-128 dispatch spy does not have:

  • hdim 192 (OPUS vs v3 vs CK)
  • North Mini 32/4 and Command A Plus 32/2 GQA
  • numeric check that a set sink_ptr moves the output vs a no-sink reference

Local gfx942 MI300X: pytest op_tests/test_fmha_v3_varlen_sink_route.py → 12 passed.

@shay-li77 could you take a look when you have a moment?

@jatseng-ai

Copy link
Copy Markdown
Contributor Author

Standard Tests: shards 0–4 and 6–7 passed (including op_tests/test_fmha_v3_varlen_sink_route.py on shard 7). Shard 5 failed on infra — the self-hosted runner lost communication; no test log.

Fork PRs cannot rerun (403). @shay-li77 could you Re-run failed jobs on https://github.com/ROCm/aiter/actions/runs/41524307182 (shard 5 only) and take a look at the extra coverage when you have a moment?

@jatseng-ai

Copy link
Copy Markdown
Contributor Author

Morning ping: shard 5 is still the infra fail (runner lost communication; no test log) on https://github.com/ROCm/aiter/actions/runs/41524307182 — needs Re-run failed jobs from someone with Actions admin (fork PRs cannot rerun). Shards 0–4 and 6–7 passed, including the new varlen sink tests on shard 7.

@shay-li77 / TEAM_AITER — review + rerun when you can. Test-only follow-up; kernel gate already on main via #6906.

@shay-li77

Copy link
Copy Markdown
Contributor

Thanks for the follow-up, and sorry for the slow reply. The run you linked (41524307182) is no longer available (it returns 404), so shard 5 can't be re-run from there; a fresh CI run is needed.

Could you merge the latest main into this branch yourself? Either the "Update branch" button on this PR or a local merge/rebase works, as long as the push comes from your side. Please don't wait for me to do it: main requires the last push to be approved by someone other than the person who pushed it, so if I update the branch, my own approval no longer counts and I can't approve and merge this for you.

The branch is 396 commits behind, and several of them touch the dispatch your test asserts on (e.g. #7584, #6990, #8075), so a quick local re-run of op_tests/test_fmha_v3_varlen_sink_route.py after merging would be good. Once you push, CI will run again; if shard 5 hits the runner issue again, I'll re-run it, then review and merge. @jatseng-ai

@xiangxli-cop

Copy link
Copy Markdown

@jatseng-ai Following up on the Nov 18 comment: the CI records for the current head have been cleaned up, so the required checks no longer show. Could you merge the latest main into this branch to trigger a fresh CI run?

Sync with upstream main to trigger a fresh CI run on ROCm#6893.
@shay-li77

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 2 review(s); expect to start in about 45 min. The box reviews one PR at a time.

@shay-li77
shay-li77 merged commit 51ba6ac into ROCm:main Dec 3, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants