Repository navigation
Conversation
…le lookup Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ble lookup Co-Authored-By: Claude Opus 5.5 <[email protected]>
…om context lengths Sequence-indexed grids read context_lengths[seq] alongside reduce_info and split the visible tiles exactly as plan_pa_decode does, instead of chaining reduce_info -> work_info -> block table before the first page DMA. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…A cluster A sequence with more tasks than the cluster has CTAs splits its tiles over the cluster's CTAs, the planner's split for that count. Dense decode at 8K with 32 partition bounds now merges on chip instead of launching the reducer (bs32: 11.0 -> 9.2 us FP8, 14.2 -> 12.3 us BF16). Error against an FP32 reference is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t output Deriving one-partition tasks from context lengths shortened short grids but cost many-row sparse prefill (4096 rows) 1-2.5%; only cluster grids derive their tiles now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
One D128 query tile over page16 caches now stages two pages per wave, so each softmax exchange and its three barriers cover 128 tokens instead of 64. LDS keeps the pages page-major: V is then the 128-token page layout and K operands read each page's 16-token block. MiniMax-M3 FP8 sparse shapes: decode 4/64/128/256 rows 1.18x/1.11x/1.21x/1.26x, verify 1.18x, prefill 1024/4096 rows 1.26x/1.04x. Error against an FP32 reference is unchanged within 1% except 4 rows with e^N(0,1) token magnitudes (5.6e-2 -> 6.3e-2), as P normalizes V scales over 128 tokens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… small grids Each wave stages two BF16 page16 pages, page-major, when the grid needs at most two CTAs per CU; the 128-token stage then halves softmax exchanges. Larger grids (sparse prefill) keep 64-token stages for occupancy. MiniMax-M3 BF16 sparse decode 4/64/128/256 rows 1.17x/1.06x/1.11x/1.13x, verify 1.17x, prefill unchanged; error against FP32 unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
One D128 FP8 query tile over page128 caches stages two pages per step when the grid has at most one CTA per CU, or two per CU with about three or more tiles per CTA. P still normalizes each page by its own V scales: waves 0-1 own page 0's tokens and waves 2-3 page 1's, and the second page's K128 PV is rescaled to the first page's factor, so error against an FP32 reference is unchanged. PV and V-scale reductions take any multiple of 128 tokens, and tail scales loop over the CTA's threads. MiniMax-M3 FP8 dense decode bs1/4/8 at 8K 1.11x/1.17x/1.17x, bs3 220K 1.03x, others unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one-CTA grids With at most one CTA per CU, one D128 BF16 query tile over page128 caches stages two pages per step (each in the one-page LDS layout), halving the softmax exchanges per token. MiniMax-M3 BF16 dense decode bs1/4/8 at 8K 1.06x/1.07x/1.05x; error against FP32 unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one-CTA grids With at most one CTA per CU, each wave stages four BF16 page16 pages per step. BF16 P needs no per-step normalization, so the wider step leaves results within BF16 rounding of the 128-token step. MiniMax-M3 BF16 sparse decode 4 rows 1.05x, verify 12 rows 1.03x, others unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ional Co-Authored-By: Claude Opus 5.5 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Critical multi-page scaling errors in the decode pipeline can overflow otherwise finite outputs and round valid FP8 probability contributions to zero.
2 open issues
What changed in this PR
This follow-up to #7079 optimizes FlyDSL paged-attention decode on gfx1250 for MiniMax-M3 shapes, reducing softmax synchronization and extending in-kernel partition merging.
Changes:
- Widens FP8/BF16 softmax steps according to cache layout and grid size.
- Overlaps query loads with page staging and enables 16-CTA cluster merges for partition bounds up to 32.
- Adds a benchmark that reuses correctness-test inputs and validation.
| File | Description |
|---|---|
op_tests/test_flydsl_pa_decode.py |
Extracts reusable cases and setup for benchmarking. |
op_tests/op_benchmarks/flydsl/bench_pa_decode.py |
Adds case selection, latency measurement, and JSONL reporting. |
aiter/ops/flydsl/pa_decode.py |
Extends cluster dispatch and passes context lengths to cluster kernels. |
aiter/ops/flydsl/kernels/pa_decode/traits.py |
Defines wider-step eligibility and token counts. |
aiter/ops/flydsl/kernels/pa_decode/pipeline.py |
Implements wider softmax steps and earlier query loads. |
aiter/ops/flydsl/kernels/pa_decode/op_lds.py |
Adds multi-page staging and corresponding operand layouts. |
aiter/ops/flydsl/kernels/pa_decode_kernel.py |
Selects grid-dependent policies and redistributes cluster tiles. |
Review effort: Balanced
Two-page FP8 steps (page128 pairs and 128-token page16 steps) quantized P against the whole step's maximum and V factor, and rescaled the second page by the first page's factor. A first half whose logits trail by 14 rounded its P to zero in E4M3, and a V-scale range of 1e40 overflowed the page ratio to inf, where one-page steps gave the reference. Each half (waves 0-1, waves 2-3) now quantizes P with its own maximum and V factor, runs its own PV, and the halves combine in FP32 with weights exp2(m_h - m) * f_h / max(f0, f1), all at most one. The FP8 page16 step stays 64 tokens on grids beyond four CTAs per CU, where the split costs more than the saved exchange. Adds the two review cases as regressions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The new tile-count heuristic negates the optional max_context_length when it is None, causing valid calls that omit it to raise a TypeError instead of retaining the narrower step.
1 open issue
2 resolved since last review
Review effort: Balanced
| wide_pages=grid_ctas <= num_compute_units | ||
| or ( | ||
| grid_ctas <= 2 * num_compute_units | ||
| and num_seqs * -(-max_context_length // KV_COMPUTE_BLOCK) |
gfx1250 keeps 15 clusters resident per 16 CUs, so batches with more than 240 split sequences per KV head fell back to the separate reducer. Such batches now put 2, 4, ... sequences in one cluster of P * k CTAs (up to 16): each sequence still merges its own P partials, every CTA reaches the cluster barrier, and a padded last cluster's CTAs only sync. MiniMax-M3 sparse decode at 256 rows (2 partitions) runs one kernel: FP8 1.11x, BF16 1.12x, bit-identical to the reducer. A 243-row test pins the shared clusters with graph replays; 2000 NaN-poisoned replays match eager. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four FP8 D128 query tiles over page128 caches gave each wave one tile and the whole page, so every wave read all of K and V from LDS. Wave pairs now share two tiles and each wave covers half of every page: each K or V operand feeds two WMMAs (K128 QK, K64 PV), halving LDS reads, and a pair merges its two online-softmax states once through the page buffer the last page left unused. P keeps the page's V normalization; error against an FP32 reference is unchanged within 1%. MiniMax-M3 FP8 verify 3x4 at 8K 1.07x, 214K 1.05x (ATOM-style calls: 1.02x, 1.05x). Co-Authored-By: Claude Opus 5.5 <[email protected]>
| for f in factors | ||
| ] | ||
| half_vnorm = (ctx.warp < 2).select(norms[0], norms[1]) | ||
| half_ratios = (factors[0] * vnorm, factors[1] * vnorm) |
… small grids Double-buffered steps issued a task's second stage only after the first stage landed, so two-step sparse tasks paid two copy latencies in series. On grids with at most one CTA per CU, the prologue now issues both stages and step 0 waits only for its own copies (same-wave TDM copies complete in order; scale copies only accompany whole stages). Fuller grids and page128 pairs keep the old order, where the earlier copy's contention cost more. MiniMax-M3 sparse decode 4 rows: FP8 1.03x, BF16 1.02x; verify 12 rows: FP8 1.05x; outputs bit-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
One-partition plans write output directly from one CTA per sequence. Sparse prefill rows see min(row + 1, 2048) tokens, so in grid order the short rows ran first and the full-length rows formed the last wave. CTAs now take sequences in reverse order. MiniMax-M3 sparse prefill: FP8 1024 rows 1.06x, BF16 4096 rows 1.04x, the others unchanged; bit-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The host selector negates the supported default max_context_length=None for grids between one and two CTAs per CU, causing a TypeError before compilation and requiring a guard with a narrow-schedule fallback.
2 open issues
Review effort: Balanced
fsx950223
left a comment
There was a problem hiding this comment.
Reviewed exact head d129063. Two reproducible correctness regressions remain: extreme per-token V scales can erase a dominant contribution, and omitting an optional context-length bound can crash kernel selection. The targeted gfx950 regression passed, but gfx1250 execution remains unvalidated.
[P2] Preserve contributions when the common-factor ratio underflows — aiter/ops/flydsl/kernels/pa_decode/pipeline.py:1951
For gfx1250 FP8 H16/D128, page128, 256 tokens and one partition, use cached V=1, page logits 0 then 128, and per-token V scales 1e32 then 1e-16. The second half's factor divided by the maximum factor is approximately 1e-48, which rounds to zero in FP32 here. Its softmax weight is one, so the subsequent PV combination discards the dominant half. A scalar reproduction of the head arithmetic returns zero, whereas the narrow-step calculation and reference return approximately 1e-16. Preserve the contribution without materializing an underflowing factor ratio, and add this reversed-logit, extreme-scale case to the regression tests.
[P2] Guard the optional context-length bound in the wide-page heuristic — aiter/ops/flydsl/kernels/pa_decode_kernel.py:289
max_context_length still defaults to None, but this heuristic negates it for grids between one and two CTAs per CU. Calling compile_pa_decode_tile with architecture='gfx1250', head_dim=128, query_group_size=16, block_size=128, num_seqs=32, num_kv_heads=1, num_compute_units=256 and work_capacity=384 while omitting the bound raises TypeError: bad operand type for unary -: 'NoneType'. Executing the same selector with a stubbed GPU compiler succeeds on the merge-base. Guard the estimate when the bound is unavailable and retain the narrower specialization.
Validation:
- PASS on
local:git -C checkout rev-parse HEAD
Verified d129063 in an isolated detached checkout. - PASS on
local:python3 reproduce_scaling.py
Exit 0. Confirmed head scalar output 0.0 versus narrow-step output 1.0000000830368325e-16 and reference 1.0000000257220937e-16. Also reproduced the optional-bound TypeError using the exact selector body; the merge-base selector succeeded. Evidence saved in logs/scalar.log. - PASS on
gfx950 / fsx950223_pr_review_gfx950:ssh -o BatchMode=yes -o ConnectTimeout=10 -o RequestTTY=no -o ControlMaster=no -o ControlPath=none -o RemoteCommand=none dzm-mi355-gpu34-dev 'srun --overlap --jobid=9275 --ntasks=1 --cpus-per-task=1 podman exec -i fsx950223_pr_review_gfx950 bash' < remote-test.sh
Exit 0. Discovered running allocation 9275, verified gfx950 inside the container, checked GPU activity, and verified aiter imports from the isolated head source tree. Used flock -w 30, timeout 240, device 0 and isolated compilation caches. Targeted pytest: 1 passed, 4 skipped, 397 deselected in 7.04s. Full command and output are preserved in remote-test.sh and logs/gfx950-isolated-cache-test.log. - SKIP on
gfx1250:GPU execution of test_pa_decode_two_page_steps_keep_page_scales
No configured gfx1250 host. All four architecture-specific cases skipped on gfx950. - PASS on
local:python3 -m compileall -q checkout/aiter/ops/flydsl/kernels/pa_decode checkout/aiter/ops/flydsl/kernels/pa_decode_kernel.py checkout/aiter/ops/flydsl/pa_decode.py checkout/op_tests/test_flydsl_pa_decode.py checkout/op_tests/op_benchmarks/flydsl/bench_pa_decode.py
Exit 0; logs/compileall.log contains no errors.
Remaining validation:
- The numerical regression was verified through FP32 scalar arithmetic and code tracing, not gfx1250 kernel execution.
- Configured gfx950/gfx942 hosts cannot validate the changed gfx1250 WMMA, TDM, cluster synchronization or performance paths.
- Available CI reports successful MI35X standard tests and style checks, but no gfx1250 test result.
Automated Codex review of commit d1290630ff97.

Summary
Follow-up to #7079 on gfx1250 PA decode, tuned on MiniMax-M3 attention shapes (H16/KV1/D128). The main change is wider softmax steps. With a single query tile, each step's QK/softmax/PV exchanges maxima, sums and P through LDS with three CTA barriers, so short and sparse contexts spend much of their time on that exchange. Steps now cover more tokens where the grid allows it. Large grids, such as sparse prefill, need occupancy to hide DMA, so they keep the narrower steps. The step width is chosen at compile time from the grid size
compile_pa_decode_tilealready receives.This branch builds on
zhiding512/pa_benchmark(bench_pa_decode.py) and merges cleanly withmain.Wider softmax steps
Prologue and merge
context_lengths, exactly asplan_pa_decodesplits them. The context-length load is issued alongside thereduce_infoload, which removes the dependent work-record load before the first DMA. Asched_barrierkeeps the two scalar loads in flight together. One-partition direct output keeps work records: deriving its tiles cost sparse prefill at 4096 rows about 2%.Performance
Measured on gfx1250 (256 CUs) on one GPU. Base and head runs alternate; each case reports the minimum over two runs of the median of three rounds. Each round takes the minimum of five 10-call CUDA graphs with 5 replays. Sparse rows use ATOM's MiniMax-M3 plans (
get_recommended_splits(rows, 1)cap; 2048 top-k tokens; page16 pool of 4096 pages). Dense rows use page128 caches with the default cap. FP8 caches use per-token scales.Geometric mean over these 34 cases: 1.13× (FP8 dense 1.14×, FP8 sparse 1.23×, BF16 dense 1.05×, BF16 sparse 1.14×). BF16 dense verify on page128 runs the wave-pair path, which this PR leaves unchanged; its 0.99× is within run-to-run spread.
Over the full
bench_pa_decodematrix (189 cases, two alternating runs each), the geometric-mean speedup is 1.17× (FP8 1.20×, BF16 1.07×). The worst case isbf16-mtp4-g16-page128-mergeat 0.95×, which is inside that case's 5% base-to-base spread.Validation
python -m pytest -q op_tests/test_flydsl_pa_decode.pyon gfx1250: 230 passed, 159 skipped, the same as on base. It also passes with a fresh FlyDSL compile cache.Notes
pa_decodealready passes when it compiles a kernel, so graph capture and plan refreshes need no host-side change.🤖 Generated with Claude Code