Repository navigation
[ASM] [HIP] Mha v4: gfx950 hd256 MXFP8 kernel - #7756
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
91f177c to
9d6e996
Compare
9d6e996 to
ea0def0
Compare
cfc4666 to
a8c1fac
Compare
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.
a8c1fac to
2e24f46
Compare
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_sageb1 h5, hd256 vs hd128 MXFP8 (TFLOP/s, median of 3):--e2es16384Regenerated 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.
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
a8c1facd7aBehavior 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_packedcompares the scale mode directly, so fullgraph compile does not break.Validation and unverified scope
MI355X:
python3 op_tests/test_mha_v4.py343 passed,python3 op_tests/test_mha_v4_sparse.py609 passed (5 skipped), both ata8c1facd7a(rebased on main after #7794; the new hd256 MXFP8 manifest row carries #7794'skv_range/jensen/sortedcolumns 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_1X32scales and per-tensor FP8 V, dense._check_head_dimrejects 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.