Repository navigation
[FlyDSL] feat(flydsl): fuse sparse PA output quantization - #7401
Conversation
Reverts 4c56e4d and 15777c9 (ROCm#7401). Exclusive single-GPU A/B: the fused PA is 7-13% slower than PA plus the standalone quant at decode rows 4/16/64 and prefill rows 2517/4536; the epilogue costs more than the kernel it removes. See wuhuikx/LLM-Booster#393 (issuecomment-6622356568). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reverts fff6a74 (ROCm#2949), the ATOM side of the F4 fusion whose aiter kernel (ROCm/aiter#7401) is removed from the integration stack: in an exclusive single-GPU A/B the fused PA is 7-13% slower than PA plus the standalone quant. Keeps F5: the sparse attention still passes the registered AR alias (out=) to o_proj and exposes supports_out. Drops the F4 unit test, including the F4+F5 alias case added with F5. See wuhuikx/LLM-Booster#393 (issuecomment-6622356568). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Closing after exclusive single-GPU A/B failed the performance gate. Fused PA quant is 7-13% slower than base PA + standalone quant across decode rows 4/16/64 and prefill rows 2517/4536; correctness is bitwise, but the fused epilogue costs more than the kernel it removes. Evidence: wuhuikx/LLM-Booster#393 issuecomment-6622356568. Removed from integration. |
2c8902d to
3499407
Compare
Reverts fff6a74 (ROCm#2949), the ATOM side of the F4 fusion whose aiter kernel (ROCm/aiter#7401) is removed from the integration stack: in an exclusive single-GPU A/B the fused PA is 7-13% slower than PA plus the standalone quant. Keeps F5: the sparse attention still passes the registered AR alias (out=) to o_proj and exposes supports_out. Drops the F4 unit test, including the F4+F5 alias case added with F5. See wuhuikx/LLM-Booster#393 (issuecomment-6622356568). Co-Authored-By: Claude Opus 5.5 <[email protected]>
3733697 to
ddd2ed0
Compare
dd64ed8 to
990e750
Compare
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (5)
- Comment the raw
cvt_pk_fp8_f32call, or reuse the shared helper.aiter/ops/flydsl/kernels/pa_decode/op_merge.py:463(_store_fp8). The FlyDSL AGENTS.md rule requires a comment at each rawrocdlcall naming the missing typed API. The nearby comment only describes the saturation. Either add the same notefp8_quant_gfx1201.py:184carries (no typed packed-FP8 conversion in FlyDSL), or extendkernels/quant_utils.py:emit_f32_to_fp8with the old-word/word_selarguments and call it here. - Reconcile the perf evidence with your own Nov 4 close comment. That comment says an exclusive single-GPU A/B found the fused PA quant 7-13% slower at the same rows 4/16/64/2517/4536. The table now shows 23-27% faster. In the description, name the commit that changed the result (presumably
083bb8bd2f, quant from registers) and confirm the new numbers come from the same exclusive back-to-back A/B at this head. - Answer the aiter-bot PR Self-Review. It is still WAITING ON AUTHOR. The description lacks
Reviewed revision(3b3b556),Behavior and intent,Validation and unverified scope,PR-specific questionandChanged op tests. - Give CI something to run. Every new check sits behind
case["quant"] and arch == "gfx1250"(op_tests/test_flydsl_pa_decode.py:2025). CI is MI35X only, so none of this PR's code runs in CI. Add a gfx942/gfx950 case that assertspa_decode(..., quantized_output=..., output_scale=...)raisesNotImplementedError(aiter/ops/flydsl/pa_decode.py:804). Also state in the description that gfx1250 coverage is manual only (251 passed on MI455X). - Fix two inaccurate messages.
op_merge.py:418and:561say the first partition'spmaxentry of a row is read only by its owner wave. In fact the padding rows of other waves, clamped tot.rows - 1atop_merge.py:310-311, also load it before the cluster barrier. The result is harmless because those rows are discarded, but the comment should say so.pa_decode.py:839says "contiguous query/output tensors", but the check also coversquantized_output.
Reviewed at 3b3b556. Earlier asks already fixed: the new test file is folded into test_flydsl_pa_decode.py, and the fused condition is widened to any GQA, D, page size and MTP (fsx950223).
fsx950223
left a comment
There was a problem hiding this comment.
Reviewed exact head 3b3b556 and the complete six-file merge-base diff. No concrete blocking defect was identified. Essential validation remains unavailable: the fused epilogue targets gfx1250, which is not configured, and the targeted gfx950 regression attempt stopped at import because the container has FlyDSL 0.4.0 while this commit requires ≥0.5.0. MI35X CI passed the existing PA suite, but the new quantization assertions are gated to gfx1250. Independent gfx1250 correctness, graph replay, and targeted performance validation are needed before approval.
Validation:
- PASS on
local:git -C checkout rev-parse HEAD; parse all six changed Python files with ast.parse
HEAD matched the supplied SHA; all changed files parsed successfully. Evidence saved in local-validation.log. - FAIL on
dzm-mi355-gpu34-dev / allocation 9581 / fsx950223_pr_review_gfx950:srun --overlap --jobid=9581 --ntasks=1 --cpus-per-task=1 podman exec -i fsx950223_pr_review_gfx950 flock -w 30 /workspace/gpu.lock bash -s < remote-test.sh
Verified gfx950 and idle devices, then used an isolated exact-head source archive and AITER compilation directory. Import exited 1: Unsupportedflydslversion: expected >=0.5.0, got0.4.0. The planned timeout 240 python3 -m pytest -q op_tests/test_flydsl_pa_decode.py -k 'test_pa_decode and bf16-decode' did not execute. Logs: gfx950-env.log, gpu-activity.log, gfx950-test.log. - PASS on
hjbog-srdc-39.amd.com / sixifang_dev:docker exec sixifang_dev python3 -c 'import torch,flydsl; print(torch.cuda.get_device_properties(0).gcnArchName); print(flydsl.__version__,flydsl.__file__)'
Verified gfx942 and FlyDSL 0.4.0 inside the container. Log saved in gfx942-env.log. - SKIP on
gfx942 / gfx1250:Targeted PA correctness and output-quantization tests
gfx942 has the same unsupported FlyDSL dependency and cannot validate the gfx1250 fused implementation. No gfx1250 test environment is configured.
Remaining validation:
- The author's reported 251 passing gfx1250 tests and performance measurements were not independently reproduced.
- CI logs show the PA suite passed on MI35X; new output-quantization assertions did not run on that architecture. Detailed CI and review evidence are preserved in the task directory.
- The gfx950 architecture-rejection check and unchanged-path GPU regression remain unexecuted because the exact-head import failed. No global dependencies were upgraded.
Automated Codex review of commit 3b3b5566633f.
fsx950223
left a comment
There was a problem hiding this comment.
Reviewed exact head 3b3b556 and the complete six-file merge-base diff. Found an unwritten output-scale tail for empty sequences with MTP lengths above 128. Independent gfx1250 validation remains unavailable.
[P2] Write all empty-sequence scales when query_length exceeds 128 — aiter/ops/flydsl/kernels/pa_decode/op_merge.py:626
store_empty writes at most one scale per thread, but BLOCK_THREADS is 128 and tokens is the unrestricted query_length when zero_output handles an empty sequence. For example, gfx1250 BF16 KV, GQA 1, head_dim 64, page size 16, query_length=129, max_partitions=1 and context lengths [129, 0] select the fused direct path. The empty sequence's final scale is never written, although its FP8 values are written. A scale buffer poisoned with NaN therefore leaves the last token's descale NaN, causing downstream dequantization or o_proj to produce NaNs instead of an inert output. Use a block-strided loop for scale stores and cover an empty sequence with query_length > BLOCK_THREADS.
Validation:
- PASS on
local:git -C checkout rev-parse HEAD; parse all six changed Python files with ast.parse
HEAD matched the supplied SHA; all six files parsed. Saved in head-sha.txt and local-validation.log. - PASS on
local:AST inspection and enumeration of store_empty scale writers for BLOCK_THREADS=128 and tokens=129
Confirmed the final guard is tid < tokens with one store per thread; scale row 128 has no writer. Source-level reproduction saved in empty-scale-repro.log and review-notes.txt. - FAIL on
dzm-mi355-gpu34-dev / allocation 9589 / fsx950223_pr_review_gfx950:srun --overlap --jobid=9589 --ntasks=1 --cpus-per-task=1 podman exec -i fsx950223_pr_review_gfx950 flock -w 30 /workspace/gpu.lock bash -s < remote-import.sh
Verified gfx950 inside the container. Isolated exact-head source and JIT cache were used. Import resolved to that source but exited 1: expected FlyDSL >=0.5.0, got 0.4.0. The targeted pytest command did not execute. Log: gfx950-import.log. - PASS on
hjbog-srdc-39.amd.com / sixifang_dev:docker exec sixifang_dev python3 -c 'import torch,flydsl; print(torch.cuda.get_device_properties(0).gcnArchName); print(flydsl.__version__,flydsl.__file__)'
Verified gfx942 and FlyDSL 0.4.0 inside the container. Log: gfx942-env.log. - SKIP on
gfx942 / gfx950 / gfx1250:Targeted PA correctness, architecture rejection, fused quantization and graph-replay tests
Configured hosts lack the required FlyDSL version; no gfx1250 environment is configured. No GPU correctness or performance result is claimed.
Remaining validation:
- The reported defect is established by source-level bounds analysis; it was not reproduced on gfx1250 hardware.
- The author's reported gfx1250 correctness and performance results were not independently reproduced.
- CI metadata shows failing MI35X test shards. Read-only log requests returned empty logs, so their causes could not be attributed to this diff. New quantization assertions are gated to gfx1250.
- Remote setup retries encountered archive permission errors and a missing amdsmi activity-probe dependency; detailed logs are preserved in the task directory.
Automated Codex review of commit 3b3b5566633f.
pa_decode gains optional quantized_output / output_scale (OCP FP8 plus one FP32 descale per token), store_output and quantized_pad_rows. On gfx1250 with one KV head, the one-partition direct output and cluster merges write the FP8 output from the final values in registers; other plans write BF16 and run the standalone per-token quant. Rebased onto main after ROCm#7619 as one commit. The epilogue now also covers step-split (cluster_steps) and run-split (cluster_runs) clusters and the reversed direct-output order; clusters shared by several sequences (cluster_seqs > 1) fall back to the standalone quant. Squashes the PR's commits 5d72374..3b3b556: - feat(flydsl): fuse sparse PA output quantization - test(flydsl): cover production PA plan capacity - perf(flydsl): quantize sparse PA output from registers - fix(flydsl): fall back to the standalone quant for other PA output modes - perf(flydsl): write a padded bucket's FP8 rows in the sparse PA quant launch - refactor(flydsl): share the cluster sync and a thread's token slice in the PA quant epilogue - test(flydsl): run the sparse PA FP8 output test from CI, time it, and trim it - refactor(flydsl): fold the FP8 output tensors into pa_decode's existing checks - feat(flydsl): widen the fused PA FP8 output to any GQA, D, page and MTP - test(flydsl): fold the PA FP8 output test into test_flydsl_pa_decode.py Co-Authored-By: Claude Opus 5.5 <[email protected]>
The spilling BF16 D1024/GQA16/MTP4/page128 tile kept query_splits=1 when the FP8 output was requested, so its direct output could quantize in the epilogue. It now keeps its measured four-way query split, and pa_decode quantizes after the output with the standalone per-token kernel whenever the selected tile splits its query rows. With FP8 output on one MI455X, that is 1679 -> 295 us at one sequence of 2048 tokens and 9122 -> 1576 us at four of 8192. The pa_decode docstring now states exactly when the epilogue quantizes: one KV head, no query split, and the one-partition direct output or a cluster merge with one sequence per cluster. It also states that the fallback writes the padded rows after the standalone quant. The stride check that the contiguity check implies is removed. The test runs cluster2-shared with the FP8 output, and adds the D1024 shape. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MiniMax-M3's sparse attention wrote a BF16 output that o_proj then quantized to per-token FP8 in a launch of its own, once per sparse layer and step. With ROCm/aiter#7401 FlyDSL's pa_decode can write that FP8 output and its FP32 descales itself (fused into its direct and eight-CTA cluster merges, after the merge otherwise), skip the BF16 store, and write rows past the queries as FP8 zeros with a unit descale. - MiniMaxM3SparseAttention hands o_proj the PA's FP8 rows and descales (Attention.forward_quantized -> unified_attention_with_output_quant_base) when o_proj consumes per-token FP8, checked at forward because online quantization re-quantizes o_proj at load. - The gate needs gfx1250, ATOM_PA_FLYDSL, one KV head, GQA16, head_dim 128, ATOM's own Attention outside Ulysses SP (whose head exchange runs in forward), a non-MXFP4 KV cache, and an aiter pa_decode that takes all four kwargs (_flydsl_output_quant_api). Otherwise nothing changes: the PA writes BF16 and o_proj quantizes it. - sparse_pa_per_row never takes ASM for it; prefill rows with a split other than eight run one partition per token (the fused direct kernel), decode rows keep their split. The rows the sparse impl pads past its metadata (a DP step) are the PA's inert pad rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (3)
- Get the MI35X Standard Tests green at this head. All 8 shards at
45b6c77failed before any test ran: Docker Hub returnedtoomanyrequests: You have reached your unauthenticated pull rate limit. This is not caused by the PR, but these shards are the only CI that runs the new gfx942/gfx950NotImplementedErrorcheck, so they need a green rerun. - Drop the
inspect.signaturefilter in_check_quant_output.op_tests/test_flydsl_pa_decode.py:2295-2306filters the compile kwargs throughinspect.signature(gfx1250_tile_traits)and repeats the fused predicate fromaiter/ops/flydsl/pa_decode.py:1201-1205. Put the predicate in one small helper inpa_decode.py(num KV heads, one-partition direct orcluster_seqs == 1cluster,query_splits == 1). Call it from the host dispatch and from the test, and removeimport inspect. Then the test cannot drift from the dispatch, and nothing is filtered silently. - Clear the aiter-bot self-review check. The section is now in the description at
45b6c77(thanks), but the bot still reportsFAIL — validation answer must explicitly state what remains unverified. Reword the second paragraph of### Validation and unverified scopeso it starts "Remains unverified: gfx942/gfx950 …, multi-GPU and end-to-end runs (#7869), gfx1250 in CI (no runner)".
Nits:
- The
_check_quant_outputdocstring (test_flydsl_pa_decode.py:2288-2290) leaves out thecluster_seqs == 1condition. - No test covers the new argument errors at
pa_decode.py:600-617: only one ofquantized_output/output_scale,store_output=Falsewithout them, and a negative or boolquantized_pad_rows, or pad rows without the FP8 output. These could be a few_INVALID_CASESentries.
Re-reviewed at 45b6c77. Already fixed: the pa_decode docstring now matches the dispatch (one KV head, no query split, one-partition direct or cluster_seqs == 1), and the fallback's pad-row fill is documented; the query-split D1024/G16/MTP4 tile now falls back to the split tile + standalone quant instead of forcing query_splits=1 (pa_decode.py:1204, new head1024-mtp4-g16-page128 quant case); cluster2-shared is tagged quant; the redundant stride check is removed; the description names eb8bd718; earlier: cvt_pk_fp8_f32 comment, perf reconciliation, gfx942/gfx950 refusal test, pmax/contiguity messages, empty-sequence descales (fsx950223 P2).
… the test pa_decode now decides with one helper, fuses_quant_output, whether the gfx1250 tile quantizes the FP8 output in its epilogue: one KV head, the one-partition direct output or a cluster merge with cluster_seqs == 1, and no query split. The host dispatch and _check_quant_output both call it, so the test no longer repeats the predicate or filters the compile arguments through inspect.signature. The dispatch is unchanged. The BF16 invalid-input cases now also cover the FP8 output's argument errors: an output_scale without quantized_output, store_output=False without the FP8 output, a negative or bool quantized_pad_rows, and pad rows without the FP8 output. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MiniMax-M3's sparse attention wrote a BF16 output, which a per-token FP8 o_proj then quantized in a launch of its own. With ROCm/aiter#7401, FlyDSL's pa_decode writes the FP8 rows and their FP32 descales itself. `Attention.per_token_fp8_out`, which already hands o_proj an `(out, scale)` pair under Ulysses SP, now also covers an impl whose kernel writes that pair (`supports_output_quant`, False on the base impl), through the new op `unified_attention_fp8`. The sparse impl sets it on a GPU without gluon (its sparse PA is FlyDSL's on every call), over an FP8 KV cache and with one KV head per rank. The PA skips the BF16 store and writes rows past the queries as FP8 zeros with a unit descale. The plan stays as it was; aiter picks the fused epilogue where that plan allows and quantizes after the merge elsewhere, with the same bytes. Needs aiter with #7401: ATOM calls its kwargs without probing for them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
-
Get the MI35X Standard Tests green at
d410eb6. Attempt 1 of "Aiter Test" at this head was cancelled during the wheel build, so the Test Gate failed and aiter-bot still says NOT READY. Attempt 2 is running, but all 8 MI35X shards are still queued. These shards are the only CI that runs the new gfx942/gfx950NotImplementedErrorcheck and the new_INVALID_CASESentries, so they must pass before merge. -
Make the fused-path assertion independent of
fuses_quant_output. Sharing the predicate between the dispatch (aiter/ops/flydsl/pa_decode.py:1218) and the test fixed theinspect.signaturefilter (thanks). Two problems remain:_check_quant_output(op_tests/test_flydsl_pa_decode.py:2316-2328) rebuildstile_optionsby deleting a hand-written list of seven compile kwargs. That list is a second copy of howpa_decode.py:1236-1251builds them.:2362then checks that the dispatch'squant_outputequalsfuses_quant_outputon the same inputs. That always holds, so the check is tautological. If a plan falls back when it should fuse, the bytes stay identical and nothing fails. That is the silent perf regression this assertion exists to catch.
Fix: pin the path in the case, as
_check_pipe_policy(:1831) already does forcluster/cluster_steps: e.g."quant": "fused"or"quant": "fallback". Assertcompile_kwargs[-1].get("quant_output", False) == (case["quant"] == "fused"), and delete the reconstruction. Iffuses_quant_outputis then used only by the dispatch, make it private (_fuses_quant_output).
Nits (non-blocking):
- The FP8 shapes in
pa_decode.py:478-479(same shape/strides as output,[num_seqs * query_length, 1]) and in the docstring at:513-516leave out thequantized_pad_rowsextra rows that:865-884requires. - The
store_emptydocstring (kernels/pa_decode/op_merge.py:611-614) says "FP8 zeros". With descale 0, an empty sequence gets0xFEbytes, as the description says, not zeros. _INVALID_CASEScoversoutput_scalewithoutquantized_output(scale-only), but not the reverse (quantized_outputwithoutoutput_scale).
Re-reviewed at d410eb6. Already fixed: the inspect.signature filter and the hand-copied predicate are gone, and the dispatch and test now share fuses_quant_output (dispatch unchanged: one_partition_output == direct_output and num_partitions == 1, pa_decode.py:1105). aiter-bot accepts the self-review answers ("Remains unverified: ..."). The _check_quant_output docstring names cluster_seqs == 1. Five new _INVALID_CASES cover the new argument errors before compile, on every arch. The branch merges cleanly into current main. Earlier: docstring/dispatch match, query-split fallback, cluster2-shared quant, cvt_pk_fp8_f32 comment, perf reconciliation, gfx942/gfx950 refusal test, pmax/contiguity messages, empty-sequence descales (fsx950223 P2).
The quant tag on each case now names the path the dispatch must take, "fused" or "fallback", and _check_quant_output asserts the launch's quant_output against it. The test no longer rebuilds the tile options or calls the dispatch's predicate, so a plan that stops fusing fails instead of matching itself. The predicate is private to the dispatch again. Also: _INVALID_CASES covers quantized_output without output_scale, the FP8 shape comments and docstring include the quantized_pad_rows rows, and the store_empty docstring states that descale 0 gives 0xFE bytes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fsx950223
left a comment
There was a problem hiding this comment.
Reviewed exact head f19082f and the complete six-file merge-base diff. No new blocking defect was established. The previously reported empty-sequence scale tail is addressed by the block-strided store loop and a query_length=129 regression test. Essential GPU validation remains incomplete: no gfx1250 environment is configured, gfx942 import fails on the installed FlyDSL version, and gfx950 allocation discovery timed out. Independent fused-output correctness, graph replay, and targeted performance validation are still needed before approval.
Validation:
- PASS on
local:git -C checkout rev-parse HEAD; AST-parse all six changed Python files; enumerate empty-scale loop writers for 129 tokens
HEAD matches the supplied SHA; all six files parse; the revised loop covers all 129 scale rows. Logs: head-sha.txt, local-validation.log. - PASS on
hjbog-srdc-39.amd.com / sixifang_dev:docker exec sixifang_dev python3 -c 'import torch,flydsl; print(torch.__version__); print([(i,torch.cuda.get_device_properties(i).gcnArchName) for i in range(torch.cuda.device_count())])'; docker exec sixifang_dev rocm-smi --showuse
Verified gfx942 inside the container; all eight devices reported 0% utilization. Log: gfx942-discovery.log. - FAIL on
hjbog-srdc-39.amd.com / sixifang_dev:docker exec -i sixifang_dev flock -w 30 /tmp/codex-pr-review-7401-20261117-f19082f/gpu.lock bash -s < remote-test.sh
Exact-head source and isolated compilation caches were used with HIP_VISIBLE_DEVICES=0. Import resolution pointed to the intended checkout, but import exited 1: expected FlyDSL >=0.5.0, got 0.4.0. The planned timeout 240 python3 -m pytest -q op_tests/test_flydsl_pa_decode.py -k 'test_pa_decode and bf16-decode' did not execute. Log: gfx942-test.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:22 timed out before allocation discovery. Log: gfx950-discovery.log. - SKIP on
gfx1250:Targeted fused quantization correctness, padded-row, graph-replay, and performance tests
No configured gfx1250 test environment is available. The author's reported MI455X results were not independently reproduced.
Remaining validation:
- No GPU correctness test completed on this revision; gfx942/gfx950 cannot validate the gfx1250 fused epilogue.
- CI metadata showed successful and failed MI35X shards with the workflow still in progress. Retrieved shard logs do not establish completion of the changed PA suite or gfx1250 coverage.
- Detailed source, review feedback, CI evidence, commands, and test logs are preserved in the task directory.
Automated Codex review of commit f19082f60c39.
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (1)
- Re-run the failed "Aiter Test" and "OPUS Test" jobs at
f19082f. Five of the eight MI35X Standard Tests shards (1, 2, 3, 4, 6) and OPUS Tests (MI35X) died before any test ran. Docker Hub returnedtoomanyrequests(unauthenticated pull rate limit, exit 125). This is infra, not this PR. The shard that runsop_tests/test_flydsl_pa_decode.py(shard 5) passed: 452 passed, 39 skipped. That run includes the gfx942/gfx950NotImplementedErrorcheck and the new_INVALID_CASES. The Aiter Test Gate is still red, so aiter-bot reports NOT READY and the merge is blocked until a re-run goes green.
Nit (non-blocking):
aiter/ops/flydsl/pa_decode.py:525says clusters are shared at "more than 15 sequences per 16 CUs". The trigger at:1120isceil(num_seqs / cluster_seqs) * num_kv_heads > CUs * 15 // 16, so it counts sequences times KV heads. Suggested wording: "more than 15 sequence-KV-head pairs per 16 CUs".
@fsx950223: your CHANGES_REQUESTED review (@3b3b556) is still standing. Its P2 (descales of an empty sequence longer than a CTA) is fixed in op_merge.py and covered by test_pa_decode_quant_empty_long_query. Please re-review.
Re-reviewed at f19082f. Already fixed: each quant case now pins "quant": "fused" / "fallback", and _check_quant_output asserts quant_output == (case["quant"] == "fused") with no tile-option reconstruction. Each pin matches the dispatch: kv_heads 2, the budget-1 last-arriver merge, cluster_seqs == 2 and the D1024 query split fall back; direct and cluster_seqs == 1 cluster plans fuse. The predicate is now private _fuses_quant_output. The FP8 shape comments and docstring name quantized_pad_rows. The store_empty docstring now says 0xFE for descale 0 and FP8 zeros for descale 1. The new fp8-only invalid case raises before compile on every arch. Earlier: shared predicate, inspect.signature removed, self-review answers, docstring/dispatch match, query-split fallback, cluster2-shared, refusal test, empty-sequence descales.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Replies to the re-reviews since 54500a2. The head is now 3758a8b. Re-review at 54500a2 → 45b6c77
Re-review at 45b6c77 → d410eb6
Re-review at d410eb6 → f19082f
MI455X: Re-review at f19082f → 3758a8b
|
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (3)
- Re-run the seven failed MI35X Standard Tests shards at
3758a8b. Shards 0 and 2–7 of run 43998817059 stopped at the Docker Hubtoomanyrequestspull limit (exit 125) before any test ran. This is infra, not the PR. Only shard 1 ran to the end, and it does not includeop_tests/test_flydsl_pa_decode.py, so the gfx942/gfx950 refusal check has not run at this head. Its last pass was shard 5 atf19082f(452 passed). The Aiter Test Gate is red and aiter-bot reports NOT READY. OPUS Tests now pass. - Keep the quant-unit width in one place.
math.gcd(query_group_size, 16)is written twice:traits.py:1675(LDS size intotal_bytes) andop_merge.py:436(Gfx1250OutputQuant.unit). These two must agree, or the LDS reservation and the quant layout drift apart. Add aquant_unitproperty next toquant_offset(traits.py:1667) and use it in both places. That also letsop_merge.pydrop its newimport math. - Cover the new FP8 shape and dtype guards in
_INVALID_CASES.pa_decode.py:866-888rejects a wrongquantized_outputshape or dtype and a wrongoutput_scaleshape or dtype. None of these four checks is tested, while the argument-combination checks next to them are. Add one case for each, for example a missing pad row, BF16quantized_output, a[rows]scale, and an FP16 scale. Each must raise before compile.
@fsx950223: your CHANGES_REQUESTED review (@3b3b556) still blocks the PR. Your COMMENTED review at f19082f found no new blocking defect, and the P2 empty-sequence descale issue is fixed (op_merge.py store_empty, test_pa_decode_quant_empty_long_query). Please re-review or dismiss it.
Re-reviewed at 3758a8b (full diff). Already fixed: the pa_decode.py:525 note now says "more than 15 sequence-KV-head pairs per 16 CUs", which matches the trigger at :1121. Earlier rounds: per-case "quant": "fused"/"fallback" pins with a non-tautological assertion; private _fuses_quant_output; quantized_pad_rows shape docs; store_empty 0xFE/zeros docstring; fp8-only invalid case; shared predicate; inspect.signature removed; self-review; D1024 query-split fallback; cluster2-shared; refusal test; empty-sequence descales. No API probing in the diff.
Add PaDecodeTraits.quant_unit, the gcd(GQA, 16)-row group that shares one FP8 output scale, and use it both for the LDS maxima in total_bytes and in Gfx1250OutputQuant, so the reservation and the layout cannot drift apart. Cover the gfx1250 quantized_output and output_scale shape and dtype checks in _INVALID_CASES: a missing pad row, a BF16 quantized_output, a [rows] output_scale and an FP16 output_scale each raise before compilation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks. Addressed in c4152a4:
MI455X: |
valarLip
left a comment
There was a problem hiding this comment.
⚠️ Action required before merge (2)
- Fix the new
quant_unitcomment: it is not the scale group.traits.py:1675says "Rows sharing one FP8 output scale group". But one scale covers a whole token (query_group_sizerows), andgcd(GQA, 16)is the number of rows behind one LDS partial maximum. The two differ for any GQA that is not a divisor of 16: GQA 12 → unit 4, GQA 32 → unit 16. Suggested wording: "Rows behind one per-wave LDS maximum (a token isquery_group_size // quant_unitof them); sizes the maxima region atquant_offset." - Name the padding unit in the cluster-grid comment.
pa_decode_kernel.py:1317says "One cluster per P padded FP8 rows", butPis defined nowhere. The code below it pads in units oft.cluster_merge, so write that name in the comment instead ofP.
Both items are comment-only and non-blocking. Everything else checks out at this head: CI is green (all 8 MI35X Standard shards and OPUS; test_flydsl_pa_decode.py passed in shard 5), aiter-bot reports READY FOR HUMAN REVIEW, and the PR merges cleanly into current main.
Re-reviewed at c4152a4 (full diff). Already fixed: the quant-unit width now has one definition, Gfx1250Traits.quant_unit, used by total_bytes and Gfx1250OutputQuant.unit, and op_merge.py no longer imports math. The four FP8 operand guards (pa_decode.py:870-888) now have _INVALID_CASES (fp8-missing-pad-row, bf16-quantized-output, rows-output-scale, fp16-output-scale); each reaches its own guard before compile and runs on gfx1250 only. The MI35X CI re-run is green. Earlier rounds: :525 wording; fused/fallback pins; private _fuses_quant_output; pad-row docs; store_empty docstring; fp8-only case; shared predicate; inspect.signature removed; self-review; D1024 query-split fallback; cluster2-shared; refusal test; empty-sequence descales (fsx950223's P2). No API probing in the diff.
quant_unit is the row count behind one per-wave LDS maximum, not the FP8 scale group; the padded cluster grid pads in t.cluster_merge rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @valarLip. Both comment fixes are in
Comment-only: the AST of both files is identical to |
valarLip
left a comment
There was a problem hiding this comment.
✅ LGTM
Both comment nits from the last round are fixed in 5c68d29, and that commit touches nothing else (2 files, comment lines only). The quant_unit comment (traits.py:1675-1677) now describes the rows behind one per-wave LDS maximum, which matches op_merge.py store_cta indexing and total_bytes. The cluster-grid comment (pa_decode_kernel.py:1317-1318) now names t.cluster_merge, which matches grid_x = (sequences + ceil(pads / cluster_merge)) * cluster_merge and one pad row per CTA. A full re-review of the whole diff found nothing else to change. The PR still merges cleanly into current main.
CI: the code is byte-identical to c4152a4, where all 8 MI35X Standard shards and OPUS passed. The re-run at this head is still queued (wheel build); merge waits on it as usual.
Re-reviewed at 5c68d29 (full diff). Already fixed: quant_unit comment, undefined P in the cluster-grid comment (this round); single Gfx1250Traits.quant_unit, _INVALID_CASES for the four FP8 operand guards, MI35X re-run (r35); and all earlier asks (:525 wording, fused/fallback pins, private _fuses_quant_output, pad-row docs, store_empty docstring, fp8-only case, shared predicate, inspect.signature removed, D1024 query-split fallback, cluster2-shared, refusal test, empty-sequence descales). No API probing in the diff.
Conflicts with #7401 (fused FP8 output quantization): - pa_decode_kernel.py: the gfx1250 tile body is main's (quant_output, pad_output, pad_grid) under the fused-task branch, with the MXFP4 plan-free task and pipeline dispatch re-applied. - traits.py: main's quant_output/store_output precede the PR's plan_free and fuse_tasks; MXFP4 keeps its own LDS size. - MXFP4 tiles refuse quant_output (pa_decode already does), and the positional MXFP4 gfx1250 launch passes the new quantized_output, output_scale and quant_rows arguments. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MiniMax-M3's sparse attention wrote a BF16 output, which a per-token FP8 o_proj then quantized in a launch of its own. With ROCm/aiter#7401, FlyDSL's pa_decode writes the FP8 rows and their FP32 descales itself. `Attention.per_token_fp8_out`, which already hands o_proj an `(out, scale)` pair under Ulysses SP, now also covers an impl whose kernel writes that pair (`supports_output_quant`, False on the base impl), through the new op `unified_attention_fp8`. The sparse impl sets it on a GPU without gluon (its sparse PA is FlyDSL's on every call), over an FP8 KV cache and with one KV head per rank. The PA skips the BF16 store and writes rows past the queries as FP8 zeros with a unit descale. The plan stays as it was; aiter picks the fused epilogue where that plan allows and quantizes after the merge elsewhere, with the same bytes. Needs aiter with #7401: ATOM calls its kwargs without probing for them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* perf(minimax-m3): let the sparse PA write o_proj's per-token FP8 input MiniMax-M3's sparse attention wrote a BF16 output, which a per-token FP8 o_proj then quantized in a launch of its own. With ROCm/aiter#7401, FlyDSL's pa_decode writes the FP8 rows and their FP32 descales itself. `Attention.per_token_fp8_out`, which already hands o_proj an `(out, scale)` pair under Ulysses SP, now also covers an impl whose kernel writes that pair (`supports_output_quant`, False on the base impl), through the new op `unified_attention_fp8`. The sparse impl sets it on a GPU without gluon (its sparse PA is FlyDSL's on every call), over an FP8 KV cache and with one KV head per rank. The PA skips the BF16 store and writes rows past the queries as FP8 zeros with a unit descale. The plan stays as it was; aiter picks the fused epilogue where that plan allows and quantizes after the merge elsewhere, with the same bytes. Needs aiter with #7401: ATOM calls its kwargs without probing for them. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(minimax-m3): give the FP8-output sparse PA a plan budget of six workgroups per CU With aiter's default budget, two workgroups per CU, a sparse PA call whose rows x split pass it gets fewer partitions than the split asks for and a slower merge, which for the FP8 output also quantizes in a launch of its own. Six per CU keeps the split. One MI455X, FP8 KV, 2048-token windows, us per call (median of 7, interleaved, CUDA graphs), default -> six per CU: decode rows 72 9.12 -> 6.08, 96 9.85 -> 8.12, 160 11.43 -> 8.35, 240 14.45 -> 11.11, 384 22.16 -> 14.84; within 1% at 1-64 and 128 rows. This replaces the earlier forced plans (one partition per prefill row, one cluster of eight per decode row up to 240 rows): those were 18-23% slower than aiter's own plan at 1-16 decode rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(minimax-m3): correct the FP8-output comments; tighten the pad-row tests The sparse prefill/decode comments said the FP8 path writes no BF16. The BF16 `output` is still allocated and only fixes the layout; on plans aiter cannot fuse, pa_decode writes a BF16 intermediate and then runs the standalone quant. Say so. Tests: the FP8 case of the row-rule test fills `quantized_output` with a sentinel, so the zero pad rows must come from the PA call. The GPU bitwise test runs the FP8 output through the decode/prefill entry points, so the prefill pad rows are checked on the GPU too. `_attention_fp8_fake` is now `attention_fp8_fake`: two ops share it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(minimax-m3): name the FP8-output budget and the tested entry points Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(minimax-m3): pin the gate that turns the FP8 attention output on Build Attention.__init__ with a stub impl and check per_token_fp8_out: without SP it follows the caller's request and the impl's supports_output_quant; under SP it follows the head exchange and ignores the impl. Reverting the gate to the SP-only formula fails this test. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(minimax-m3): keep the feature-off attention calls as on main A layer without the FP8 output now makes exactly the calls it made before: - PagedAttentionImpl.forward passes the FP8 output pair to forward_impl only through its **kwargs, and forward_impl keeps the plain 8-argument backend call when there is no pair. - run_pa_decode checks the pair inside its FlyDSL branch and binds it there, so the FlyDSL call keeps its plain argument list; the guard refusing an FP8 output before gluon stays. Its three new parameters sit before the `*`: a missing keyword-only default costs CPython a dict lookup on every call. Docs: the FP8-output sparse PA is native ATOM only, without Ulysses SP; the vLLM/SGLang bridges never take it. Docstrings name `unified_attention_fp8` and the optional pair in the dispatch_backend contract. Tests pin that the backend and FlyDSL get no extra kwargs without the pair. Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(minimax-m3): give the FP8 attention output entries of its own Without an FP8 output, every call now runs main's code: `PagedAttentionImpl.forward`, `run_pa_decode`, `sparse_pa_per_row` and both sparse asm wrappers are main's again. - `unified_attention_fp8` calls `impl.forward_impl` with the pair directly, so `forward` needs no `if kwargs:`. - The sparse PA writing FP8 is `sparse_pa_fp8_per_row`, FlyDSL only: it plans with the FP8 budget and calls aiter's `pa_decode` with the pair, as the MXFP4 sparse PA calls FlyDSL itself. `_sparse_decode` / `_sparse_prefill` branch once on the pair and otherwise call the asm wrapper as on main. `run_pa_decode` loses its three slots, the FlyDSL-side bind and the gluon-side guard (dead: the pair exists only on GPUs without gluon). - Drop the FP4-KV `NotImplementedError` (the gate admits an FP8 KV only) and ATOM's pair check (aiter validates the pair). Co-Authored-By: Claude Opus 5.5 <[email protected]> * perf(minimax-m3): read the FP8 plan budget after the captured-plan return; run the tests on CPU CI - `_flydsl_prepare_explicit_plan` reads the workgroup budget after the `existing_plan` early return, so a captured dense plan pays nothing for it. - `_sparse_decode` / `_sparse_prefill` branch on the FP8 output first: it gets `torch.empty_like(q[:rows])` as its layout, and the BF16 output and its pad-row memset are allocated only on the other branches, as before. - `sparse_pa_fp8_per_row`: say when aiter fuses the quant into the PA launch and when it stores BF16, then quantizes and fills the pad rows after. - docs: the FP8 budget's larger decode-plan scratch. - tests: load the modules under `atom_without_aiter` so the CPU CI lane runs the file; a sentinel FP8 buffer for the dummy run; the call-site walks cover `sparse_pa_fp8_per_row` in decode and prefill. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: lirui927 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Consumer: ROCm/ATOM#2949 (MiniMax-M3 sparse attention passes the FP8 output and scale straight to
o_proj).What this PR does
MiniMax-M3's sparse attention output feeds an FP8
o_proj. Today that takes two launches:pa_decodewrites BF16, anddynamic_per_token_scaled_quantreads it back to produce FP8 plus a per-token scale. With this PR, the gfx1250 FlyDSL sparse PA writes the FP8 output itself, from the final values in registers.pa_decodegains two optional arguments:quantized_output(OCP FP8, same layout asoutput) andoutput_scale(FP32[tokens, 1]).cluster_seqs == 1), including the step-split and run-split clusters from [FlyDSL] gfx1250 PA decode: wider page-local softmax steps, shared clusters and wave-pair MTP4 for MiniMax-M3 #7619.zero_()/fill_(1.0)after the quant.store_output=Falseskips the BF16 store.quantized_pad_rows=Nwrites the N rows past the real tokens as FP8 zeros with descale 1.0, so a token-grapho_projover the padded bucket reads inert rows. The fused epilogue writes them in the PA launch, so it needs no fill launches.Benefit
Workload: MiniMax-M3 sparse attention. GQA 16, head_dim 128, page 16, one KV head, FP8 KV and BF16 query. Decode rows have 2048 selected tokens. In direct prefill, row i has min(i + 1, 2048).
Hardware and method: one MI455X (gfx1250), exclusive, in the
rocm/fw-bringup:gfx1250-minimax-m3-20261112image with FlyDSL 0.5.0. Each variant is captured as a CUDA graph of 50 calls, and the three variants are interleaved back to back over 9 repeats. Values are the median per call in µs, with [min-max] across repeats. Measured at 54500a2. The later commits change only the D1024/GQA16/MTP4 dispatch, tests and comments, not these shapes.Baseline:
pa_decodefollowed bydynamic_per_token_scaled_quant.In every row the fused path selected the fused epilogue, and its FP8 bytes and descales matched PA + quant bit for bit. Decode, where the removed launch is a large share of the time, gains 22-33%. Prefill is within noise: -1% to -3% with FP8 only, +1% to +2% with BF16 kept. The descale exchange costs about what the removed quant kernel did there. The win is mainly the one launch fewer per layer in the prefill token graph, plus the padded-row fills. These prefill rows use a heavier length profile than the earlier description's table, so the absolute times are not comparable with it.
The 7-13% slowdown in the Nov 4 close comment was measured with the first epilogue. That version re-read the BF16 output from global memory and synced three times. The register epilogue measured here, now part of eb8bd71, replaced it.
The query-split BF16 D1024/GQA16/MTP4/page128 tile is not fused on purpose. Unsplit, it spills: with FP8 output, PA + quant on the split tile takes 295-1576 µs, against 1679-9122 µs for the fused unsplit tile (5.8x; 1-64 sequences at 2048 tokens and 4 at 8192, one MI455X, interleaved CUDA graphs).
Testing
On MI455X (gfx1250):
python3 -m pytest -q op_tests/test_flydsl_pa_decode.py: 336 passed, 159 skipped (the skips are arch-gated cases such as gfx950-only MXFP4). gfx1250 coverage is manual only, because CI is MI35X.test_pa_decodecases taggedquantrun the FP8 output. They cover:cluster2-shared) and the query-split D1024 tile (head1024-mtp4-g16-page128).store_output=False;test_pa_decode_quant_empty_long_query: an empty sequence with query_length 129 (BF16 KV, GQA 1, D256, direct path) writes all of its descales. It fails without the fix.pa_decoderefuses, before any kernel compiles: only one ofquantized_output/output_scale,store_output=Falsewithout the FP8 output, a negative or boolquantized_pad_rows, pad rows without the FP8 output, and (gfx1250) aquantized_outputmissing its pad row, a BF16quantized_output, a[rows]output_scaleand an FP16output_scale.NotImplementedError. This check was not run here, because no gfx950 GPU was available.Not covered
PR Self-Review
Reviewed revision
5c68d29
Behavior and intent
On gfx1250,
pa_decodegains an optional per-token FP8 output (quantized_output,output_scale,store_output,quantized_pad_rows) for MiniMax-M3's FP8o_proj. Before, this took PA plus a separatedynamic_per_token_scaled_quantlaunch that read the BF16 output back. The output is quantized in the tile epilogue when there is one KV head, the tile has no query split, and the plan writes the one-partition direct output or a cluster merge withcluster_seqs == 1. Other plans fall back to PA + the standalone quant. Both paths give the same bytes. Calls without the new arguments are unchanged; gfx942/gfx950 raiseNotImplementedErrorfor them.Validation and unverified scope
Validated on one MI455X (gfx1250) in
rocm/fw-bringup:gfx1250-minimax-m3-20261112:python3 -m pytest -q op_tests/test_flydsl_pa_decode.py, 336 passed, 159 skipped. Perf: see Benefit (decode -22..-33%, prefill within noise).Remains unverified: gfx942/gfx950 (the refusal check runs only in MI35X CI), multi-GPU and end-to-end runs (#7869), gfx1250 in CI (no runner).
PR-specific question
What would the changed op test fail on before this PR, and why does no existing test cover it? Before this PR,
pa_decodehas noquantized_output/output_scale, so every quant-tagged case fails on the call. That covers the M3 decode and cluster shapes, the fallbacks (multi-KV-head, last-arriver,cluster2-shared,head1024-mtp4-g16-page128) andtest_pa_decode_quant_empty_long_query. On gfx942/gfx950, the case that expectsNotImplementedErrorfails for the same reason. No existing canonical test checks a fused PA FP8 output againstdynamic_per_token_scaled_quant, because the feature is new.Changed op tests
op_tests/test_flydsl_pa_decode.py: this is the canonical PA decode test. The FP8 output is added there rather than in a new file.quanttags on existing cases, such as the M3 cluster8/cluster16 step splits andcluster2-shared, and on one new short case,head1024-mtp4-g16-page128, run_check_quant_output. Each tag pins the expected path,"fused"or"fallback", the waycluster/cluster_stepspin the pipe policy. It checks the FP8 bytes and scales against PA + quant bit for bit, the BF16 store or its skip, the padded rows, that the dispatch takes the pinned path (so a plan that silently stops fusing fails), and graph replay.test_pa_decode_quant_empty_long_querycovers the descales of an empty sequence longer than a CTA. That failed before the fix._INVALID_CASESentries cover the new argument errors, including either FP8 tensor without the other and a wrong shape or dtype ofquantized_outputoroutput_scale. On gfx942/gfx950 the same cases check that the FP8 output is refused. No existing test covers the FP8 output, because the feature is new.