Skip to content

[ASM] [HIP] Mha v4: gfx950 hd256 MXFP8 kernel - #7756

Merged
jcaraban merged 2 commits into
mainfrom
mha4_hd256_mxfp8
Nov 16, 2026
Merged

jcaraban merged 2 commits into
mainfrom
mha4_hd256_mxfp8

Conversation

@jcaraban

@jcaraban jcaraban commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the gfx950 hd256 MXFP8 recipe next to hd256 MXFP4/MXFP6 (#7173): MXFP8 Q/K with E8M0 per-32 scales, per-tensor FP8 V, dense, 256Q/64KV. K is one 17,408-byte record per 64 tokens, written by the hd128 MXFP8 rotate-quantize kernel in a new record mode (quantize_mxfp8_k_hd256).

The second commit regenerates all three hd256 objects (MXFP4, MXFP6, MXFP8), with the same symbols and kernargs and fewer registers (SGPR/VGPR: MXFP4 90/256 -> 74/244, MXFP6 90/244 -> 70/248, MXFP8 90/256 -> 66/256). MXFP4 also rounds the FP6 P block max into the next binade before taking its E8M0 exponent, so a max with a bf16 mantissa >= 120/128 no longer saturates E2M3. MXFP6 and MXFP8 output is bitwise unchanged.

Performance

MI355X, bench_sage b1 h5, hd256 vs hd128 MXFP8 (TFLOP/s, median of 3):

Workload hd128 hd256 Change
kernel-only s8192 1928 2088 +8.3%
kernel-only s16384 2060 2214 +7.5%
kernel-only s65536 2978 3156 +6.0%
--e2e s16384 1867 1995 +6.9%

Regenerated objects vs the previous ones (kernel time, 60 rounds x 8 GPUs; positive is faster). The same-object control moved up to -0.23% at s65536.

Recipe h16 s4096 h32 s2048 h5 s16384 h5 s65536
MXFP4 -0.03% +0.13% +0.07% -0.22%
MXFP6 +0.24% +0.29% +0.24% +0.00%
MXFP8 -0.00% +0.04% -0.09% -0.27%

hd256 MXFP4 error (1-cos vs aiter_bf16, b1 h5 s8192, seeds 0/1): tiebreak -4.4/-5.1%, latepeak +0.2/+0.3%, diffusion and peaked within 0.05%, maxstair unchanged.

PR Self-Review

Reviewed revision

a8c1facd7a

Behavior and intent

hd256 accepted only all-MXFP4 or all-MXFP6; FP8 Q/K under E8M0 scales now dispatch to the new object, and per-tensor FP8 at hd256 is still rejected. The head-dim check in mha_v4_packed compares the scale mode directly, so fullgraph compile does not break.

Validation and unverified scope

MI355X: python3 op_tests/test_mha_v4.py 343 passed, python3 op_tests/test_mha_v4_sparse.py 609 passed (5 skipped), both at a8c1facd7a (rebased on main after #7794; the new hd256 MXFP8 manifest row carries #7794's kv_range/jensen/sorted columns as 0). Kernel-level validator: dequantized-reference cosine >= 0.9995, identical output across 32 launches on odd KV-tile shapes, key-swap controls fail. Unverified: none beyond MI355X; the object is gfx950-only.

PR-specific question

Selected only on gfx950 at head dim 256 for FP8 Q/K with E8M0_PER_1X32 scales and per-tensor FP8 V, dense. _check_head_dim rejects other FP8 hd256 combinations and sparse, and a natural (non-record) K raises before launch.

Changed op tests

op_tests/test_mha_v4.py: runs the existing hd256 checks (attention, GQA, partial KV, seqlens_k, LSE, compile parity, K common mode) for MXFP8, adds a byte-exact K-record check against an index formula and a natural-K rejection. hd256 MXFP8 had no coverage.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 7756 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 2e24f46c4114 · 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. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  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.

Third hd256 recipe, after MXFP4 and MXFP6: MXFP8 Q/K (E8M0 per 32) with
per-tensor FP8 V, dense, on the same 256Q/64KV geometry. hd256 now accepts FP8
Q/K only under E8M0 scales; per-tensor FP8 at hd256 is still rejected.

Q and V stay natural BSHD (Q from the hd128 producer on the [b, s, 2h, 128]
half-head view). K is one 17,408-byte record per 64 tokens, written directly by
the hd128 MXFP8 rotate-quantize kernel under a new record mode: 16 KiB of data in
the FP8 MFMA lane order, then the 1 KiB K-scale tail hd256 MXFP6 already uses.
An FP8 operand's scale block b is its dwords 4b..4b+3 in both lane halves (not
lane half b as for FP4/FP6), so a lane slot holds channels half*64 + hi*16 and
the same +32. The raw MXFP8 default softmax scale now follows the head dim.

gfx950, b=1 h=5, bench_sage kernel-only, hd256 vs hd128 MXFP8 (median of 3
interleaved rounds):
  s=8192   2088 vs 1928 TFLOP/s  (+8.3%)
  s=16384  2214 vs 2060 TFLOP/s  (+7.5%)
  s=65536  3156 vs 2978 TFLOP/s  (+6.0%)
e2e (quantize + attention) at s=16384: 1995 vs 1867 (+6.9%).
Cosine against bf16 attention 0.9985; bench_sage d=256 cosine 0.99958 against
0.99949 for hd256 MXFP6.

test_mha_v4 runs the hd256 checks (attention, GQA, partial KV, seqlens_k against
truncated K/V, LSE against torch and hd128, compile parity, K common mode) for
MXFP8 too, checks every K-record byte and E8M0 against an explicit index formula,
and rejects a natural K at hd256. seqlens_k pins V's amax so the per-tensor V
scale matches between the varlen call and its truncated controls. test_mha_v4
343/343 and test_mha_v4_sparse 290/290 (5 skipped) pass on gfx950.

Signed-off-by: jcaraban <[email protected]>
Same symbols and kernargs. SGPR/VGPR: MXFP4 90/256 -> 74/244, MXFP6 90/244 -> 70/248,
MXFP8 90/256 -> 66/256.

MXFP4 now rounds the FP6 P block max into the next binade before taking its E8M0 exponent, so a
max with a bf16 mantissa >= 120/128 no longer saturates E2M3. 1-cos vs aiter_bf16 (b1 h5 s8192,
seeds 0/1): tiebreak -4.4/-5.1%, latepeak +0.2/+0.3%, diffusion and peaked within 0.05%, maxstair
unchanged. MXFP6 and MXFP8 output is bitwise unchanged.

A/B vs the previous objects (60 rounds x 8 GPUs; h16 s4096 / h32 s2048 / h5 s16384 / h5 s65536):
MXFP4 -0.03/+0.13/+0.07/-0.22%, MXFP6 +0.24/+0.29/+0.24/+0.00%, MXFP8 -0.00/+0.04/-0.09/-0.27%;
the same-object control moved up to -0.23% at s65536.

test_mha_v4.py: 343 passed.
@jcaraban
jcaraban merged commit 36e7358 into main Nov 16, 2026
@jcaraban
jcaraban deleted the mha4_hd256_mxfp8 branch November 16, 2026 11:29
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