Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d067061
Pin MX V partial-tile results against attention
jcaraban Sep 9, 2026
4656866
Cover block-sparse accuracy as the KV-tile count grows
jcaraban Sep 10, 2026
d2747d6
Refresh gfx950 dense MHA v4 objects for ragged seqlen_k
jcaraban Sep 10, 2026
f3b75fd
Refresh the gfx950 FP8, MXFP8 and I8FP8 MHA v4 objects
jcaraban Sep 10, 2026
7d973b9
Refresh the gfx950 F6F8 MHA v4 objects
jcaraban Sep 11, 2026
4ac7e7e
Accept per-batch key lengths in dense MHA v4
jcaraban Sep 11, 2026
55869d9
Align sorted-sparse F8F6 MHA v4 with the dense FP6-P V packing
jcaraban Sep 11, 2026
e75d261
Update gfx950 F8F6 MHA v4 objects to the block-schedule build
jcaraban Sep 11, 2026
e8dff04
Rebuild gfx950 F8F6 MHA v4 objects with a compacted register allocation
jcaraban Sep 12, 2026
ea62033
Rebuild gfx950 F6F8 and F8F6 MHA v4 objects with a V-LDS race fix
jcaraban Sep 12, 2026
bab0b5b
Add a sorted-sparse gfx950 MXFP6 MHA v4 object and rebuild the dense one
jcaraban Sep 15, 2026
fa58266
Rebuild the gfx950 F6F4 and MXFP6 MHA v4 objects and move F6F4 sparse…
jcaraban Sep 16, 2026
1fe9ae9
Fix all-MXFP4 sparse V packing and rebuild the gfx950 F4F4 objects
jcaraban Sep 17, 2026
cfb66a7
Route all-MXFP4 attention to the canonical-V mxfp4 objects
jcaraban Sep 19, 2026
f6e1682
Refresh gfx950 FMHA v4 f6f4 and mxfp8 objects
jcaraban Sep 20, 2026
25a3dba
Refresh gfx950 FMHA v4 mxfp6 objects
jcaraban Sep 20, 2026
8ebcb8a
Route gfx950 MXFP4 FMHA v4 through the FP6-P V packing
jcaraban Sep 21, 2026
4c06e5f
Scope the MXFP4 FP6-P pack rule to the V format, and format
jcaraban Sep 21, 2026
3497012
Retire MXFP4 Q/K with FP8 V
jcaraban Sep 21, 2026
27103cf
Drop V dispatch branches unreachable after the FP8-V retirement
jcaraban Sep 21, 2026
70f2529
Refresh the MHA v4 doc for dense/sparse recipe parity
jcaraban Sep 21, 2026
b105a94
Remove the deprecated mxfp8 alias and the canonical MXFP4 V producer
jcaraban Sep 21, 2026
39e5a71
Add coherent-attention input distributions to the sage benchmark
jcaraban Sep 21, 2026
21511cd
Subtract K's token mean before quantizing in MHA v4
jcaraban Sep 21, 2026
0b50b11
Add a K common-mode regression test for the quantized recipes
jcaraban Sep 21, 2026
417ecae
Fuse the K mean subtraction into the MX quantizer kernels
jcaraban Sep 21, 2026
adc319e
Split the block-sparse cases out of test_mha_v4.py
jcaraban Sep 21, 2026
5442b59
Gate K smoothing on the measured shared component
jcaraban Sep 22, 2026
0a15f4d
Clamp the per-channel V amax so empty heads do not quantize to NaN
jcaraban Sep 22, 2026
f5cf9bc
Raise the K-smoothing gate to the magnitude where it consistently pays
jcaraban Sep 22, 2026
fbaf64b
Calibrate the benchmark's default distribution to diffusion attention
jcaraban Sep 22, 2026
42b9b49
Emit the per-tensor amax from the hd128 rotate kernel
jcaraban Sep 22, 2026
e4d088c
Rebuild the MHA v4 fp8 hd128 dense kernel
jcaraban Sep 22, 2026
6543f65
Add BF16 sparse MHA v4 support
jcaraban Sep 22, 2026
f2e399e
Standardize gfx950 sparse LUT capacity
jcaraban Sep 22, 2026
7e2c32a
Rebuild the MHA v4 fp8 hd128 sparse kernel
jcaraban Sep 22, 2026
61cf2fc
Rebuild the MHA v4 fp8 hd128 kernels after a scheduling simplification
jcaraban Sep 22, 2026
b2ddc20
Rebuild the MHA v4 mxfp8 hd128 kernels
jcaraban Sep 22, 2026
b4ebc52
Rebuild the MHA v4 i8fp8 hd128 kernels
jcaraban Sep 22, 2026
4a8f7b5
Rebuild the MHA v4 i8fp8 hd128 kernels
jcaraban Sep 22, 2026
f0fc5e9
Rebuild the MHA v4 mxfp8 hd128 kernels
jcaraban Sep 22, 2026
30abd62
Enable BF16 sparse benchmark modes
jcaraban Sep 23, 2026
13a1d9d
Rebuild the MHA v4 f8f6, f6f8, mxfp6, f6f4 and mxfp4 hd128 kernels
jcaraban Sep 23, 2026
21a51a3
Rebuild the MHA v4 mxfp4 hd128 kernels
jcaraban Sep 23, 2026
9149ef3
bench_sage: drop the unsupported fp6_p argument on the f4f4 path
jcaraban Sep 23, 2026
cc06c3c
mha v4: dense log-sum-exp output
jcaraban Sep 23, 2026
4a908c7
Reject per-batch key lengths on rows that ignore them
jcaraban Sep 24, 2026
c600fae
Add the K-smoothing shift back into the exported LSE
jcaraban Sep 24, 2026
0345bb0
Require seqlens_k to live on Q's device
jcaraban Sep 24, 2026
1fb6b55
Fix the BF16 Q/K, FP8 V exported LSE under a frozen-max rollback
jcaraban Sep 24, 2026
cb9a297
Bound a per-batch key length inside the MHA v4 BF16 objects
jcaraban Sep 24, 2026
e6d53d5
Require the K mean to share the input's GPU
jcaraban Sep 24, 2026
31aa821
Format test_mha_v4.py with black
jcaraban Sep 24, 2026
009c350
Require the LSE buffer to live on Q's device, and document it
jcaraban Sep 24, 2026
4d4a0ed
Satisfy the pinned style checks
jcaraban Sep 24, 2026
15b591f
Gate LSE to the architecture where it has been measured
jcaraban Sep 24, 2026
9a6127e
Allocate the LSE output through one helper
jcaraban Sep 24, 2026
da09e19
Trim the oversized comments in the sage benchmark
jcaraban Sep 24, 2026
ece80ed
Fold the duplicated head and sparse-LSE validation into helpers
jcaraban Sep 24, 2026
686e053
Give the two custom-op recipes a shared exit
jcaraban Sep 24, 2026
a8e6123
Name the unpadded block-scale allocation
jcaraban Sep 24, 2026
e22ba20
Merge branch 'main' into mha_v4_fixes_sparse_etc
jcaraban Sep 24, 2026
b9a01f0
Pin that the exported LSE bias does not move between key chunks
jcaraban Sep 25, 2026
642c744
Bring both MHA v4 op tests up to the op-test standard
jcaraban Sep 25, 2026
247a9d3
Minor LUT scheduling tweaks across the gfx950 MHA v4 kernels
jcaraban Sep 27, 2026
dadc3a7
Refresh the gfx950 MHA v4 bf16 and bf16fp8 objects
jcaraban Sep 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions aiter/ops/mha_v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@ dispatch metadata. Unsupported recipes fail instead of falling back to another a
- Contiguous BF16 BSHD inputs with head dimension 128.
- BF16 BSHD output.
- Dense and sorted block-sparse inference.
- GFX950 LDS-staged sparse recipes support up to 8,192 KV tiles per sequence.
- Grouped-query ratios `1, 2, 4, 8, 16`.
- No backward, dropout, RNG state, LSE, causal, or varlen support yet.

Supported dense recipes:

| Q/K | V |
|---|---|
| BF16 | BF16 |
| BF16 | FP8 |
| INT8 | FP8 |
| MXFP8 | FP8 |
| FP8 | FP8 |
| FP8 | MXFP6 |
| MXFP6 | FP8 |
| MXFP6 | MXFP6 (dense only) |
| MXFP6 | MXFP4 |
| MXFP4 | MXFP4 |
- Per-batch key lengths via `seqlens_k`, on the dense GFX950 `BF16 Q/K` rows only. Every other
recipe, architecture, and the sorted-sparse path reject it.
- Log-sum-exp via `return_lse`, on the dense GFX950 rows. Sorted sparse rejects it, and so does
GFX942 until its exported value is measured.
- No backward, dropout, RNG state, causal, or Q-side varlen support yet.

Supported recipes. Every recipe is available in both dense and sorted-sparse mode with the same
V packing and scale modes.

| Q/K | V | Modes |
|---|---|---|
| BF16 | BF16 | dense, sparse |
| BF16 | FP8 | dense, sparse |
| INT8 | FP8 | dense, sparse |
| MXFP8 | FP8 | dense, sparse |
| FP8 | FP8 | dense, sparse |
| FP8 | MXFP6 | dense, sparse |
| MXFP6 | FP8 | dense, sparse |
| MXFP6 | MXFP6 | dense, sparse |
| MXFP6 | MXFP4 | dense, sparse |
| MXFP4 | MXFP4 | dense, sparse |

MXFP4 Q/K requires MXFP4 V. The FP8-V variant is retired.

## Ownership

Expand Down Expand Up @@ -60,11 +68,13 @@ Backend choice is private to `mha_v4_quant`; recipe selection does not branch on
| Per-tensor INT8/FP8 | Triton |
| Rotated FP8 and FP8 V | Triton |
| Canonical MXFP6 V | Triton |
| Canonical MXFP4 V | Triton |
| MXFP8/MXFP6/MXFP4 Q and K | HIP `module_mha_v4_quant` |
| FP6-P MXFP6 V | HIP `module_mha_v4_quant` |
| FP6-P MXFP4 V | HIP `module_mha_v4_quant` |

No manifest row consumes canonical MX V: every MXFP6-V and MXFP4-V row selects the FP6-P pack.
`quantize_v_mxfp6` is retained only as the reference the FP6-P layout test permutes against.

## APIs

Use `mha_v4` for BF16 inputs and canonical preprocessing:
Expand Down Expand Up @@ -115,10 +125,10 @@ calling `mha_v4_packed`.
MXFP4 V uses E2M1 values with one E8M0 scale per `(channel, 32-token)` block. Each 128-token tile
contributes 8,192 data bytes and 512 scale bytes. The data buffer includes 64 bytes of launch slack.

`AttentionPack.DEFAULT` is the canonical V token order used by sparse kernels and FP8-P rows.
`AttentionPack.V_FOR_FP6_P` selects the shared dense V token order for FP6-P and FP4-P consumers.
Numeric format and consumer pairing are separate dispatch contracts even when the physical V
layout is identical.
`AttentionPack.DEFAULT` is the canonical V token order. `AttentionPack.V_FOR_FP6_P` selects the V
token order that FP6-P and FP4-P consumers require, and a row's packing no longer depends on the
mode: dense and sparse rows for the same recipe select the same pack. Numeric format and consumer
pairing remain separate dispatch contracts even when the physical V layout is identical.

Changing a custom op's output shape or packed layout requires a versioned custom-op name.

Expand Down
Loading
Loading