Skip to content

[FlyDSL] gfx1250 pa_decode: NVFP4 K/V on a wave-owned scaled-WMMA tile - #8289

Closed
lirui927 wants to merge 3 commits into
ROCm:mainfrom
lirui927:lirui/gfx1250-nvfp4-pa
Closed

lirui927 wants to merge 3 commits into
ROCm:mainfrom
lirui927:lirui/gfx1250-nvfp4-pa

Conversation

@lirui927

@lirui927 lirui927 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this does

Adds NVFP4 K/V to the gfx1250 FlyDSL pa_decode. The format is packed e2m1 with one E4M3 scale per 16 values, stored token-major per (page, KV head) as [128, 64] payload bytes and [128, 8] scale bytes. Passing key_scale/value_scale of dtype torch.float8_e4m3fn together with a uint8/fp4x2 cache selects it. This is the layout of the MiniMax-M3.1 NVFP4 sparse KV pool (ROCm/ATOM#2744), whose checkpoint is QAT-trained for an NVFP4 KV cache.

A new tile, Gfx1250Nvfp4WavePipeline (pa_decode/pipeline_nvfp4.py), runs at most 16 query rows a CTA. That covers M3.1 TP4 decode, DSpark verify and prefill rows, since the sparse path flattens tokens to one row each. Longer queries split their positions evenly over up to 8 CTAs.

  • Each wave owns 32 tokens of every page and DMAs its own payload and scale rows into a private 3-page ring. The page loop has no CTA barrier and no LDS exchange.
  • QK is v_wmma_scale16_f32_16x16x128_f8f6f4 directly on the raw e2m1 K rows and their E4M3 scales, so K is never widened. The query is split into FP8 terms (two for BF16, three for FP16) whose sum is within 2^-21 of each 16-dim block's maximum.
  • V is dequantized and transposed by the same instruction, using a constant selector B operand. The accumulator holds V × scale exactly, in the BF16 PV operand layout after one pack.
  • Online softmax runs per wave, and P stays in registers. The four waves merge once after the loop.
  • Supported: direct, last-arriver merge, cluster merge (incl. shared clusters) and reducer outputs, the FP8 output (quantized_output), sinks, sliding windows, and up to 128 query rows per sequence and KV head (8 CTAs of 16).
  • Refused: head_dim ≠ 128, page ≠ 128, more than 16 query heads per KV head, and query lengths that do not split evenly into at most 8 CTAs of 16 rows.

How it plugs in:

  • One predicate, nvfp4_kv(kv_dtype, kv_scale_dtype), decides the format for pa_decode, compile_pa_decode_tile and gfx1250_tile_traits. NVFP4 is its own compute dtype ("nvfp4") of the gfx1250 tile and goes through the existing gfx1250 compile branch; Gfx1250Traits.bf16 is unchanged.
  • pa_decode validates the caches with its common shape, dtype, device and contiguity checks and the scales with the per-token scale checks (now shared by both scale layouts). The tile's own limits are stated once, in compile_gfx1250_pa_decode.

FP8 and BF16 kernels are unchanged: the gfx1250 ISA of 14 FP8/BF16 tile specializations (page16 and page128; direct, cluster, reducer-fed, FP8 output, sliding window) is byte-identical to main, and the reducer is not touched.

gfx1250 erratum: v_wmma_scale16 misreads 64-bit scales from scalar sources

On MI455X, v_wmma_scale16_f32_16x16x128_f8f6f4 reads its i64 block-scale operands correctly only from VGPRs. A one-wave probe fed the same selector dequantization with the B scale supplied in four ways:

B-scale source max error, blocks 0..7
loaded from memory (VGPR) 0 on all blocks
const | lane-varying zero (VGPR) 0 on all blocks
compile-time constant (inline 56 for block 0, VGPR literal for blocks 1-7) 25.19 on block 0 only
uniform runtime value (SGPR pair) 25.19 on block 0, 10.5–11.25 on blocks 1-7

The tile ORs every selector scale with a lane-varying zero, (lane + context) >> 31, so each scale stays in a VGPR pair (one VALU OR per scale, outside the page loop). Other gfx1250 kernels passing uniform scales to v_wmma_scale* should check their ISA for inline-constant or s[...] scale operands.

Benefit

Kernel time on this branch, MI455X, run_perftest, M3.1 TP4 shape (GQA 16, D128, one KV head), every row attending a full top-16 × 128-token window, median of 3 runs. FP8 is the existing FlyDSL page16 tile with per-token FP8 K/V scales on the same rows and context.

rows NVFP4 (this PR) FlyDSL FP8 page16
4 (c4 decode) 5.03 µs 3.68 µs
32 (c4 MTP8) 5.34 µs 4.64 µs
64 (c64 decode) 6.69 µs 5.25 µs
512 (c64 MTP8) 17.85 µs 23.76 µs (−25%)

NVFP4 halves the KV bytes against FP8 (1.73x KV capacity with the scales), which is what M3.1 serving uses it for; at small batches the kernel is 0.7–1.4 µs slower than FP8 page16.

End to end, MiniMax-M3.1-Flash, TP4 on MI455X, AgentX c64 for 10 min, NVFP4 KV with an FP8 index, measured on an internal stack with this tile, the fused NVFP4 K/V write (companion PR) and the ATOM integration:

FP8 KV NVFP4 KV
throughput / GPU 74,391 tok/s 78,011 tok/s (+4.9%)
interactivity P90 / median 78.5 / 134.5 87.2 / 144.2
prefix-cache hit 94.6% 96.0%

GSM8K: 0.947 with this tile, 0.958 for FP8 KV (about 1.1 combined standard errors apart).

Testing

  • op_tests/test_flydsl_pa_decode.py (extended), run on MI455X:
    • test_pa_decode_nvfp4, 34 cases: plain decode and MTP8 at c4/c64, direct, prefill rows, cluster8, cluster4, last-arriver merge, shared clusters 2×4 / 3×4 / 8×2, reducer, short rows, FP16 query, fp4x2 view, GQA 8 with 2 KV heads, query_length 2 (cluster and, with 2 KV heads, reducer); query positions split over 2, 3, 4, 5 and 8 CTAs (cluster, direct, last-arriver merge, reducer; one with 2 KV heads); sinks (also with a split and with a window); sliding windows (direct, last-arriver merge, split cluster); K/V scale planes interleaved in one buffer. Each checks against the file's fp32 reference over the dequantized cache (empty rows included, never-written tail scales poisoned with NaN), pins the output mode the plan picks (merge cases must split a row over several tasks), and checks the FP8 output bit for bit against the standalone per-token quant of the same call (store and quant-only, padded rows, graph replay).
    • test_pa_decode_nvfp4_rejects: partial scale planes, an unaligned scale plane, 64-token pages, 32 query heads over one KV head. Every input stays in bounds for the tile the call must not reach.
    • Whole file: 403 passed, 174 skipped (main: 368 passed, 174 skipped).
  • ISA: the 15 NVFP4 specializations compared (direct, cluster 2/4/8, shared cluster, last-arriver merge, reducer-fed, FP8 output, FP16 query, GQA 4/8, query_length 2/4) are byte-identical to the previous revision of this PR apart from the symbol tag (kvnvfp4w → kvnvfp4); the new split and window specializations compile without spills or scratch (206–245 VGPRs); the 14 FP8/BF16 tiles are byte-identical to main.
  • black and ruff clean.

Not covered

  • head_dim ≠ 128, page ≠ 128, more than 16 query heads per KV head, more than 8 CTAs per sequence: refused.
  • Planes whose bases, or scale strides, are not multiples of 16 bytes: refused. The tile only needs even addresses (the ISA is the same with a 2-byte alignment promise), but nothing else was run.
  • gfx950 / gfx942: NVFP4 here is gfx1250-only.
  • CI does not run the NVFP4 cases. The default MI35X job skips them (they need gfx1250), and the gfx1250 job (ci:gfx1250-ffm-triton in ffm-bringup.yaml, whose shard 0 runs this test file) requires head.repo.full_name == github.repository, so it is skipped for this fork PR even with the label.
  • The end-to-end and GSM8K numbers come from the internal stack, not re-run on this branch.
  • Performance of the split and window specializations: not measured.

Dependencies

PR Self-Review

Reviewed revision

a99508c

Behavior and intent

New NVFP4 K/V path for gfx1250 pa_decode, selected only when key_scale is float8_e4m3fn and the cache is uint8/fp4x2 (nvfp4_kv). Before this PR every uint8/fp4x2 cache is routed to the MXFP4 path, which raises NotImplementedError("MXFP4 pa_decode supports gfx950") on gfx1250, so the MiniMax-M3.1 NVFP4 KV pool cannot be read there. Existing FP8, BF16, MXFP4 and NHD dispatch is unchanged: NVFP4 is a separate compute dtype in gfx1250_tile_traits, so the FP8/BF16 selection rules do not see it, and FP8/BF16 calls pass the same compile arguments as on main. The per-token scale checks of pa_decode are generalised to serve both scale layouts; their FP8 behaviour is the same, with four reworded messages that no test matches. Cluster selection counts a query-split tile's grid rows; cluster runs are not used for NVFP4. The DMA ring depth is fixed at 3 pages (2/3/4 measured within 1.4%; 4 needs more than 256 VGPRs).

Validation and unverified scope

  • This revision is a906e3e rebased onto main 7c132b8 (on the old base the unrelated op_tests/test_gemm_a4w4.py fails to compile a Triton kernel in CI). The PA sources and the test file are byte-identical to a906e3e, the 39 tile kernels compared compile to the same ISA as before the rebase, and the host dry run below passes. Nothing was re-run on a GPU after the rebase: the GPU results below are a906e3e's. One whole-file attempt on the rebased tree was aborted (Fatal Python error: Aborted, in test_pa_decode's output check of an existing FP8/BF16 case) at the moment another tenant's job started on the GPU, and was not repeated.
  • python3 -m pytest -q op_tests/test_flydsl_pa_decode.py, MI455X (gfx1250), one GPU, image rocm/fw-bringup:gfx1250-minimax-m3-20261112 with the tree mounted, a906e3e: 403 passed, 174 skipped (another job was loading on the same GPUs during this run). -k nvfp4 alone on an idle GPU, a906e3e: 35 passed (test_pa_decode_nvfp4, 34 cases, and test_pa_decode_nvfp4_rejects). The same whole-file command on main bf59948: 368 passed, 174 skipped.
  • Compile-only ISA comparison on a host without a GPU (COMPILE_ONLY=1 FLYDSL_COMPILE_ARCH=gfx1250 FLYDSL_DEBUG_DUMP_ASM=1): at a906e3e, 15 NVFP4 tile specializations byte-identical to 4c523d0 apart from the symbol tag and 14 FP8/BF16 tile specializations byte-identical to main bf59948; this revision, the same 29 and the 10 split/window specializations byte-identical to a906e3e's.
  • Host dry run of pa_decode for the 34 NVFP4 cases and the rejects (validation, plan, tile selection, compile and launch-argument marshalling, nothing launched): the selected output modes equal the ones the GPU run pins.
  • Kernel benchmark (run_perftest, 3 runs, script kept outside the tree) on MI455X: the NVFP4 vs FP8 page16 table above, measured on an earlier revision (a2a59ff08) whose NVFP4 kernels compile to byte-identical ISA; not re-run for this revision.
  • Intermittent failure, not root-caused and not reproduced: one -k nvfp4 run that overlapped another tenant's multi-GPU job on the same GPUs (all four at 100% load, about 390 GB of VRAM each) failed three cases whose kernels and launch arguments are unchanged from 4c523d0: mtp8-c64 (last-arriver merge, 512 rows), shared-cluster3 and shared-cluster8 (clusters shared by several sequences) each had a few wrong, finite rows. Those three modes add only the shared cross-CTA merge code (op_merge.py), which compiles to the same instruction sequences in the FP8 and BF16 kernels. Follow-up on one GPU: these three cases and four neighbours (shared cluster 2×4, cluster8, reducer, direct), as NVFP4 and as BF16 and FP8 K/V over the same plans, with the scratch refilled with NaN before every launch and every output compared bit for bit, gave 0 bad launches in 74,700 (about a third per format): idle, next to a memory-bound load process, next to a process that keeps starting short GPU jobs, and with four such probe processes sharing the GPU. The whole-file run above also overlapped another job's start and passed. The original condition could not be recreated.
  • Unverified: end-to-end serving and accuracy on this branch (the numbers above come from the internal stack); behaviour next to another tenant's job at full load (see the intermittent failure above); performance of the split and window specializations; gfx942/gfx950 only run the existing cases, since NVFP4 is refused there and its tests skip; and no CI job runs the NVFP4 cases on gfx1250, because the ci:gfx1250-ffm-triton job is skipped for fork PRs (ffm-bringup.yaml requires head.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_nvfp4 (34 cases in op_tests/test_flydsl_pa_decode.py): before this PR every case fails at the first pa_decode call, because the uint8 cache is routed to the MXFP4 path, which raises NotImplementedError on gfx1250 (or refuses the query length, sinks or window first). No existing test builds an NVFP4 cache (E4M3 scales per 16 values): the file's FP4 cases are MXFP4 with E8M0 scales per 32 values and run on gfx950 only. The reference is the file's existing _reference.
  • test_pa_decode_nvfp4_rejects: before this PR all four calls raise NotImplementedError("MXFP4 pa_decode supports gfx950") from the MXFP4 path instead of the expected errors and messages. No existing test covers the NVFP4 refusals, since no existing path accepts NVFP4.

Changed op tests

  • op_tests/test_flydsl_pa_decode.py: adds the NVFP4 cache construction (random e2m1 bytes and E4M3 scales, never-written tail scales poisoned with NaN, empty rows, optional sinks, windows and interleaved scale planes) and a 34-case table that pins the output mode (direct, cluster 3/4/8, shared clusters, last-arriver merge, reducer) and runs each case twice (the second call reuses the cached compiled launch). It reuses the file's _reference for the expected output and _check_quant_output for the per-token FP8 output instead of adding a second reference or checker. It is not redundant: no other test calls pa_decode with NVFP4 K/V (op_tests/test_flydsl_sparse_pa_nvfp4.py tests the separate gfx950 sparse_pa_nvfp4_* kernels and their own page layout), and this file is the canonical pa_decode test that CI collects with pytest.

@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 8289 --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.

lirui927 pushed a commit to lirui927/ATOM that referenced this pull request Nov 20, 2026
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]>
lirui927 pushed a commit to XiaobingSuper/aiter that referenced this pull request Nov 23, 2026
…e NVFP4 index cache

aiter.ops.flydsl.index_score_prefill.index_score_prefill_nvfp4: the
MiniMax-M3 prefill indexer's block scores on gfx1250. The index cache is
the NVFP4 one: e2m1 payload [pages, 128, 64] plus an E4M3 scale per 16
values [pages, 128, 8], each with its own page stride.

score[h, r, blk] is the max, over the block's keys at or before row r's
position, of e4m3(clamp(q)) . dequant(K), times sm_scale * log2(e). It is
written exactly where and how the Triton prefill scorer writes it. Every
dot is the 128-deep scaled WMMA (ROCm#8289's _wmma_scale16). Pages arrive by
tensor DMA into an LDS ring (`ring` pages in flight), and operands are read
from LDS 16 B at a time. A CTA scores block_q rows (`waves` waves). With
lds_scores, each row's chunk of at most CHUNK_MAX blocks goes out in one
coalesced store.

index_score_prefill_nvfp4_supported() accepts gfx1250 and the cache shapes
above only.

MI455X, MiniMax-M3.1 TP4 rank, 14336 new tokens on 99968 cached: 97 us
against 172 us for the Triton scorer (score + select + emit 141 vs 216 us),
the scores bit for bit the Triton scorer's. Short prefills (300 rows) are
2-4 us slower, so callers use it from about 2048 rows.

op_tests/test_flydsl_index_score_prefill_nvfp4.py checks it against an
FP32 torch reference (about 2e-3 relative: the WMMA's internal sum is not
FP32-exact), for ragged batches, chunked prefixes and two CTA shapes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lirui927
lirui927 force-pushed the lirui/gfx1250-nvfp4-pa branch from b30e295 to f95c298 Compare November 23, 2026 08:58
@lirui927
lirui927 marked this pull request as ready for review November 23, 2026 08:58
@lirui927
lirui927 requested a review from a team November 23, 2026 08:58
@aiter-bot

aiter-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

DRAFT — evaluation paused

PR Self-Review

Revision a906e3e7c5e3 · mode shadow

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.

@lirui927 lirui927 added the ci:gfx1250-ffm-triton Run gfx1250 FFM tests label Nov 23, 2026
lirui927 pushed a commit to XiaobingSuper/aiter that referenced this pull request Nov 23, 2026
…e NVFP4 index cache

aiter.ops.flydsl.index_score_prefill.index_score_prefill_nvfp4: the
MiniMax-M3 prefill indexer's block scores on gfx1250. The index cache is
the NVFP4 one: e2m1 payload [pages, 128, 64] plus an E4M3 scale per 16
values [pages, 128, 8], each with its own page stride.

score[h, r, blk] is the max, over the block's keys at or before row r's
position, of e4m3(clamp(q)) . dequant(K), times sm_scale * log2(e). It is
written exactly where and how the Triton prefill scorer writes it. Every
dot is the 128-deep scaled WMMA (ROCm#8289's _wmma_scale16). Pages arrive by
tensor DMA into an LDS ring (`ring` pages in flight), and operands are read
from LDS 16 B at a time. A CTA scores block_q rows (`waves` waves). With
lds_scores, each row's chunk of at most CHUNK_MAX blocks goes out in one
coalesced store.

index_score_prefill_nvfp4_supported() accepts gfx1250 and the cache shapes
above only.

MI455X, MiniMax-M3.1 TP4 rank, 14336 new tokens on 99968 cached: 97 us
against 172 us for the Triton scorer (score + select + emit 141 vs 216 us),
the scores bit for bit the Triton scorer's. Short prefills (300 rows) are
2-4 us slower, so callers use it from about 2048 rows.

op_tests/test_flydsl_index_score_prefill_nvfp4.py checks it against an
FP32 torch reference (about 2e-3 relative: the WMMA's internal sum is not
FP32-exact), for ragged batches, chunked prefixes and two CTA shapes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lirui927
lirui927 requested a review from fsx950223 November 24, 2026 04:36

@fsx950223 fsx950223 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.

Reviewed a906e3e, including the complete diff, dispatch and merge helpers, tests, earlier feedback, and CI results. No concrete blocking defect was established. Approval remains pending independent gfx1250 correctness validation of the new NVFP4 pipeline, especially split-query and shared/last-arriver merge modes. The reported intermittent incorrect rows remain unexplained; the author's subsequent stress results are useful evidence but were not independently reproduced.

Validation:

  • PASS on local: git -C source rev-parse HEAD; git -C source diff --check bf5994891 HEAD; Python AST parsing of all six changed files
    HEAD is a906e3e. Diff whitespace checks and Python parsing passed.
  • PASS on hjbog-srdc-39.amd.com / sixifang_dev: HIP_VISIBLE_DEVICES=1 python3 -c 'import torch,flydsl,aiter; ...'
    Verified gfx942:sramecc+:xnack-, FlyDSL 0.5.3 from the task-specific environment, and AITER imports from /tmp/codex-pr-review-8289-a906e3e/source. Details in gfx942-final-tests.log.
  • PASS on hjbog-srdc-39.amd.com / sixifang_dev: PYTHONPATH=$PWD:/tmp/codex-pr-review-8289-a906e3e/venv/lib/python3.12/site-packages HIP_VISIBLE_DEVICES=1 flock -w 30 /tmp/codex-pr-review-8289-a906e3e/gpu.lock timeout 180 python3 -m pytest -q op_tests/test_flydsl_pa_decode.py -k 'nvfp4 or export_import_order or softmax_scale_rejected'
    Exit 0: 9 passed, 35 skipped, 533 deselected in 33.62s. All NVFP4 cases skipped because this device is gfx942. Source and compilation caches were task-specific. Log: gfx942-final-tests.log.
  • FAIL 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; no allocation or GPU tests could be reached. Log: gfx950-access.log.
  • SKIP on gfx1250: python3 -m pytest -q op_tests/test_flydsl_pa_decode.py -k nvfp4
    Neither configured host supports gfx1250. The new NVFP4 kernel was not executed during this review.

Remaining validation:

  • The gfx942 subset validates imports and existing rejection behavior, not NVFP4 numerical correctness, DMA synchronization, or merge behavior on gfx1250.
  • Initial gfx942 collection failed with installed FlyDSL 0.4.0. A task-specific FlyDSL 0.5.3 installation enabled the successful subset without changing global dependencies; setup logs are preserved.
  • The failed current CI shard reports a Triton compilation error in unchanged op_tests/test_gemm_a4w4.py. No evidence attributed that failure to this diff. The shard log is preserved in ci-shard.log.
  • No independent base comparison or performance measurement was performed. Author-reported GPU, ISA, stress, and serving results were treated as supporting evidence rather than tests executed by this reviewer.

Automated Codex review of commit a906e3e7c5e3.

lirui927 and others added 3 commits November 25, 2026 08:23
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]>
lirui927 pushed a commit to XiaobingSuper/aiter that referenced this pull request Nov 25, 2026
…e NVFP4 index cache

aiter.ops.flydsl.index_score_prefill.index_score_prefill_nvfp4: the
MiniMax-M3 prefill indexer's block scores on gfx1250. The index cache is
the NVFP4 one: e2m1 payload [pages, 128, 64] plus an E4M3 scale per 16
values [pages, 128, 8], each with its own page stride.

score[h, r, blk] is the max, over the block's keys at or before row r's
position, of e4m3(clamp(q)) . dequant(K), times sm_scale * log2(e). It is
written exactly where and how the Triton prefill scorer writes it. Every
dot is the 128-deep scaled WMMA (ROCm#8289's _wmma_scale16). Pages arrive by
tensor DMA into an LDS ring (`ring` pages in flight), and operands are read
from LDS 16 B at a time. A CTA scores block_q rows (`waves` waves). With
lds_scores, each row's chunk of at most CHUNK_MAX blocks goes out in one
coalesced store.

index_score_prefill_nvfp4_supported() accepts gfx1250 and the cache shapes
above only.

MI455X, MiniMax-M3.1 TP4 rank, 14336 new tokens on 99968 cached: 97 us
against 172 us for the Triton scorer (score + select + emit 141 vs 216 us),
the scores bit for bit the Triton scorer's. Short prefills (300 rows) are
2-4 us slower, so callers use it from about 2048 rows.

op_tests/test_flydsl_index_score_prefill_nvfp4.py checks it against an
FP32 torch reference (about 2e-3 relative: the WMMA's internal sum is not
FP32-exact), for ragged batches, chunked prefixes and two CTA shapes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zufayu
zufayu removed the request for review from coderfeli November 25, 2026 23:08
@lirui927 lirui927 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:gfx1250-ffm-triton Run gfx1250 FFM tests FlyDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants