Skip to content

[Triton/Gluon] bench_sage: route head dim 256 to the hd256 mxfp4/6 producers - #7174

Merged
jcaraban merged 3 commits into
mainfrom
mha4_hd256_mxfp4_bench
Nov 4, 2026
Merged

jcaraban merged 3 commits into
mainfrom
mha4_hd256_mxfp4_bench

Conversation

@jcaraban

@jcaraban jcaraban commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Routes bench_sage to the hd256 MXFP4/MXFP6 producers from #7173 and adds an aiter_fp8 comparator using FMHA v3 per-tensor FP8.

Motivation

Stacked on #7173. The hd256 producers have separate entry points, so the benchmark must select the same trio as production. aiter_fp8 provides the non-MX comparator that runs at d=256.

Changes

  • Selects Q/K/FP6-P V producers through mha_v4_mx_producers and uses the hd256 MXFP6 K view.
  • Adds opt-in aiter_fp8 via flash_attn_fp8_pertensor_func. It is deliberately unrotated: xDiT's AITER_FP8 rotates Q/K, so their accuracy is not directly comparable.
  • Cancels internal Q/K rotation per 128-wide half, supporting --hadamard-rotate 0 at d=256.
  • Normalizes quality output using each runner's actual layout, fixing the pre-existing mis-permutation of BSHD-native runners under --layout bhsd.
  • Changes no runtime or kernel code.

Performance

Benchmark-only change; no kernel speedup claimed or absolute throughput quoted here. hd256 object throughput is reported in #7173.

Testing

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

Documentation

Dependencies

  • No new third-party dependencies added

Breaking Changes

None. hd256 routing applies only at head dim 256; aiter_fp8 is opt-in. Existing rows retain their behavior except for the rotation-cancellation and quality-layout fixes above.

PR Self-Review

Reviewed revision

19fd870

Behavior and intent

The benchmark now reaches production hd256 MXFP4/MXFP6 objects, offers an unrotated FP8 comparator, and evaluates quality in the correct output layout rather than mis-permuting native-BSHD results.

Validation and unverified scope

On gfx950 (MI355X):

  • bench_sage.py --kernel mha4_mxfp4 --d 256 --dv 256 --b 1 --hq 16 --hk 16 --sq 4096 --sk 4096 loads _ZN5aiter28fmha_fwd_hd256_mxfp4_gfx950E, confirming hd256 producer selection.
  • At dc29c376d, bench_sage.py --b 1 --hq 5 --hk 5 --sq 16384 --sk 16384 runs mha4_mxfp6 and mha4_mxfp4 at d=128/256, kernel-only and --e2e, plus the shared-helper rows mha4_f6f4/mha4_f6f8 at d=128. MXFP6 d256 loads _ZN5aiter28fmha_fwd_hd256_mxfp6_gfx950E.
  • Black/Ruff pass; the module imports with 15 kernel specs. CPU checks against an exact Hadamard confirm cancel-then-producer is identity at d=128/256 and only the two sage_* runners are permuted under --layout bhsd.
  • GPU checks with --b 1 --hq 4 --sq 1024 --sk 1024: mha4_mxfp4 --d 256 --hadamard-rotate 0 gives cosine 0.9825. With --layout bhsd --report-quality, cosine is 0.9990/0.9992 for aiter_fp8 d128/d256, 1.0000 for aiter_bf16, and 0.9997 for sage_fp8 (still permuted). Before the fixes, the former aborts and the latter raises the reported shape mismatch.

Unverified: no MI250X/MI300X run. bench_sage.py is not collected by CI on any target; all validation was manual.

PR-specific question

The manual checks cover hd256 routing, half-head rotation cancellation and runner-specific layout conversion; the pre-fix benchmark cannot complete the latter two cases. Neither select_triton_tests.py nor split_tests.sh collects op_tests/op_benchmarks/triton/, so no CI job exercises this benchmark.

Changed op tests

None. Only op_tests/op_benchmarks/triton/bench_sage.py changes; it is a benchmark, not an op test.

@jcaraban
jcaraban added this pull request to stack #7175 October 29, 2026 20:29
@github-actions github-actions Bot changed the title bench_sage: route head dim 256 to the hd256 MXFP4 producers [Triton/Gluon] bench_sage: route head dim 256 to the hd256 MXFP4 producers Oct 29, 2026
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 19fd870008e2 · 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

The benchmark now reaches production hd256 MXFP4/MXFP6 objects, offers an unrotated FP8 comparator, and evaluates quality in the correct output layout rather than mis-permuting native-BSHD results.

Validation and unverified scope

On gfx950 (MI355X):

- `bench_sage.py --kernel mha4_mxfp4 --d 256 --dv 256 --b 1 --hq 16 --hk 16 --sq 4096 --sk 4096` loads `_ZN5aiter28fmha_fwd_hd256_mxfp4_gfx950E`, confirming hd256 producer selection.
- At `dc29c376d`, `bench_sage.py --b 1 --hq 5 --hk 5 --sq 16384 --sk 16384` runs `mha4_mxfp6` and `mha4_mxfp4` at d=128/256, kernel-only and `--e2e`, plus the shared-helper rows `mha4_f6f4`/`mha4_f6f8` at d=128. MXFP6 d256 loads `_ZN5aiter28fmha_fwd_hd256_mxfp6_gfx950E`.
- Black/Ruff pass; the module imports with 15 kernel specs. CPU checks against an exact Hadamard confirm cancel-then-producer is identity at d=128/256 and only the two `sage_*` runners are permuted under `--layout bhsd`.
- GPU checks with `--b 1 --hq 4 --sq 1024 --sk 1024`: `mha4_mxfp4 --d 256 --hadamard-rotate 0` gives cosine 0.9825. With `--layout bhsd --report-quality`, cosine is 0.9990/0.9992 for `aiter_fp8` d128/d256, 1.0000 for `aiter_bf16`, and 0.9997 for `sage_fp8` (still permuted). Before the fixes, the former aborts and the latter raises the reported shape mismatch.

Unverified: no MI250X/MI300X run. `bench_sage.py` is not collected by CI on any target; all validation was manual.

PR-specific question

The manual checks cover hd256 routing, half-head rotation cancellation and runner-specific layout conversion; the pre-fix benchmark cannot complete the latter two cases. Neither `select_triton_tests.py` nor `split_tests.sh` collects `op_tests/op_benchmarks/triton/`, so no CI job exercises this benchmark.

Changed op tests

None. Only `op_tests/op_benchmarks/triton/bench_sage.py` changes; it is a benchmark, not an op test.

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.

@ROCm ROCm deleted a comment from github-actions Bot Oct 29, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 29, 2026 21: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

Active issues cause 256-wide heads to fail in the hd128-only rotation op and quality reporting to compare mismatched output layouts for aiter_fp8.

2 open issues
What changed in this PR

This benchmark-only change lets bench_sage exercise the hd256 MXFP4 support from #7173 and adds an FP8 comparator. It does not modify runtime or kernel code.

Changes:

  • Selects the hd256 MXFP4 producer trio for 256-wide heads.
  • Adds an opt-in, unrotated aiter_fp8 row with end-to-end and kernel-only timing.
File Description
op_tests/​op_benchmarks/​triton/​bench_sage.py Adds hd256 producer routing and the per-tensor FP8 benchmark runner.

Review effort: Balanced

@zufayu
zufayu requested review from a team and k50112113 October 30, 2026 01:25
@zufayu
zufayu removed the request for review from k50112113 October 30, 2026 01:54
@jcaraban
jcaraban force-pushed the mha4_hd256_mxfp4_bench branch from c3f3d05 to 21fbe18 Compare October 30, 2026 11:47
@jcaraban
jcaraban requested a review from a team October 30, 2026 11:47
@jcaraban
jcaraban force-pushed the mha4_hd256_mxfp4_bench branch 2 times, most recently from 7569ad6 to 8396d6b Compare October 30, 2026 16:58
@jcaraban

Copy link
Copy Markdown
Contributor Author

@k50112113 the failed job is unrelated to this PR, please let me know how to proceed

@jcaraban
jcaraban force-pushed the mha4_hd256_mxfp4_bench branch from 8396d6b to 6297254 Compare November 2, 2026 07:01
@jcaraban jcaraban changed the title [Triton/Gluon] bench_sage: route head dim 256 to the hd256 MXFP4 producers [Triton/Gluon] bench_sage: route head dim 256 to the hd256 MXFP4 and MXFP6 producers Nov 2, 2026
@jcaraban jcaraban changed the title [Triton/Gluon] bench_sage: route head dim 256 to the hd256 MXFP4 and MXFP6 producers [Triton/Gluon] bench_sage: route head dim 256 to the hd256 mxfp4/6 producers Nov 2, 2026
Base automatically changed from mha4_hd256_mxfp4 to main November 3, 2026 11:57
MXFP4 is the one recipe with an hd256 object, and its producers are separate entry points rather
than a head-dim argument, so the bench has to pick the trio the way mha_v4's raw path does.

Stacked on the hd256 kernel branch; it has no object to benchmark without it.
…runner layout

--hadamard-rotate 0 passed a 256-wide head to the hd128-only rotation op. The hd256 producers
rotate each 128-wide half as its own head, so the cancel now does the same.

Only the two sage runners honour --layout; the other 13 are handed BSHD and return BSHD, yet both
quality sites permuted every output under --layout bhsd. A follows_layout spec field now gates the
permute. The bug predates aiter_fp8, which only inherited it.
The MXFP4 and MXFP6 producer helpers now take their (Q, K, FP6-P V) trio from
mha_v4's own table instead of restating the head-dim switch, which also routes
mha4_mxfp6 at --d 256 to the hd256 MXFP6 producers.

b1 h5 s65536 d256: mha4_mxfp6 4321 TFLOPS kernel-only, 4047 --e2e
(mha4_mxfp4 5043). mha4_mxfp4/mxfp6/f6f4/f6f8 at d128 unchanged.

Signed-off-by: jcaraban <[email protected]>
@jcaraban
jcaraban force-pushed the mha4_hd256_mxfp4_bench branch from 6acac67 to 19fd870 Compare November 3, 2026 12:22
@zufayu
zufayu requested a review from Dewei-Wang-sh November 4, 2026 01:33
@jcaraban jcaraban assigned Dewei-Wang-sh and unassigned k50112113 Nov 4, 2026
@jcaraban
jcaraban merged commit a2ea453 into main Nov 4, 2026
@jcaraban
jcaraban deleted the mha4_hd256_mxfp4_bench branch November 4, 2026 19:15
eppaneamd added a commit that referenced this pull request Nov 4, 2026
…sp-rs-ag

No conflicts; main's new commit touches only op_tests/op_benchmarks/triton/bench_sage.py.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

7 participants