Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
With NVFP4 sparse K/V on gfx1250 and the MXFP4 checkpoint's native group-32 A8 o_proj, every sparse layer (57) stored the paged attention's BF16 output and o_proj quantized it again (native_quant_linear -> quantize_fp8_kernel: 2.4 us a layer at decode, 7.2 us at prefill). ATOM_MINIMAX_M3_PA_MXFP8_OUT=1 (default off, for A/B) asks aiter's paged decode for that MXFP8 input instead: Attention.forward_mxfp8 allocates E4M3 rows and E8M0 scales [tokens, heads * head_dim / 32] and runs the new custom op unified_attention_with_output_quant_base, which hands them through the sparse impl to pa_decode (an E8M0 output_scale selects the MXFP8 output); o_proj takes them as (x, x_scale). The attention keeps the BF16 call's split: aiter writes the MXFP8 output in every output mode, so the bytes equal the BF16-only attention quantized by quantize_fp8, bit for bit. The path applies when the flag is on, the arch is gfx1250 (construction), the layer's K/V are NVFP4 and o_proj is native group-32 A8 (forward: both are known only after load). Otherwise the BF16 path is unchanged. Dummy-run rows get FP8 zeros and E8M0 1.0 scales (fill_unit_scale). Needs aiter with ROCm/aiter#8289 + ROCm/aiter#8365. Tests: test_nvfp4_attention_mxfp8_output_is_bf16_then_quantize_fp8 (gfx1250: 8 / 37 / 64 / 512 / 2048 rows, bytes and scales equal BF16-only attention + quantize_fp8); tests/test_minimax_m3_pa_mxfp8_out.py (CPU): the model hands (FP8, E8M0) to o_proj only under the flag with NVFP4 K/V and a native A8 o_proj, the attention passes the MXFP8 output with the BF16 split, fill_unit_scale. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… across query tokens aiter.ops.flydsl.pa_sparse_prefill.pa_sparse_prefill_nvfp4: the prefill counterpart of pa_decode's NVFP4 wave tile, for MiniMax-M3.1's block-sparse attention: 16 query heads per KV head, head_dim 128, 128-token NVFP4 pages, top-16 pages per token. It takes the compacted page table and lengths that pa_decode's NVFP4 sparse path takes. Instead of one CTA per token gathering its own 16 pages, a CTA takes tile_rows consecutive tokens and walks the union of their selected pages once. Each page is DMAed and dequantized once, and every token that selected it runs its own QK / softmax / PV step. - impl="v1" (kernels/pa_sparse_prefill_nvfp4.py): tile_rows 2, 3, 4, 6 or 8. - impl="v2" (kernels/pa_sparse_prefill_nvfp4_v2.py): the tile's rows run in one basic block per page against a lazily re-based softmax reference. Compile options are passed through `v2` (rebase_log2, waves_per_eu, all_rows, v_valu, q_regs, v_hoist, fence, v_wide); tile_rows 2, 4, 6 or 8. - quantized_output / output_scale: o_proj's MXFP8 input (E4M3 + E8M0 per 32), bit for bit the group-32 quant of the BF16 rows, padded rows included. With one KV head, as ROCm#8365's decode output. The result equals pa_decode's to rounding: each row's pages accumulate in the tile's union order. MI455X, one MiniMax-M3.1 TP4 rank, 14336 new tokens on 99968 cached, real top-k picks: v2 at tile_rows 2 takes 248-271 us a layer against 307-312 for the paged decode one token a CTA (v1: 276-325). 16000 prose tokens on 98304: 271 vs 346 us. An AgentX-shaped 32768 on 65280: 634 vs 700 us. op_tests/test_flydsl_pa_sparse_prefill_nvfp4.py checks both impls against an FP32 attention over the dequantized pages and against pa_decode (the error must not exceed pa_decode's by more than rounding). It covers synthetic pick patterns from shared to random, padding rows and the MXFP8 output. `python op_tests/test_flydsl_pa_sparse_prefill_nvfp4.py` benchmarks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the paged attention (opt-in) ATOM_M3_PA_FUSED_REDUCE=1 (default off). On gfx1250 with NVFP4 sparse K/V, decode rows merge their top-k window inside aiter's FlyDSL paged attention instead of the tile kernel plus the separate PS reduce kernel. `sparse_attn_nvfp4.fused_reduce_split` picks the split: - a cluster of 8 or 4 CTAs per row while every row's cluster stays resident (gfx1250: 15 clusters per 16 CUs), with two wave groups at the 4-cluster bound; - otherwise one CTA per row, whose four wave groups split its pages and merge in LDS. The launch is plan-free, and a request's rows (which share most selected pages) dispatch on one XCD. - The decode caller passes `rows_per_request` (its query length). Prefill rows (0) keep the split path, and so does everything with the flag off. - `_flydsl_prepare_explicit_plan` takes a `plan_workgroup_budget` override for the cluster split. - Both outputs: BF16, and o_proj's MXFP8 input (ROCm#3634). MI455X, C64 decode, CUDA graph, us per layer, fused vs the split path: 32 rows 4.6 vs 5.1, 64 rows 5.1 vs 6.5, 80 rows 6.3 vs 8.5, 128 rows 6.9 vs 8.6, 192 rows 8.5 vs 13.0, 256 rows 9.6 vs 13.7. Needs aiter's fused-reduce paged attention (stacked on ROCm/aiter#8365). Tests: - (CPU) the split policy, and the fused-reduce keywords reaching pa_decode only for decode rows under the flag; - (gfx1250) the fused output against the split path, and the MXFP8 bytes as quantize_fp8 of the same call's BF16 output. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6db6bfd to
35491d4
Compare
DRAFT — evaluation pausedPR Self-ReviewRevision This pull request is a draft, so readiness evaluation is paused and no verdict applies. Evaluation resumes when it is marked ready for review and the required CI completes. |
35491d4 to
2c7d748
Compare
fsx950223
left a comment
There was a problem hiding this comment.
Reviewed commit 2c7d748, focusing on the final MXFP8 commit against stacked parent a906e3e. No concrete blocking defect was found in the changed dispatch, group quantization, output addressing, or reducer argument marshalling. A targeted gfx942 reducer regression passed with pinned FlyDSL 0.5.3. Validation remains insufficient for approval because the new MXFP8 epilogues require gfx1250, which is unavailable in the configured environments, and no gfx1250 CI result covers this head. Independent gfx1250 correctness testing should cover direct, cluster, last-arriver, query-split, and sink/reducer routes, including the XCD-grid reducers above eight partitions.
Validation:
- PASS on
local:git -C checkout rev-parse HEAD; git -C checkout diff HEAD^ HEAD --check; parse all eight changed Python files with ast.parse
HEAD matched 2c7d748. Diff whitespace checks and Python syntax checks passed. - PASS on
hjbog-srdc-39.amd.com / sixifang_dev:HIP_VISIBLE_DEVICES=0 PYTHONPATH=$PWD:/tmp/codex-pr-review-8365-2c7d748/venv/lib/python3.12/site-packages:/opt/venv/lib/python3.12/site-packages FLYDSL_RUNTIME_CACHE_DIR=/tmp/codex-pr-review-8365-2c7d748/cache AITER_JIT_DIR=/tmp/codex-pr-review-8365-2c7d748/aiter-cache flock -w 30 /tmp/codex-pr-review-8365-2c7d748/gpu.lock timeout 180 /tmp/codex-pr-review-8365-2c7d748/venv/bin/python reducer_regression.py
Exit 0. Verified gfx942, FlyDSL 0.5.3, and AITER imports from the exact-head source archive. Four numerical reducer checks passed: BF16 D64/D128, with and without sinks, three partitions. Maximum absolute errors were 0.00565–0.00751. Log: gfx942-regression-final.log. Earlier attempts and the corrected reference script are also preserved. - SKIP on
dzm-mi355-gpu34-dev:ssh -o BatchMode=yes -o ConnectTimeout=10 -o RequestTTY=no -o ControlMaster=no -o ControlPath=none -o RemoteCommand=none dzm-mi355-gpu34-dev "squeue -h -u zhiming_ding_qle -o '%i|%N|%t'"
SSH connection to aac16.amd.com port 22 timed out before allocation discovery; no gfx950 tests ran. Failure preserved in gfx950-discovery.log. - SKIP on
gfx1250:Targeted op_tests/test_flydsl_pa_decode.py MXFP8 correctness cases
No configured gfx1250 environment. gfx942/gfx950 cannot validate these epilogues. Author-reported MI455X results were examined as evidence but were not independently reproduced.
Remaining validation:
- The gfx942 check validates the changed non-MXFP8 reducer launcher, not the gfx1250 MXFP8 kernels.
- CI reports a failed MI35X standard-test shard and failed test gate. Job metadata identifies the Tests step as failing, but downloaded logs were empty, so the failure could not be attributed to this diff.
- The gfx1250 workflow restricts fork PR execution; no available gfx1250 CI result validates this head.
- No prior reviews or inline review feedback were present. No GitHub mutations were performed.
Automated Codex review of commit 2c7d748ed566.
NVFP4 K/V (packed e2m1, one E4M3 scale per 16 values, token-major per (page, KV head): [128, 64] payload and [128, 8] scale bytes) for the gfx1250 FlyDSL pa_decode, selected by key/value scales of dtype float8_e4m3fn. Gfx1250Nvfp4WavePipeline serves one query tile (<= 16 rows: M3.1 TP4 decode, MTP and prefill rows): each wave owns 32 tokens of every page and DMAs them into a private 3-page ring, QK is v_wmma_scale16_f32_16x16x128_f8f6f4 straight from the raw K rows and their E4M3 scales (the query split into FP8 terms exact to 2^-21 of a 16-dim block's maximum), V is dequantized and transposed by the same instruction with a constant selector, and softmax and P stay in registers, so the page loop has no CTA barrier. Direct, last-arriver, cluster and reducer outputs and the FP8 output epilogue are supported. v_wmma_scale16 misreads 64-bit scale operands that come from an inline constant or an SGPR pair on gfx1250; every selector scale is ORed with a lane-varying zero so it stays in a VGPR pair. The tests extend op_tests/test_flydsl_pa_decode.py: accuracy against an fp32 reference over the dequantized cache in every output mode, and the FP8 output bit for bit against the standalone per-token quant. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ode_tile kv_scale_dtype is the dtype of the K/V block scales, not of K/V: packed e2m1 K/V with E4M3 scales is NVFP4, and FP8, BF16 and MXFP4 callers leave it None. Comment only; the module's AST is unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s, query splits
NVFP4 is a compute dtype of the gfx1250 tile ("nvfp4"), selected by
nvfp4_kv(kv_dtype, kv_scale_dtype) in the host wrapper, compile_pa_decode_tile
and gfx1250_tile_traits alike. compile_pa_decode_tile takes it through the
existing gfx1250 branch, and Gfx1250Traits.bf16 is main's again: the wave tile
passes its 2-byte DMA unit to tdm_copy instead.
pa_decode validates NVFP4 caches with the common shape, dtype, device and
contiguity checks and their scales with the per-token scale checks. The tile's
own limits (head_dim 128, page 128, 16 query rows a CTA) are stated once, in
compile_gfx1250_pa_decode.
No longer refused: sinks (the reducer applies them), sliding windows (the wave
tile masks the window as the BF16 wave tile does) and more than 16 query rows
(query positions split evenly over up to 8 CTAs; cluster selection counts
their grid rows).
ISA of the 15 NVFP4 and 14 FP8/BF16 tile kernels compared is byte-identical to
the previous revision; the NVFP4 symbol tag is now kvnvfp4.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
MiniMax-M3.1's MXFP4 checkpoint runs o_proj as a native MXFP8 GEMM (gemm_a8w8_mx32: E4M3 activations, one E8M0 scale per 32 along K). Each sparse layer stored the PA's BF16 output and quantized it in a separate kernel. The per-token quantized_output (one FP32 descale a token) does not fit that GEMM. An E8M0 output_scale [rows, H * D / 32] (dtypes.fp8_e8m0 or uint8) now selects that output in pa_decode: FP8 bytes in the output's layout and row-major scales, bit for bit the BF16/FP16 output of the same call quantized as the split path does: code = ceil_pow2(max(amax, 1e-10) / 448) (emit_mx_e8m0_scale RoundUp), values e4m3(clamp(x * 2^(127 - code), +-448)) after rounding to the output dtype. Padded bucket rows are FP8 zeros with E8M0 1.0. A float32 [rows, 1] scale keeps the per-token output unchanged. A 32-element group lies in one head row, so its maximum takes lane shuffles only (kernels/pa_decode/op_mxfp8.py), no LDS, CTA or cluster exchange, and the kernel that writes the final rows writes it with them: - the NVFP4 wave tile, in every output mode and on query-split tiles: under the MXFP8 output each wave merges output tiles 2 w, 2 w + 1 instead of w, w + 4, so a group is a lane pair. Cluster merges of any size, clusters shared by several sequences and the last-arriver merge take 8 lanes a group, with no extra cluster barrier; - the reducer (pa_decode_reduce_kernel_*_mxfp8[only]), for any K/V and with sinks: 16 lanes a group with pairs. Its FP8 and scale pointers take the sink pointer's kernel argument, so that every argument still preloads; a kernel with sinks takes its sink pointer last, past the preloaded bytes, where its load overlaps the XCD remap. It runs the XCD-contiguous grid (a token's scale row written by CTAs spread over the XCDs cost 2.7 us at 512 rows). FP8 and BF16 K/V tiles have no MXFP8 epilogue, so with this output their plans take the reducer. The tile builder states what quant_mx needs once, in compile_gfx1250_pa_decode. Padded rows of plans whose kernel has no padding CTAs (last-arriver merge, shared clusters, reducer) are filled after the launch. Kernels compiled without the MXFP8 output keep their ISA. The NVFP4 cases of op_tests/test_flydsl_pa_decode.py (sinks, sliding windows and query splits included) and the FP8/BF16 cases with a quantized output (one V layout and scale mode of each) now also check the MXFP8 output bit for bit against a torch group-32 quant of the same call's output, eagerly and in graph replays. test_pa_decode_reduce_split_groups runs its split rungs and dual-mode reducers with the MXFP8 output as well. Co-Authored-By: Claude Fable 5.2 <[email protected]>
2c7d748 to
9e559ca
Compare
| parallel_groups: int = 1, | ||
| num_xcds: int = 0, | ||
| quant_mx: bool = False, | ||
| store_output: bool = True, |
There was a problem hiding this comment.
Use argment output_dtype replace two arguments
There was a problem hiding this comment.
Changed in b5f687d7: quant_mx is now quant_dtype (None or "mxfp8"), the argument the tile takes too. Kernel symbols and ISA are unchanged.
It sits next to output_dtype_str instead of being one of its values because output_dtype_str stays the dtype of the BF16/FP16 rows: the MXFP8 bytes are those rows quantized, so the kernel rounds to that dtype first even when it skips their store.
store_output stays because one launch writes both the BF16/FP16 rows and the MXFP8 rows by default, as pa_decode's per-token output does, and store_output=False drops only the float store. That is three states, one more than a single dtype can name.
| cluster_merge=0, | ||
| quant_output=False, | ||
| store_output=True, | ||
| quant_mx=False, |
There was a problem hiding this comment.
Same change in b5f687d7: quant_output and quant_mx are one quant_dtype (None, "fp8" for the per-token output, "mxfp8") in _pa_decode_tile_kernel_name, compile_pa_decode_tile and gfx1250_tile_traits. Gfx1250Traits derives quant_output / quant_mx from it, so the kernel code and the _quant[only] / _mxfp8[only] symbols are untouched. store_output is main's flag, kept for the reason given on the reducer.
The tile's compile arguments quant_output and quant_mx become one format tag, quant_dtype (None, "fp8" for the per-token output, "mxfp8"), in compile_pa_decode_tile, gfx1250_tile_traits, the kernel-name builder and Gfx1250Traits, which derives quant_output and quant_mx from it. The reducer takes the same argument in place of quant_mx. store_output stays: by default a launch writes the BF16/FP16 rows and the quantized rows, and False drops only the float store. No kernel changes: symbols and ISA are the same. A tag the builders do not know is refused, and so is a reducer asked to skip the store without a quantized output (it built a kernel that stores nothing). On gfx942 and gfx950 a quantized tile is refused as before; quant_mx=True alone, which they ignored and gfx1250 refused, can no longer be written. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Adds pa_sparse_prefill_nvfp4_v3, a gfx1250 NVFP4 sparse-prefill attention kernel for MiniMax-M3.1's block-sparse prefill (16 query heads a KV head, head_dim 128, 128-token NVFP4 pages, top-16 pages a token), next to #8459's v1/v2. v2 splits a page's 128 tokens over a CTA's four waves, so every wave holds every row's softmax state and output, and a tile stops at two rows. v3 takes 8 consecutive rows of one KV head per CTA, and each wave owns two of them, walking every token of its rows' pages. The tile's union of pages is built once; per row that is 3.0-3.5 union pages instead of v2's 8.8-9.4. Pages go to one of two phases: - Phase A: pages all waves select. They go through a CTA ring, with one tensor DMA a page and wave and one barrier a page. V is dequantized once a CTA into a shared buffer. - Phase B: the rest. They go through wave-private quarter rings: no barrier, DMA descriptors built in SALU, and a K/V plane pair in one 2-D tensor DMA. The rest of the design: - Rows are paired over the waves by their phase-B pages. - Walk metadata is read a step ahead. - PV takes FP16 operands, with a lazy softmax rebase. - The union is built from hashed first-entry tables, representative masks and branch-free list stores. Dead chunks are skipped, and its barriers fence LDS only. - Query rows load at the kernel start, and the epilogue is spill-free. - An optional MXFP8 output (o_proj's input, bit for bit the separate group-32 quant) sits behind a constexpr. The M3.1 build (tq8, nvfp4_buffers 3): 336 VGPRs, 0 spills, LDS 99,888 B, 3 CTAs a WGP. The module stands alone. It imports only pa_decode's NVFP4 modules and utils, and carries its own copies of the v1/v2 geometry constants and page-step helpers. Callers use compile_pa_sparse_prefill_nvfp4_v3 directly; its launch takes #8459's compile_pa_sparse_prefill_nvfp4 arguments (listed in its docstring). It needs #8365's pa_decode NVFP4 modules and nothing from #8459. On MI455X it wins from about 1536 v3 CTAs up, and smaller grids should stay on v2 at tile_rows 2. MI455X, FlyDSL 0.5.3, vs #8459's v2 at tile_rows 2 (the current M3.1 call): the 8 M3.1 prefill chunks run at a geomean of 1.446x (982 -> 1419 TFLOPS), and the guard shapes v3 serves (pick swaps, TP4 one KV head, 4K-token small T) run 1.28-1.39x. Error vs FP32 is no worse than v2's: relative L2 0.94x on the large cases, max abs error at most 1.10x, MXFP8 bit-exact. Co-Authored-By: Claude Opus 5.5 <[email protected]>
NVFP4 K/V (packed e2m1, one E4M3 scale per 16 values, token-major per (page, KV head): [128, 64] payload and [128, 8] scale bytes) for the gfx1250 FlyDSL pa_decode, selected by key/value scales of dtype float8_e4m3fn. Gfx1250Nvfp4WavePipeline serves tiles of one query tile (<= 16 rows, M3.1 TP4 decode, MTP and prefill rows): each wave owns 32 tokens of every page and DMAs them itself, QK is v_wmma_scale16_f32_16x16x128_f8f6f4 straight from the raw K rows and their E4M3 scales (the query split into FP8 terms exact to 2^-21 of a 16-dim block's maximum), V is dequantized and transposed by the same instruction with a constant selector, and softmax and P stay in registers, so the page loop has no CTA barrier. Direct, last-arriver, cluster and reducer outputs and the FP8 output epilogue are supported. v_wmma_scale16 misreads 64-bit scale operands that come from an inline constant or an SGPR pair on gfx1250; every selector scale is ORed with a lane-varying zero so it stays in a VGPR pair. Co-Authored-By: Claude Opus 5.5 <[email protected]> (Carried in #8819 without op_tests/test_flydsl_pa_decode_nvfp4.py; that test is in #8365.)
…t_scale) MiniMax-M3.1's MXFP4 checkpoint runs o_proj as a native MXFP8 GEMM (gemm_a8w8_mx32: E4M3 activations, one E8M0 scale per 32 along K). Each of the 57 sparse layers stored the PA's BF16 output and quantized it in a separate kernel (ATOM quantize_fp8: 2.4 us decode, 7.2 us prefill a layer). The per-token quantized_output (one FP32 descale a token) does not fit it. An E8M0 output_scale [rows, H * D / 32] (dtypes.fp8_e8m0 or uint8) now selects that output in pa_decode: FP8 bytes in the output's layout and row-major scales, bit for bit the BF16/FP16 output of the same call quantized as the split path did: code = ceil_pow2(max(amax, 1e-10) / 448) (emit_mx_e8m0_scale RoundUp), values e4m3(clamp(x * 2^(127 - code), +-448)) after rounding to the output dtype. Padded bucket rows are FP8 zeros with E8M0 1.0. A float32 [rows, 1] scale keeps the per-token output unchanged. A 32-element group lies in one head row, so its maximum takes lane shuffles only (kernels/pa_decode/op_mxfp8.py), no LDS, CTA or cluster exchange, and the plan's split is kept in every output mode: - NVFP4 wave tile: under the MXFP8 output each wave merges output tiles 2 w, 2 w + 1 instead of w, w + 4 (dims 32 w + [0, 32)), so a group is a lane pair; direct rows, single-task rows of merging plans, empty and padded rows (Gfx1250OutputMxQuant); - cluster merges of any size, clusters shared by several sequences, and the last-arriver merge: 8 lanes a group, no extra cluster barrier; - the reducer (pa_decode_reduce_kernel_*_mxfp8[only]): 16 lanes a group with pairs; its FP8 / scale pointers take the unused sink slot so every argument still preloads, and it runs the XCD-contiguous grid: a token's 64-byte scale row written by 16 CTAs spread over the XCDs cost 2.7 us at 512 rows, nothing with the token's CTAs on one XCD. Other tiles (FP8, BF16) take the reducer path and its epilogue. Padded rows of plans whose kernel has no padding CTAs (last-arriver merge, shared clusters, reducer) are filled after the launch. No sinks. gfx1250 compile, no spills, no extra LDS: wave direct 212 VGPR, cluster 2/4/8 and merges 210, reducer np3/8/32 9/14/53 (as BF16). The existing tile and reducer kernels (NVFP4 wave direct, cluster2 shared, cluster8, merge, reducer-fed; per-token quant direct/cluster8; FP8 page16 direct and cluster8 quant; reducer np3/8/32) compile to byte-identical ISA. op_tests/test_flydsl_pa_decode_nvfp4.py: test_pa_decode_nvfp4_mxfp8_output (direct prefill/decode, cluster8 c4/c24, cluster4, shared clusters 2 x4, 3 x4 and 8 x2, last-arriver merge, reducer np8; bf16/fp16; kept or skipped BF16 store; padded and empty rows) against a torch reference and a copy of the split quant kernel, and a __main__ benchmark (fused vs split vs BF16). Co-Authored-By: Claude Opus 5.5 <[email protected]> (Carried in #8819 without op_tests/test_flydsl_pa_decode_nvfp4.py; that test is in #8365.)
Adds pa_sparse_prefill_nvfp4_v3, a gfx1250 NVFP4 sparse-prefill attention kernel for MiniMax-M3.1's block-sparse prefill (16 query heads a KV head, head_dim 128, 128-token NVFP4 pages, top-16 pages a token), next to #8459's v1/v2. v2 splits a page's 128 tokens over a CTA's four waves, so every wave holds every row's softmax state and output, and a tile stops at two rows. v3 takes 8 consecutive rows of one KV head per CTA, and each wave owns two of them, walking every token of its rows' pages. The tile's union of pages is built once; per row that is 3.0-3.5 union pages instead of v2's 8.8-9.4. Pages go to one of two phases: - Phase A: pages all waves select. They go through a CTA ring, with one tensor DMA a page and wave and one barrier a page. V is dequantized once a CTA into a shared buffer. - Phase B: the rest. They go through wave-private quarter rings: no barrier, DMA descriptors built in SALU, and a K/V plane pair in one 2-D tensor DMA. The rest of the design: - Rows are paired over the waves by their phase-B pages. - Walk metadata is read a step ahead. - PV takes FP16 operands, with a lazy softmax rebase. - The union is built from hashed first-entry tables, representative masks and branch-free list stores. Dead chunks are skipped, and its barriers fence LDS only. - Query rows load at the kernel start, and the epilogue is spill-free. - An optional MXFP8 output (o_proj's input, bit for bit the separate group-32 quant) sits behind a constexpr. The M3.1 build (tq8, nvfp4_buffers 3): 336 VGPRs, 0 spills, LDS 99,888 B, 3 CTAs a WGP. The module stands alone. It imports only pa_decode's NVFP4 modules and utils, and carries its own copies of the v1/v2 geometry constants and page-step helpers. Callers use compile_pa_sparse_prefill_nvfp4_v3 directly; its launch takes #8459's compile_pa_sparse_prefill_nvfp4 arguments (listed in its docstring). It needs #8365's pa_decode NVFP4 modules and nothing from #8459. On MI455X it wins from about 1536 v3 CTAs up, and smaller grids should stay on v2 at tile_rows 2. MI455X, FlyDSL 0.5.3, vs #8459's v2 at tile_rows 2 (the current M3.1 call): the 8 M3.1 prefill chunks run at a geomean of 1.446x (982 -> 1419 TFLOPS), and the guard shapes v3 serves (pick swaps, TP4 one KV head, 4K-token small T) run 1.28-1.39x. Error vs FP32 is no worse than v2's: relative L2 0.94x on the large cases, max abs error at most 1.10x, MXFP8 bit-exact. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The NVFP4 PA decode carried from #8365 has its tests in op_tests/test_flydsl_pa_decode_nvfp4.py, which this PR leaves to #8365. Some of those cases move here so the NVFP4 path still runs in this PR's tests: - test_pa_decode_nvfp4: M3.1 TP4 rows over compacted top-16 tables with NaN-poisoned tail bytes, against an FP32 reference and through the recorded-launch path. Cases: decode c4, MTP8 c64 cluster8, one-partition direct, last-arriver merge, reducer, FP16 query, two KV heads (GQA 8), and the fp4x2 payload view. - test_pa_decode_nvfp4_mxfp8_output: the fused MXFP8 output equals the group-32 quant of the same call's BF16 output. Modes: direct, cluster8, merge and the reducer, each with the BF16 store and quant-only. Padded rows are FP8 zeros with E8M0 1.0 scales. The helpers are copied from #8365's test with an _nvfp4_ prefix. The cases run on gfx1250 only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
pa_decodeon gfx1250 can now write MXFP8 output: OCP E4M3 values in the output's layout, plus one E8M0 scale per 32 consecutive elements of a token's[heads * head_dim]row, stored row-major as[tokens, heads * head_dim / 32]. That is the activation pair a native MXFP8 GEMM (gemm_a8w8_mx32) reads. An E8M0output_scale(dtypes.fp8_e8m0or uint8) selects this output; a float32[rows, 1]scale keeps the existing per-token output, unchanged.The bytes match, bit for bit, the BF16/FP16 output of the same call quantized the way the split path does (ATOM
quantize_fp8):Padded bucket rows (
quantized_pad_rows) are FP8 zeros with E8M0 1.0 scales.A 32-element group lies inside one head row, so its amax needs only lane shuffles (
kernels/pa_decode/op_mxfp8.py): no LDS, no CTA barrier and no cluster barrier. Whichever kernel writes the final rows writes the MXFP8 output, so the plan's split is kept:2w, 2w+1instead ofw, w+4, so a group is one lane pairpa_decode_reduce_kernel_*_mxfp8[only], 16 lanes per group; the FP8 and scale pointers take the sink slot, so without sinks every argument still preloads, and with sinks the sink pointer becomes a trailing argument; the XCD-contiguous grid keeps a token's scale row in one L2 (+2.7 µs at 512 rows otherwise)The FP8 and BF16 K/V tiles have no MXFP8 epilogue (there a group spans two waves, or a lane holds several groups), so with an E8M0 scale their plans take the reducer instead of the tile's direct or cluster output. Pad rows are filled after the launch in the modes whose kernel launches no padding CTAs (last-arriver merge, shared clusters, reducer).
Why
MiniMax-M3.1's MXFP4 checkpoint runs
o_projas a native MXFP8 GEMM. Today each sparse layer stores the PA's BF16 output and then runs a separate group-32 quant kernel. The per-tokenquantized_outputwrites one FP32 descale per token, which a group-32 E8M0 GEMM cannot consume.MI455X, this branch, NVFP4 K/V with top-16 × 128 tokens, GQA16, D128, bf16,
run_perftest, µs, median of 3 runs. "split" = PA BF16 followed by the group-32 quant. In every row the fused FP8 bytes and scales equal the split path's.The fused output saves 2.0–4.4 µs per call against the split path and costs at most 0.6 µs over BF16 alone.
The NVFP4 MXFP8 kernels of 2c7d748 (this revision before the rebase onto main, with the same PA sources) compile to the same ISA as the ones measured; the routes added since (sinks, FP8/BF16 K/V through the reducer, query-split tiles) are not benchmarked.
Testing
op_tests/test_flydsl_pa_decode.py(MI455X):test_pa_decode_nvfp4case (34) also checks the MXFP8 output bit for bit against a torch group-32 quant of the same call's output, with the BF16 store kept and skipped, padded and empty rows, in graph replay, and asserts which kernel writes it: the tile in every mode but the reducer one (8 cases on query-split tiles), the reducer in 7 cases (4 with sinks).test_pa_decode(decode, cluster, shared cluster, step and run clusters, D64/D256/D1024, MTP) andtest_pa_decode_quant_empty_long_querygain the same check through the reducer.test_pa_decode_reduce_split_groupsreruns every (partitions, split) with the MXFP8 epilogue into poisoned buffers: 48 reducers (register rungs np 24/32, dual mode np 64/256, D 64–512, 17 with sinks).[rows, 1]shape.Not covered
pa_decode-level cases reach the XCD grid at up to 8 partitions.ci:gfx1250-ffm-tritoninffm-bringup.yaml, whose shard 0 runs this test file) requireshead.repo.full_name == github.repository, so it is skipped for this fork PR even with the label.ATOM_MINIMAX_M3_PA_MXFP8_OUT=1).Open question
Should the E8M0
output_scaledtype select the MXFP8 output (as here), or shouldpa_decodetake an explicitquant_dtype=argument, as the compile functions do? The dtype is unambiguous (FP32[rows, 1]versus E8M0[rows, H*D/32]) and adds no keyword.PR Self-Review
Reviewed revision
b5f687d
Behavior and intent
output_scalehas an E8M0/uint8 dtype. Calls withoutquantized_output, and per-token FP32 calls, follow the same dispatch as before and compile to the same kernels.quantized_outputwrites one FP32 descale per token, which a group-32 E8M0 GEMM such as MiniMax-M3.1's MXFP8o_projcannot consume, so today the BF16 output is stored and then quantized by a separate kernel (2.0–4.4 µs per call in the table above).batch * (rows * kv_heads)^2 <= 2^30. Reducers without MXFP8 keep their signature and ISA.launch_pa_decode_ps_reduce's compiled launcher always takes two extra pointer arguments (null when unused); the direct reducer launch in the test passes them.quant_dtype(None,"fp8"for the per-token output,"mxfp8"), replacesquant_outputand this PR'squant_mxincompile_pa_decode_tile,gfx1250_tile_traitsand the kernel-name builder, andquant_mxincompile_pa_decode_ps_reduce.Gfx1250Traitsderivesquant_output/quant_mxfrom it, so the kernel code is untouched, and symbols and ISA are the same. This renames main'squant_outputcompile argument;pa_decode's signature is unchanged.store_outputstays a separate flag: by default one launch writes the BF16/FP16 rows and the quantized rows, andFalsedrops only the float store. An unknown tag is refused. The reducer accepts only"mxfp8", and now refuses a skipped store without a quantized output, which used to build a kernel that stores nothing. gfx942/gfx950 refuse a quantized tile as before.pa_decodeandcompile_pa_decode_tileare gone (one builder guard remains); the dedicated MXFP8 reducer kernel variant is merged into the generic one.Validation and unverified scope
op_tests/test_gemm_a4w4.pyfails to compile a Triton kernel in CI), plus thequant_dtypecommit (b5f687d). Nothing was re-run on a GPU after the rebase or for that commit: the GPU results below are 2c7d748's.COMPILE_ONLY=1 FLYDSL_COMPILE_ARCH=gfx1250 FLYDSL_DEBUG_DUMP_ASM=1): all 161 kernels of the sets below are byte-identical to 2c7d748's, symbols included: 39 tile kernels and 12 gfx1250 reducers without MXFP8, 3 + 3 reducers for gfx950 / gfx942, 38 MXFP8 tile kernels, 18 MXFP8 reducers and the 48 MXFP8 reducers of the reducer test.pa_decodedry runs (170 for the NVFP4 cases, 36 for FP8/BF16 K/V on gfx1250, 12 + 12 host logic only for gfx950 / gfx942) carry the same arguments as at 2c7d748 oncequant_output/quant_mxare read asquant_dtype; 14 refusal checks aroundquant_dtyperaise as described above;python3 -m pytest --collect-onlyfinds the same 578 tests.python3 -m pytest -q op_tests/test_flydsl_pa_decode.py, MI455X (gfx1250), one GPU, imagerocm/fw-bringup:gfx1250-minimax-m3-20261112with the tree mounted, 2c7d748: 404 passed, 174 skipped in 324 s (another job started on the same GPUs during the run). Same command on [FlyDSL] gfx1250 pa_decode: NVFP4 K/V on a wave-owned scaled-WMMA tile #8289's head a906e3e: 403 passed, 174 skipped in 279 s; on main bf59948: 368 passed, 174 skipped.-k nvfp435 passed and-k reduce_split_groups6 passed on an idle GPU;-k "quant_empty_long_query or e8m0"2 passed.COMPILE_ONLY=1 FLYDSL_COMPILE_ARCH=gfx1250 FLYDSL_DEBUG_DUMP_ASM=1, 2c7d748): 39 tile kernels and 12 gfx1250 reducers without MXFP8 byte-identical to a906e3e; 17 MXFP8 tile kernels and 12 MXFP8 reducers byte-identical to 35491d4 (symbol tag aside); 21 new MXFP8 tile kernels (208–244 VGPRs) and the new MXFP8 reducers compile with no spills and no scratch.pa_decode(validation, plan, tile selection, compile and launch-argument marshalling, nothing launched) for the 34 NVFP4 cases with an E8M0 scale: the tile writes the MXFP8 output in 27 and the reducer in 7; FP8/BF16 calls without the MXFP8 output select the same kernels as on [FlyDSL] gfx1250 pa_decode: NVFP4 K/V on a wave-owned scaled-WMMA tile #8289.run_perftest, this PR's earlier__main__benchmark kept outside the tree) on MI455X: the table above is the median of 3 runs on a2a59ff08, whose NVFP4 MXFP8 kernels compile to the same ISA as 2c7d748's; not re-run.quant_dtypecommit changes run only on gfx1250 and were not run (a CPU self-test that drives_check_quant_outputwith faked launches passes); performance of FP8/BF16 K/V through the reducer, of sinks with MXFP8 and of the query-split tiles; the XCD-grid MXFP8 reducers above 8 partitions (compiled only); end-to-end serving and accuracy with the MXFP8o_projinput (ATOMATOM_MINIMAX_M3_PA_MXFP8_OUT=1); gfx942/gfx950, which refuse the MXFP8 output and skip these cases (their reducers without MXFP8 keep the same kernels; the launcher passes two more null pointers there, which only CI on those cards exercises); and no CI job runs these cases on gfx1250, because theci:gfx1250-ffm-tritonjob is skipped for fork PRs (ffm-bringup.yamlrequireshead.repo.full_name == github.repository).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?
test_pa_decode_nvfp4case, in 28 FP8/BF16test_pa_decodecases and intest_pa_decode_quant_empty_long_query(_check_quant_outputwithmx, reference_mxfp8_quant): before this PR ([FlyDSL] gfx1250 pa_decode: NVFP4 K/V on a wave-owned scaled-WMMA tile #8289's head) the first MXFP8 call raisesValueError, becausepa_decodeonly accepts an FP32output_scaleof shape[rows, 1], so every one of these cases fails. No existing test covers it: the file's existing FP8-output checks cover only the per-token FP32 descale, and no test callspa_decodewith an E8M0[rows, H*D/32]scale or has a group-32 reference.test_pa_decode_reduce_split_groups, MXFP8 reruns: before this PRcompile_pa_decode_ps_reducehas noquant_dtypeargument, so the rerun raisesTypeError. The existing assertions of that test are unchanged; its direct launch passes two more null pointers because the compiled launcher takes them.test_pa_decode[...e8m0-row-output-scale]: before this PR an E8M0[rows, 1]scale raisesTypeError("output_scale must be float32") instead of theValueErrornaming the[rows, H*D/32]shape. No existing invalid case passes an E8M0 scale.Changed op tests
op_tests/test_flydsl_pa_decode.py(this PR's commit on top of [FlyDSL] gfx1250 pa_decode: NVFP4 K/V on a wave-owned scaled-WMMA tile #8289, which adds the NVFP4 cases):_check_quant_outputtakes anmxcase flag (E8M0 scale tensor, the group-32 reference_mxfp8_quant, E8M0 1.0 pad check, the assertion of which kernel writes the MXFP8 output), and the NVFP4 cases, 28 FP8/BF16 cases and the empty-long-query case run it after the per-token check: store kept and skipped, padded and empty rows, graph replay.test_pa_decode_reduce_split_groupsgains the MXFP8 reruns of its 48 reducers. It extends the file's existing checker and cases instead of adding a parallel suite, and it is the only test ofpa_decode's MXFP8 output; this file is the canonicalpa_decodetest that CI collects with pytest.