Skip to content

[FlyDSL] [Perf] pa_decode: K/V streaming, MTP query split and sparse split-major on gfx950 - #7864

Open
fsx950223 wants to merge 54 commits into
mainfrom
fsx950223/pa-gfx950-gfx942-policies
Open

fsx950223 wants to merge 54 commits into
mainfrom
fsx950223/pa-gfx950-gfx942-policies

Conversation

@fsx950223

@fsx950223 fsx950223 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Brings three of #7709's gfx942 pa_decode schedule policies to gfx950, each re-tuned on MI355X:

  • K/V streaming for long head rows;
  • MTP query splitting over idle CUs;
  • split-major launches on sparse grids.

It also fixes one regression in #7709's gfx942 streaming policy, found while checking the review's regressions on gfx942: windowed rows now stream only from three CTAs per CU (commit 4).

gfx1250 kernels are bit-for-bit unchanged. On gfx942 only commit 4's windowed MTP rows on light grids change; every other gfx942 kernel is identical to main.

On MI355X, over all 817 cases of the unit-test-geometry matrix described below: geomean 1.19x against the merged dependencies 03894b767e, i.e. #7700+#7701+#7709 without this PR's commits (unit-test cases 1.22x, grid cases 1.19x). The 333 cases whose kernels change run 1.54x faster, and none is slower than 0.98x with warm KV. With cold KV against current main some gfx950 cases regress; see "Known regressions".

Branch layout. #7700, #7701 and #7709 are on main now. The branch merges main in 2e58031059 (e3931369ce) and c93e018031 (78a14ae5df), so against main it carries only this PR's four commits.

Motivation

#7709 found four schedule problems on gfx942. To see which also hold on gfx950, I opened each of #7709's gfx942-only gates on gfx950 and measured it on its own, against main and against #7700+#7701. Three hold:

  1. Spills at long head rows. The tile holds a whole next-tile K prefetch plus the tile's V gather in VGPRs. Once a lane's K row reaches 1 KiB (BF16 D512+, FP8 D1024), gfx950 spills as gfx942 does. Single and paired MTP M-tiles with 384/256-byte rows drop to one wave per SIMD on busy grids. Streaming runs these 1.8-7.7x faster.
  2. Idle CUs under MTP. With few sequences, one CTA's serial latency over all query positions is the decode time while most CUs idle.
  3. Plan-order dispatch on small grids. The tile grid dispatches x first, so later query splits and KV heads queue behind every empty plan slot.

Three gfx942 policies did not carry over and stay gfx942-only:

Changes

The first three commits change aiter/ops/flydsl/kernels/pa_decode/{traits,op_epilog}.py and pa_decode_kernel.py. After the merge with main, their diff is traits.py and op_epilog.py only (see "Merge with main" below). Commit 4 changes traits.py only:

  1. 372b2bc843 K/V streaming on gfx950 (STREAM_KV).
  2. 50e1d38283 MTP query split over idle gfx950 CUs, using [FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) #7709's rules with two gfx950 differences:
    • Per-token FP8 keeps its fused MTP4 tiles. Splitting them ran 0.75x.
    • The FP8 split also requires at most eight KV tiles per CU. This uses tile_demand, the sequence x head x tile count before the plan's capacity cap. gfx950 MTP plans fix capacity regardless of load, so a capacity bound no longer means idle CUs (B64/32K per-tensor ran 0.87x without the cap).
    • The busy BF16 D128 split stays gfx942-only.
  3. cbffdd201b Split-major launches on sparse gfx950 grids.
    • gfx950 uses split-major only while at most a quarter of the CUs hold work. On fuller grids slot-major ran up to 1.25x faster.
    • It applies to FP8, and to BF16 up to D128 (LDS-forced BF16 D192/D256 splits ran 0.91-0.93x). MXFP4 keeps slot-major.
    • Two gfx950-only paths assumed the slot-major axes and now follow the grid:
      • The BF16 D128 planned output's slot count read grid_dim.x. With a split-major grid that is heads x splits, so partials were stored at wrong offsets.
      • The one-partition plan's empty-row zero fill read block_id("y") as the KV head.
  4. 8092a71ef3 gfx942: stream windowed rows only from three CTAs per CU.
    • [FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) #7709's busy-grid streaming arms (single M-tiles with 384-1023 B rows, paired M-tiles with 256-1023 B rows) select once more CTAs than CUs hold work. A sliding window bounds every task to a few tiles, and there streaming only pays on fuller grids: BF16 MTP4 G16 D128 windows (w257, w700) on MI308X ran 0.83-0.91x at 1.2-2.4 CTAs per CU and 1.15-1.27x from 3.6 per CU.
    • Windowed gfx942 rows now need more than three CTAs per CU (new cache-key field stream_busy). Unwindowed rows, every other busy_grid consumer and every gfx950/gfx1250 selection are unchanged.

Not changed:

  • the API, plan_pa_decode and its budgets;
  • the reducer;
  • softmax math;
  • MXFP4 paths;
  • every gfx1250 binary, and every gfx942 binary except commit 4's windowed rows.

Merge with main

2e58031059 merges main at e3931369ce, which has #7700 (bdabd08dad), #7709 (ce737ce698, including its own resolution against #7700) and #7619's gfx1250 changes.

c93e018031 merges main at 78a14ae5df, which has #7701 at its head a8b9f032b9 (the reducer also honors the kernarg preload env). Its one conflict, the preload options in pa_decode_reduce.py, takes main's version. The merged tree is identical to main + the three commits cherry-picked onto it.

The stack's older merge history (#7700 59d523033c + #7701 02dc5d11b8 + #7709 8274dfbc42 + 65eed8399b, at 03894b767e) stays in the branch. While porting streaming, I found a first-tile LDS race in #7709's streamed path. It was fixed in #7709 itself (65eed8399b) and is on main.

Performance (if applicable)

How these numbers were measured:

  • Hardware: MI355X (gfx950, 256 CUs), ROCm 7.2.4, torch 2.10, FlyDSL 0.5.0. Before = 03894b767e (the merged dependencies), after = cbffdd201b.
  • Matrix (817 cases): every geometry of op_tests/test_flydsl_pa_decode.py that runs on gfx950 at its unit-test lengths (115 cases), plus each geometry at batch {1, 16, 64} x context {1K, 8K, 32K} with the default plan (702 cases).
  • Method: paired in-process A/B, both trees loaded in one process. CUDA-graph replays of 10 calls, 10 replays x 20 ABBA pairs per case; median ratio.
  • Noise: the 484 cases whose kernels are binary-identical read geomean 1.0000, 1st-99th percentile 0.984-1.018.
Hardware Workload/configuration Before After Change
MI355X Full matrix, 817 cases (geomean) - - 1.19x
MI355X The 333 changed cases (geomean) - - 1.54x (min 0.984x)
MI355X BF16 D1024 MTP4 GQA16, B16 ctx1K 202.2 us 26.2 us 7.72x
MI355X BF16 D1024 MTP4 GQA16, B16 ctx8K 1662.0 us 389.5 us 4.27x
MI355X BF16 D512 MTP4 GQA16, B16 ctx8K 326.5 us 91.5 us 3.57x
MI355X FP8 D1024 GQA4, B16 ctx8K 116.7 us 49.6 us 2.35x
MI355X FP8 MTP4 GQA16 page128, UT mtp4-g16-page128-direct 20.2 us 9.3 us 2.17x
MI355X BF16 D64 MTP4 GQA16 page128, UT ...-direct-d64 20.3 us 12.4 us 1.64x
MI355X FP8 per-token MTP4 window 257, B1 ctx8K 9.2 us 6.4 us 1.45x
MI355X Worst changed case: FP8 D256 MTP4 2 heads page128, B64 ctx32K 362.6 us 368.5 us 0.98x

Per commit, each against its parent, over the cases it changes:

Hardware Commit / workload Change
MI355X 1: K/V streaming, 96 cases geomean 2.67x (BF16 3.88x, FP8 1.83-2.07x), min 0.984x
MI355X 2: MTP query split, 164 cases geomean 1.19x (UT 1.51x), min 1.004x
MI355X 3: sparse split-major, 166 cases geomean 1.13x (grid 1.18x, UT 1.00x), min 0.982x

By family over all 817 cases:

  • BF16: grid 1.35x, UT 1.41x;
  • FP8 per-tensor: grid 1.11-1.16x, UT 1.21-1.33x;
  • FP8 per-token: grid 1.09-1.11x, UT 1.03-1.06x.

gfx942, commit 4 (MI308X, 80 CUs, paired in-process ABBA, 20 pairs; before = c93e018031, which is main on gfx942; after = 8092a71ef3):

Hardware Workload/configuration Before After Change
MI308X The 13 changed cases (BF16 MTP4 G16 D128, w257/w700, B16-B32), cold KV (512 MB rotation), geomean - - 1.128x (min 1.095x)
MI308X The same 13 cases, warm KV, geomean - - 1.101x (min 1.060x)
MI308X w257, B16 ctx1K, cold KV 16.74 us 13.71 us 1.22x
MI308X w700, B16 ctx8K, cold KV 19.21 us 17.48 us 1.10x

Commit 4 changes no other case among 3726 schedule-checked gfx942 cases (UT matrix, off-grid batch/context/length-mix probes and a prod sweep), and all 13 outputs are bit-exact.

Known regressions:

  • With warm KV, no changed case is below 0.98x. Three unchanged cases read 0.974-0.976x; their binaries are identical, so those readings are noise.
  • gfx950 with cold KV, against current main (review 5917442590 found these; I reproduced and attributed them on MI355X with 512 MB KV rotation). They are not fixed in this PR yet:
    • Commit 2 (query split): FP8 per-tensor plain-V and BF16 MTP single-sequence 32K decodes run 5-12% slower cold, though 2-5% faster warm. FP8 per-tensor G8 MTP4 page16 B1 32K with a bounded max_context_length runs 10% slower cold and 13.7% slower warm: the 4-way split leaves 8 of 16 MFMA rows per CTA.
    • Commit 3 (split-major): per-token -merge UT cases run 5-12% slower cold, and per-token MTP4 G16 max_partitions=1 B16 8K runs at 0.77-0.89x warm. When every plan slot holds work, split-major only spreads a task's splits over more XCDs, whose L2s each fetch its K/V.
    • Commit 1 (busy-grid streaming): BF16 G32 page16 decode with mixed lengths (one 32K row among 512-token rows) runs at 0.85-0.87x warm, because the busy test assumes every row has the bound's length.
    • Candidate gfx950 fixes (split-major only with empty plan slots, an FP8 split that keeps 16 rows per CTA, no busy-grid streaming arms on gfx950) are not measured yet: the MI355X host has been unreachable.
  • gfx942 has two pre-existing regressions from [FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) #7709 on main that commit 4 does not fix, because every gate I tried costs more elsewhere:
    • Split-major on FP8 G8 MTP4 page16 B1 32K costs about 4% warm (cold neutral). Gating it on empty plan slots loses 18-31% on BF16 D1024 MTP and 14-22% cold on FP8 B1 4K with a table-capacity bound.
    • Busy-grid streaming on skewed or table-capacity-bound batches runs at 0.76-0.95x, but the host cannot tell those from uniform batches, where streaming gains 1.2-1.3x.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Results:

  • gfx942 (MI308X, 80 CUs), head 8092a71ef3: op_tests/test_flydsl_pa_decode.py: 357 passed, 108 skipped, the same as main.
  • Compile-only replay of 8092a71ef3: gfx950 (128 tile, 46 reducer, 14 planner) and gfx1250 binaries are identical to c93e018031; gfx942 binaries are identical to the timed commit-4 tree, and differ from main only in the windowed rows.
  • gfx942 regression check of c93e018031 vs main (33 cases: the review's regressions, my own finds and control wins): cold 0.998x, warm 0.999x geomean, all bit-exact.

On c93e018031:

On the stack base (cbffdd201b, before the merge):

No unit test is added: the existing cases reach every new gfx950 specialization and commit 4's windowed rows. Not tested on MI250X (gfx90a is unsupported by this kernel), MI300X (304 CUs) or MI325X.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The API, the plan and the set of supported shapes are unchanged; the change is internal to the gfx950 tile schedule.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None

PR Self-Review

Reviewed revision

8092a71

Behavior and intent

On gfx950 the pa_decode tile schedule now uses three policies #7709 introduced for gfx942:

  • K/V streaming for long head rows removes the next-tile K prefetch spill.
  • The MTP query split spreads one sequence's query positions over idle CUs.
  • Split-major launches stop small grids' later splits and heads from queuing behind empty plan slots.

Each is re-tuned on MI355X where the gfx942 rule lost: per-token FP8 keeps its fused MTP4 tiles, the FP8 split is bounded by the uncapped tile count, and split-major is limited to sparse grids and to FP8 or BF16 up to D128. Without these policies, gfx950 spilled at D512/D1024 and left CUs idle under MTP (1.19x geomean over the matrix). Commit 4 stops gfx942 windowed rows from streaming on grids with fewer than three CTAs per CU, where streaming ran 0.83-0.91x. gfx1250 binaries are unchanged, and gfx942 binaries change only for those windowed rows.

Validation and unverified scope

Evidence on 8092a71ef3:

  • pytest op_tests/test_flydsl_pa_decode.py on MI308X (gfx942): 357 passed, 108 skipped, the same as main.
  • Compile-only replay: gfx950 and gfx1250 binaries identical to c93e018031; gfx942 binaries identical to the timed commit-4 tree.
  • gfx942 paired A/B of commit 4: its 13 changed cases run 1.128x faster cold and 1.101x warm, bit-exact; no other case among 3726 changes.

Evidence on the merged tree (c93e018031):

  • pytest op_tests/test_flydsl_pa_decode.py on MI355X: 433 passed, 32 skipped, the same as main 78a14ae5df.
  • Compile-only replay of 243 cases: the gfx950 tile and reducer binaries are identical to cbffdd201b, and the reducer and planner are identical to main. The gfx942 and gfx1250 binaries are identical to main.

Evidence on MI355X at cbffdd201b (stack base):

  • pytest op_tests/test_flydsl_pa_decode.py: 355 passed, 37 skipped. The negative control with commit 3's axis fixes reverted fails 9 cases.
  • Paired in-process A/B: per commit and end-to-end over all 817 matrix cases. Geomean 1.19x, no changed case below 0.98x, 0 errors, 0 non-finite.
  • Determinism: every one of the 333 changed cases repeats bit-exactly over 20 launches (det_check.py).
  • Accuracy: 19 changed cases are not bit-exact against the base (streamed accumulation order). On each, the max error against the fp32 reference equals the base's.

Evidence on gfx942:

  • pytest on MI308X: 285 passed, 107 skipped.
  • Compile-only replay (COMPILE_ONLY=1) of every matrix case: gfx942 and gfx1250 binaries identical to 03894b767e.

Unverified:

  • Not run on MI350X or other gfx950 SKUs with fewer CUs; the CU/4 and 8-tiles-per-CU bounds were measured at 256 CUs.
  • Shapes outside the matrix are not covered.
  • Callers that pass no max_context_length get the block-table capacity as the bound (as ATOM does). With a long table, the gfx950 FP8 split then needs at most four sequence-heads, and split-major rarely fires (review finding 1).
  • The gfx950 cold-KV regressions listed under "Known regressions" are not fixed; gfx950 was not re-run on this head because the MI355X host is unreachable, but its gfx950 binaries are identical to c93e018031.
  • Commit 4's three-CTAs-per-CU bound was measured at 80 CUs (MI308X) only; MI300X (304 CUs) is not tested.
  • The A/B timings were not re-run on the merged tree. Its gfx950 tile and reducer binaries are identical to the timed ones; the planner kernel and the host code are main's.
  • gfx942 pytest was not re-run on the merged tree; its gfx942 binaries are identical to main.

PR-specific question

The main boundary is the split-major grid on gfx950: it swaps which block-id axis names the plan slot. Any gfx950-only path that still assumes slot-major axes silently reads the wrong slot or head.

Two such paths existed:

Opening split-major on gfx950 without fixing them produced relative errors of 1-19 on BF16 D128 two-head shapes. Both now select the axis from SPLIT_MAJOR, and their IR is unchanged when it is off. The remaining direct block_id/grid_dim reads are gfx1250-only pipelines, or the MXFP4 direct path, which keeps slot-major. Evidence: with the two fixes reverted, the existing UT fails 9 cases; with them, all pass; every changed case is deterministic and matches the base's fp32-reference error.

The second boundary is the cache key. Main's PaDecodeCacheKey is built by keyword in select() and read by name in create(), so the rename covers the field names and both sites; a missed one raises on the first call. The renamed fields keep their positions ahead of D256_PIPE, so the test's cache_key[-2:] is unchanged and the pipe-policy tests pass.

Changed op tests

None. After the merge with main, this PR's diff changes no op test: the earlier op_tests/test_flydsl_pa_decode.py change came from #7700 and is on main now. The existing test_pa_decode cases reach every new gfx950 specialization: the head1024/head512/head192 streamed rows, the MTP4/MTP8 -direct, -merge, -probability_tail and window cases for the query split, and the -direct/-cluster cases for split-major. The negative control shows they fail when the split-major axis fixes are missing.

🤖 Generated with Claude Code

fsx950223 and others added 30 commits November 10, 2026 03:48
… load scheduling, lean FP8 MTP4

gfx950-only tile-kernel changes, each behind a traits flag that requires is_gfx950:

- BF16_MTP_FUSED: BF16 multi-query (MTP4 verify) page-128 D128 tiles keep Q in padded LDS rows,
  give every M-tile a private P/Lsum slot (one publication barrier), carry V across M-tiles and
  pair K16 packs into gfx950's K32 BF16 MFMA. The resident set fits 256 VGPRs (2 CTAs per CU).
  The task's last tile is peeled and carries the V tail mask; unowned KV rows stay masked.
- BF16_DECODE_NT_KV / DECODE_Q_EARLY / DECODE_LAST_V_AFTER_QK: BF16 single-M decode streams K and
  V nontemporally, issues Q ahead of the page ids, and loads the last tile's V right after QK.
- FP8_SCALES_AFTER_Q / FP8_LOOP_SCALES_LATE: per-token FP8 page-128 tiles stage scales so their
  vmcnt waits stop draining K and V ahead of the softmax.
- FP8_MTP4_LEAN / FP8_MTP4_Q_LDS / FP8_MTP4_PAGES_AHEAD: FP8 MTP4 verify folds the K scale and the V
  normalization into exp2 and the PV MFMA's P scale, rereads Q from LDS and carries the next
  tile's page ids, with waves_per_eu=2.
- The gfx950 BF16-KV tile launch preloads its leading kernel arguments.

gfx942 and gfx1250 code paths are unchanged (gfx942: every compiled PA kernel bit-identical).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in one rung

On gfx950 the dual-mode reducer replaces the (1, 2, 4, 8, 16, 32) rung ladder with one
32-partition rung. LLVM hoisted the ladder's shared leading loads above the count branch,
waited on them there and trickled the rest in small batches: 32 live partitions took several
serial L2 round trips. One rung issues every load at once; partitions past the live count read
zeros from the per-sequence buffer bound. Above 32 live partitions, each group's loads now issue
before the weight barrier, as on gfx1250.

Trade-off: sequences with few live partitions now pay the 32-load rung (see the PR description).
gfx942 and gfx1250 are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-16 tiles

gfx950 scalar-scale (per-tensor) FP8 page-16 single-M tiles now take the existing V-prefetch pipe
(PAGE16_VPIPE) that per-token FP8 page 16 already uses; before, only page 128 qualified, so page-16
tiles issued V after the softmax barriers. Single-CTA page-16 cost drops from ~2.7 us per 256-token tile.

Paired in-process A/B vs the previous head on MI355X (FlyDSL 0.5.0): 32 page-16 review shapes 1.035x
geomean (single-CTA 30K context 1.53x, H8 B32 1.18x), outputs bit-exact; other paths unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gfx950 BF16 page-16 single-M decode tiles take the V-prefetch pipe as well (they had no V
prefetch: ~3.7 us per 256-token tile in a single CTA).

Paired A/B on MI355X: single-CTA 30K context 1.58x, random-length B16 1.04x, B1 short contexts
+1-2%, large grids -0.4..-0.8%; outputs bit-exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…128 decode

gfx950 FP8 single-M page-128 decode loads V with nontemporal flat loads (FP8_DECODE_NT_V), as BF16
decode already streams K and V. K stays cached: streaming K as well slowed the short single-tile
tasks, and on page 16 streaming fights the V-prefetch pipe (single-CTA 30K -21%).

Paired A/B on MI355X over the FP8 page-128 decode shapes: 1.033x geomean (b64 32K 1.18x, b4 32K
1.13x, b32 8K 1.05x), no shape below 0.998x; outputs bit-exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d of rebuilding them

pa_decode built a fresh one-element scale tensor on every call for scalar FP8 KV scales
(torch.ones for None, torch.tensor for a Python float). Under a CUDA graph each is a captured fill
or host copy: a scale-less FP8 call ran 4 dispatches instead of 2. The scale is now one persistent
tensor per (device, value), cached only when built outside graph capture (a captured fill has not
run yet and lives in that graph's pool), so captured-first calls keep working.

Host-only; kernels unchanged on every architecture. Paired A/B on MI355X over the 51-shape review
set: 1.245x geomean; short scalar-FP8 calls 9.9 -> 6.6 us; outputs bit-exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… from the tile kernel

A plan with max_partitions == 1 gives every sequence at most one task (capacity == batch), yet gfx950
FP8/BF16 still wrote packed partials and launched the reducer to copy them out. The tile kernel now
stores the normalized rows itself, as gfx1250 and MXFP4 already did: slot s runs packed task s and
zero-fills sequence s when it owns no task (reduce_info count 0), so the second dispatch and the
partial scratch round trip go away. Sinks and strided outputs keep the reducer. The direct store
takes the query's row/head strides for any query length.

Paired A/B on MI355X: W6 fp8 page-16 B64 mp1 1k 10.55 -> 8.65 us (1.21x), W5 bf16 B64H8 mp1
1.07x, R7 single-CTA 30k 1.01x; outputs bit-exact; other shapes compile the same kernels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… V; FP8 issues next K after QK

gfx950 scalar-scale page-16 tiles issue this tile's V at tile start, then load the next tile's page ids
from the block table and stage them in LDS. In-order vmcnt makes that staging wait drain V as well,
so V overlapped only QK, and the next K went out only after the P barrier, with PV left to hide it.
The next page ids now load ahead of V (they are masked past the task and staged only under the
existing next-tile guard), and FP8 issues the next K from them right after QK. BF16 keeps K after
the P barrier: its next K needs twice the registers and was 4% slower per tile.

Single-CTA cost per 256-token tile on MI355X: FP8 1.693 -> 1.412 us, BF16 2.227 -> 2.152 us.
Paired A/B: R7 single-CTA 30k 1.20x, R5b budget=CU 32k 1.16x, W6 B64 mp1 1.10x, R1 128k 1.04x,
P2 H8 B32 1.03x; outputs bit-exact; other shapes within +-1% (re-measured candidate-first).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e bound

The planner gives every nonempty sequence one task, then spreads the other slots in proportion to
tiles. With mixed lengths and about two slots per sequence the long sequences keep the longest tasks:
16 tiles on a P2 H8 B32 random 1k-8k batch whose average is 8.5, so the kernel ends on that tail. On
gfx950, single-block plans now give a sequence of t tiles min(ceil(t / T), max_partitions) tasks,
with T the smallest bound from ceil(total / capacity) up that fits the capacity. A binary search over
[ceil(total / capacity), ceil(total / (capacity - rows))] finds it; one block reduction per halving,
int32 math, skipped for full plans. Equal-length batches keep their task size and may use fewer
slots, which also shortens the reducer.

Paired A/B on MI355X (decode only, plans built outside the graph): H2 D256 H8 B32 1.16x, P2 B32
1.07x, H1 B32 1.05x, MiniMax b3 225k four shapes 1.02-1.05x, P4 B8 1.03x; P1 B128 0.99x; 87-shape
geomean 1.006-1.008x. Planner refresh +0.06..0.51 us. test_pa_decode_plan asserts the min-max
counts when the planner compiles the balanced variant and the proportional split otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssion

The one-partition direct output generalized the direct store's address to query lengths above 1.
Single-query kernels, including the MXFP4 plan-free ones that already stored directly, now keep the
original expression, so their generated code stays as it was; only longer queries take the
position/head split. Paired A/B: W3/W4 MXFP4 1.000x/1.001x, W5/W6/R7 within noise, outputs
bit-exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… gfx942

On gfx942 the D1024 FP8/BF16 and BF16 D512 MTP tile kernels hold the whole
next-tile K prefetch and the tile's whole V gather in registers. They hit
512 VGPRs and spill 350-2000 registers to scratch.

Where a lane's K row reaches 384 bytes (BF16 D192+, FP8 D512+; with
several M-tiles, 1 KiB), the tile now carries only page ids. K is
streamed in pieces of four head groups (two in flight) and V in head
chunks (four in flight), with a scheduling fence after each chunk. M-tiles
pack P into private slots behind one barrier and share every K/V chunk.
Spills drop to zero. gfx950 and gfx1250 binaries are unchanged.

Paired in-process A/B vs main on MI308X (gfx942, 80 CU):
- 70 D1024 cases: 1.87-6.14x, all bit-exact
- BF16 D512 MTP4: 2.30-4.18x, same fp32-reference error
- BF16 D256 page16: 1.28-1.41x at batch >= 16, 0.81-0.94x at batch 1
- BF16 D192 page64: 1.21-1.27x at batch >= 16

107 cases: geomean 2.48x.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nes use DPP

The reducer's softmax weights reduce each row's partition max and sum across lanes with shuffle_xor.
On gfx950 the 8/4/2/1-lane steps lowered to ds_swizzle, an LDS crossbar round trip with a full
lgkmcnt wait each: eight serial ~44-cycle waits per reducer wave, on the critical path of every
short call. Those steps now use the 16-lane DPP xor patterns (the same partner lane, so results are
bit-identical); the 16/32-lane steps keep permlane swaps. Other architectures are unchanged.

Paired A/B on MI355X over 87 shapes: 1.0069x, all outputs bit-exact; short calls 1-3% (MiniMax
fp8/bf16 b1 decode, R1/R5b/H1 page 16), the lowest shapes within +-0.4% when re-measured alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gfx9 tile issues a single M-tile's V loads only after the P barrier, and
PV consumes them right away. The load latency therefore sits on every tile's
critical path. ATT on MI308X showed the PV MFMAs waiting on vmcnt one V load
at a time. gfx950 already prefetches V at the tile start for its tuned FP8
shapes; gfx942 never did.

On gfx942, single-M-tile FP8 (up to D256, any page size) and BF16 page16
D128 now take the existing prefetch_v schedule. V is loaded at the tile start
and overlaps QK and softmax. BF16 page128 and BF16 D64 measured neutral and
are left as they were; BF16 D192+ streams instead. gfx950 binaries are
unchanged.

Paired in-process A/B vs c52a931 on MI308X (gfx942, 80 CU):
- 135 single-M-tile grid cases: geomean 1.052x
  - FP8 page16 D128: 1.02-1.42x
  - BF16 page16 D128: 1.04-1.21x
  - FP8 page128 vectorized V at batch 1: 0.98-0.99x
- 111 unit-test cases: geomean 1.024x, worst 0.96x

Per-token outputs move by at most 1e-6 relative; the max error against the
fp32 reference is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rids

When more CTAs than CUs hold work, occupancy matters more than one CTA's
latency. When fewer do, the reverse holds. The schedule now records
whether the host-bounded busy-CTA count (the existing split_workgroups bound
times query splits) exceeds the CU count, and uses that on gfx942:

- FP8 D128 MTP tiles (2-4 M-tiles) need 260-272 VGPRs, i.e. one wave per
  SIMD. On busy grids they compile with waves_per_eu=2. That caps them at
  256 VGPRs at the cost of about ten spills, and two CTAs share each CU.
- Single M-tile K/V streaming between 384-byte and 1 KiB K rows (BF16
  D192/D256) now runs only on busy grids. On small grids the K prefetch it
  gives up was the latency that mattered: BF16 D256 batch 1 was 0.81x vs
  main. From 1 KiB rows, kernels always stream, because the unstreamed
  kernels spill.

gfx950 and gfx1250 binaries are unchanged.

Paired in-process A/B vs a5a617e on MI308X (gfx942, 80 CU), 310 cases:
geomean 1.077x.
- FP8 D128 MTP4/5/8 at batch >= 16 (or batch 64 ctx1K): 1.13-1.40x
- BF16 D256 page16 batch 1 ctx 1K/8K: 1.23x, back to 1.0x vs main
- Small grids: 0.97-1.00x. The worst is a long-row UT case
  (mtp4-g16-page128-varied), which is busy by the host bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tition decode

A one-partition plan gives each sequence a single CTA that walks all of its tiles; on sparse grids
that is a latency chain of four waves, one per SIMD. On gfx950, when the grid has at most one CTA
per CU, single-query decode tiles (scalar FP8 or BF16, no window, not the head-256 pipe) now launch
eight waves as two four-wave groups. Group g walks tiles start + g, + 2, ... with its own copy of the
LDS layout; both run the same iteration count (group 1's last tile may lie past the task and is fully
masked), so their CTA barriers pair up. After the loop group 1 publishes its (O, max, sum) per lane
and group 0 rescales both to the shared maximum and stores, directly or as the task's partial.
The grid condition joins the schedule key ahead of its last two fields, which tests read.

Single-CTA cost per 256-token tile on MI355X: FP8 page 16 1.42 -> 1.15 us, BF16 page 16 2.15 ->
1.54 us, FP8 page 128 1.69 -> 1.41 us. Paired A/B: R7 single-CTA 30k 1.19x, W6 B64 mp1 1.04x; all
other shapes compile the same kernels. FP8 P is quantized against each group's running maximum, so
those outputs move within FP8 rounding (max 3.4e-2 of the output max).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… when both LDS copies fit

MXFP4 tiles have no per-tile CTA barrier: each wave owns 64 tokens and the four waves merge once
after the loop, so a plan-free sequence is one CTA's latency chain. The dual-group CTA now covers it
when two copies of the MXFP4 layout (BF16 V staging and staged page ids) fit gfx950's 160 KiB of
LDS. The groups merge lane-wise (O, max, sum) before group 0's four-wave merge, and a barrier keeps
that merge's LDS writes behind every lane's read of the merge slots, which share the space.

Paired A/B on MI355X: W3 MXFP4 plan-free 64k 316.5 -> 226.2 us (1.40x); W4 (a 512k table stages
4096 page ids, so it keeps one group) unchanged; every other shape compiles the same kernels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… max

Every FP8 tile quantizes Q to e4m3 per row, first reducing |q| over each lane's 8-element BF16/FP16
unit. LLVM widened every element to f32 for the max: about 30 VALU per unit on the prologue's
critical path, 120 per lane for an MTP4 tile. A 16-bit float's magnitude orders like its
sign-cleared bit pattern, so on gfx950 the unit now reduces as a packed 16-bit integer max over
sign-cleared words, with one conversion of the winner. The result is the same value.

Paired A/B on MI355X over 87 shapes: 1.0045x, all outputs bit-exact; FP8 MTP4 verify b3 32k 1.03x,
short page-16 FP8 calls ~1-2%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…de tiles

Single-query decode without a sliding window can only see tokens past a row's bound in a task's last
tile, which the pipeline already peels for the V tail mask. The head-256 pipe still compared and
selected every score chunk of every tile. Interior tiles now skip that mask (single_scores and
pack_single take the tile's mask flag); the peeled tile and every other configuration keep it. On
the page-16 V pipe the masks are free and the change measured 1.5% slower, so it is left out there.

Paired A/B on MI355X: X2 D256 page-64 per-token B8 mp1 1.12x, X1 B1/B8 1.06x/1.05x, X3 page 16
1.04x; 87-shape geomean 1.0015x. Without the select, the multiply contracts into the exp's FMA, so
head-256 outputs move within rounding (max 2.4e-3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h integer DPP max

After each lane's |q| max, the row's 16 lanes combined theirs with four xor DPP steps of maxnumf.
Each step cost a copy, one or two v_mov_b32_dpp, an s_nop and a canonicalizing v_max_f32 besides the
max: about 22 VALU per M-tile on the prologue's critical path. The magnitudes are non-negative, so on
gfx950 the reduction now runs on their bits with integer max. Rotate-by-8 and rotate-by-4 within the
row and the two quad swaps cover all 16 lanes, each a single full-mask DPP pattern that LLVM folds
into the max. The result is the same value.

Paired A/B on MI355X over 87 shapes: 1.0024x (FP8 shapes 1.0037x), all outputs bit-exact; FP8 MTP4
verify b3 32k 1.025x.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es' page ids

Plan-free MXFP4 stages the task's page ids in LDS, up to 4096 of them when the table is long. Two
copies of that next to two BF16 V staging areas exceeded gfx950's 160 KiB, so long tables kept one
tile group. A dual group only walks tiles part_start + 2j, so it now stages just those ids (each tile's
pair contiguous) and looks a tile up at ((tt - part_start) / 2) * pages_per_tile; the page region of
each copy halves and both copies fit.

Paired A/B on MI355X: W4 MXFP4 plan-free 2k context in a 512k table 14.10 -> 12.53 us (1.13x); W3 and
every other shape unchanged and bit-exact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…head of the page ids

Single-M FP8 page-128 decode with a full 16-row tile already issues Q before the page ids and stages
it while K is in flight; scalar page-16 tiles still loaded Q after them. Page 16 now takes the early
path too, including partial tiles (GQA 8): a padded row's early load reads the last real row so it
stays inside the query, and the existing runtime row guard never stages it.

Paired A/B on MI355X over 87 shapes: 1.0046x, all outputs bit-exact; FP8 page-16 shapes 1.010x
(short calls up to 1.03x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…6 page-16 decode

The scalar head-256 pipe and BF16 page-16 single-M decode tiles now issue Q ahead of the page ids
and stage it while K is in flight, as FP8 head-128 decode does (partial tiles load the last real row
for their padded rows). Per-token head-256 keeps Q after its scale loads: its prologue orders the
scales ahead of K, and early Q cost it 10%.

Paired A/B on MI355X over 87 shapes: 1.0023x, all outputs bit-exact; short head-256 calls 1.04-1.05x
(P3 B1/B8, W1 B1, R5 4k), BF16 page-16 R2 up to 1.025x.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ruff 0.16.0, the version CI pins, flags the dpp_utils import placed after tensor_shim (I001).
Import order only; no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Black wrapped the condition, which left the noqa on the closing line; ruff 0.16.0, the version CI
pins, then reports SIM102 and an unused noqa. Comment placement only; no behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #7388 (FlyDSL-dtype tile kernel keys, no batch-first plan grid). This branch's traits and
kernels now use its names: kv_dtype/query_dtype FlyDSL types, OUT_DTYPE, KV_COMPUTE_BLOCK and
MXFP4_KV_DTYPE in place of MXFP4/is_bf16_kv/Q_IN_DTYPE/Q_DTYPE/KV_DTYPE/TILE_TOK; the gfx950
one-partition direct-output allowance moves into the schedule's direct_output check with #7388's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gfx9 prologue issued a CTA's Q loads after the first tile's page-table
and K loads. Q staging (quantize, LDS write, barrier) therefore waited on the
in-order vmcnt chain for every K load: ATT on MI308X showed a 1056-cycle
wait in a 9500-cycle single-tile task.

gfx942 now issues Q loads first, as gfx950 already does for MTP4-fused and
MXFP4 kernels. Padding rows of a partial last M-tile load the last real row
(clamped index) and staging still zero-fills them. Streamed kernels start
with K pieces and keep their order. gfx950 binaries are unchanged.

Paired in-process A/B vs 9428a09 on MI308X (gfx942), 111 unit-test
cases: geomean 1.016x (FP8 1.01-1.05x, BF16 1.00-1.03x, streamed D1024
0.98-0.99x before excluding them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… gfx942

Tiles that load V at the tile start (V prefetch, MTP M-tiles) issued the
next tile's block-table read only later, behind those V loads. Its
pin-to-context select then waited on vmcnt(0), i.e. for all of V; ATT on
MI308X showed about 1000 cycles of a 4400-cycle FP8 page16 tile spent
there.

The page-table read now issues before the V loads, fenced so the scheduler
keeps that order, and the pin happens at the use. The wait drops to
vmcnt(8). Applied on gfx942 to FP8 per-tensor single M-tiles and to MTP
tiles, except BF16 with two M-tiles. gfx950 binaries are unchanged.

Paired in-process A/B vs the previous head on MI308X (gfx942):
- FP8 per-tensor single M-tile: up to 1.18x (page128 plain V); page16
  1.03-1.07x at batch 64
- MTP M-tiles: 1.00-1.12x
- Excluded: FP8 per-token and BF16 page16 single tiles (0.95-0.98x) and
  BF16 two-M-tile MTP (0.95-0.98x)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…busy gfx942 grids

V prefetch at the tile start keeps the V registers live through QK and
softmax. For FP8 per-tensor page128 with a vectorized V cache, that cost more
than the hidden latency on small grids: 0.955-0.967x on the latency-bound
unit-test shapes. It still gains 1.11-1.15x on busy grids. Such tiles now
prefetch only when more CTAs than CUs hold work. Per-token, plain-V and
page16 tiles are unchanged.

Paired in-process A/B on MI308X (gfx942): small_query/probability_tail
page128 UT cases 1.04x, busy grids unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…D256 on gfx942

A streamed BF16 D256 page16 tile needs just over 256 VGPRs, so it ran one
wave per SIMD. Capped at 256 with waves_per_eu=2 (254 VGPRs, no spills),
two CTAs share each CU. That only matters on busy grids, where this path
is selected.

Paired in-process A/B on MI308X (gfx942): BF16 D256 page16 B64 ctx32K 1.38x
(main 0.94x before, now 1.30x vs main); other sizes unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… grids

MTP tiles with two M-tiles and K rows of 256 bytes or more need 272-324 VGPRs
(FP8 D256 GQA8 MTP4, BF16 D128 GQA8 MTP4). That leaves one wave per SIMD.
On busy grids they now take the streamed multi-M-tile schedule from
c52a931: K and V stream per chunk and both M-tiles share every chunk.
That frees the registers held by the next-tile K prefetch and the tile's V
gather, and two CTAs fit per CU. Small grids keep the prefetching schedule.

Paired in-process A/B on MI308X (gfx942), busy sizes (batch >= 16, or batch 1
with a 32K context):
- FP8 D256 page128 GQA8 MTP4 (2 KV heads): 1.18-1.28x
- FP8 D256 page64 GQA8 MTP4 per-token: 1.23-1.52x
- BF16 D128 page64 GQA8 MTP4: 1.17-1.20x
Max error against the fp32 reference is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fsx950223 and others added 6 commits November 11, 2026 06:40
Union of both sides in the pa_decode tile kernel. #7709's policies stay
gfx942-only and #7700's paths gfx950-only:

- traits: the cache key carries #7700's SPARSE_GRID and #7709's busy,
  two-per-CU and split-major flags ahead of D256_PIPE; prefetch_v keeps both
  arches' rules; P_BUFFERS gives each M-tile a slot for MTP4_FUSED,
  D256_PIPE, BF16_MTP_FUSED or STREAM_KV.
- pipeline: tile() issues both next-page lookaheads (PAGE16_PAGES_FIRST,
  PAGES_EARLY). single_query_tile takes #7709's STREAM_KV K/V branch, else
  #7700's late-scale / V-after-QK path with PAGES_EARLY ahead of
  REUSE_KV_PAGES.
- op_lds: early Q covers MTP4_FUSED, DECODE_Q_EARLY, GFX942_Q_EARLY and
  MXFP4; the padded-row clamp takes #7700's form.
- launch: the split-major grid with CTA_THREADS blocks, the gfx950 kernarg
  preload, and waves_per_eu=2 for FP8_MTP4_LEAN or WAVES_PER_EU_2.

Compiled binaries: gfx950 and gfx1250 match #7700+#7701; gfx942 matches
#7709 except the padded-row kernels, whose clamp compares against
CTA_ROWS - 1 instead of CTA_ROWS (same rows selected).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…re restaging

STREAM_KV tiles stage the next tile's page ids in LDS at the start of the
tile, so the page-table wait does not drain the K stream. The first tile's
ids are staged in the prologue and read back by every wave after its
barrier, but nothing ordered that read before the first tile's restaging:
a fast wave could overwrite the ids while a slow wave had yet to read them,
and the slow wave then gathered the first tile's V from the second tile's
pages. Later tiles are ordered by the tile barriers. Streamed tasks now
take one barrier after the read.

The race showed as run-to-run output differences of up to 1e-3 on FP8
per-tensor D256 MTP4 two-head busy grids (1-2 of 40 runs on gfx942; 8-16
of 20 on gfx950 with streaming enabled). After the fix, every streamed
case repeats bit-exactly; the cost is 1.0005x geomean over 161 streamed
gfx942 cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The barrier follows the first tile's page-id read in the merged prologue,
ahead of #7700's Q-operand selection. STREAM_KV is gfx942-only in this
stack, so gfx950 and gfx1250 binaries are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gfx950 pa_decode has the same register problem #7709 solved on gfx942: a
lane holding a whole next-tile K prefetch plus the tile's V gather spills
once its K row reaches 1 KiB (BF16 D512+, FP8 D1024), and single or
paired M-tiles with 384/256-byte rows drop to one wave per SIMD on busy
grids. Let STREAM_KV select on gfx950 too, outside the fused BF16 MTP and
head-256 pipes, which keep their own schedules; streamed tiles skip the
dual-group CTA. The busy-grid flags it reads are now arch-neutral
(renamed busy_grid / two_per_cu); every other consumer stays gfx942-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#7709's gfx942 query split also pays on gfx950: when few CTAs hold work,
per-CTA latency dominates, and splitting the MTP query positions over
more CTAs (re-reading K/V from L2) shortens the critical path. Apply it on
gfx950 with two differences found by measurement:

- per-token FP8 keeps its fused MTP4 tiles (splitting them ran 0.75x);
- gfx950 MTP plans fix capacity at one or two slots per CU regardless of
  load, so a capacity bound no longer means idle CUs. The FP8 split also
  requires at most eight KV tiles per CU (tile_demand, the uncapped
  sequence x head x tile count); B64/32K per-tensor ran 0.87x without it.

The BF16 D128 split for busy grids stays gfx942-only (0.6-0.9x on gfx950).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#7709 launches gfx942 query splits and multi-head grids split-major, so a
slot's splits (or a small grid's heads) dispatch together instead of
queueing behind every empty plan slot of the previous split. On gfx950 the
order only pays while at most a quarter of the CUs hold work; on fuller
grids slot-major order measured up to 1.25x faster, so gfx950 takes it
only below that bound, for FP8 and for BF16 up to D128 (LDS-forced BF16
D192/D256 splits ran 0.91-0.93x). MXFP4 keeps slot-major.

Two gfx950-only paths assumed the slot-major axes and now follow the grid:
the BF16 D128 planned output's slot count (grid_dim.x; with a split-major
grid it read heads x splits and stored partials at wrong offsets) and the
one-partition plan's empty-row zero fill (block_id("y") as the KV head).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 7864 --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.

@fsx950223
fsx950223 marked this pull request as ready for review November 12, 2026 07:44
@fsx950223
fsx950223 requested review from a team and a balanced review from Copilot November 12, 2026 07:44

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aiter-bot

aiter-bot commented Nov 12, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 8092a71ef303 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

On gfx950 the pa_decode tile schedule now uses three policies #7709 introduced for gfx942:
- **K/V streaming** for long head rows removes the next-tile K prefetch spill.
- **The MTP query split** spreads one sequence's query positions over idle CUs.
- **Split-major launches** stop small grids' later splits and heads from queuing behind empty plan slots.

Each is re-tuned on MI355X where the gfx942 rule lost: per-token FP8 keeps its fused MTP4 tiles, the FP8 split is bounded by the uncapped tile count, and split-major is limited to sparse grids and to FP8 or BF16 up to D128. Without these policies, gfx950 spilled at D512/D1024 and left CUs idle under MTP (1.19x geomean over the matrix). Commit 4 stops gfx942 windowed rows from streaming on grids with fewer than three CTAs per CU, where streaming ran 0.83-0.91x. gfx1250 binaries are unchanged, and gfx942 binaries change only for those windowed rows.

Validation and unverified scope

Evidence on `8092a71ef3`:
- `pytest op_tests/test_flydsl_pa_decode.py` on MI308X (gfx942): 357 passed, 108 skipped, the same as main.
- Compile-only replay: gfx950 and gfx1250 binaries identical to `c93e018031`; gfx942 binaries identical to the timed commit-4 tree.
- gfx942 paired A/B of commit 4: its 13 changed cases run 1.128x faster cold and 1.101x warm, bit-exact; no other case among 3726 changes.

Evidence on the merged tree (`c93e018031`):
- `pytest op_tests/test_flydsl_pa_decode.py` on MI355X: 433 passed, 32 skipped, the same as main `78a14ae5df`.
- Compile-only replay of 243 cases: the gfx950 tile and reducer binaries are identical to `cbffdd201b`, and the reducer and planner are identical to main. The gfx942 and gfx1250 binaries are identical to main.

Evidence on MI355X at `cbffdd201b` (stack base):
- `pytest op_tests/test_flydsl_pa_decode.py`: 355 passed, 37 skipped. The negative control with commit 3's axis fixes reverted fails 9 cases.
- Paired in-process A/B: per commit and end-to-end over all 817 matrix cases. Geomean 1.19x, no changed case below 0.98x, 0 errors, 0 non-finite.
- Determinism: every one of the 333 changed cases repeats bit-exactly over 20 launches (`det_check.py`).
- Accuracy: 19 changed cases are not bit-exact against the base (streamed accumulation order). On each, the max error against the fp32 reference equals the base's.

Evidence on gfx942:
- pytest on MI308X: 285 passed, 107 skipped.
- Compile-only replay (`COMPILE_ONLY=1`) of every matrix case: gfx942 and gfx1250 binaries identical to `03894b767e`.

Unverified:
- Not run on MI350X or other gfx950 SKUs with fewer CUs; the CU/4 and 8-tiles-per-CU bounds were measured at 256 CUs.
- Shapes outside the matrix are not covered.
- Callers that pass no `max_context_length` get the block-table capacity as the bound (as ATOM does). With a long table, the gfx950 FP8 split then needs at most four sequence-heads, and split-major rarely fires (review finding 1).
- The gfx950 cold-KV regressions listed under "Known regressions" are not fixed; gfx950 was not re-run on this head because the MI355X host is unreachable, but its gfx950 binaries are identical to `c93e018031`.
- Commit 4's three-CTAs-per-CU bound was measured at 80 CUs (MI308X) only; MI300X (304 CUs) is not tested.
- The A/B timings were not re-run on the merged tree. Its gfx950 tile and reducer binaries are identical to the timed ones; the planner kernel and the host code are main's.
- gfx942 pytest was not re-run on the merged tree; its gfx942 binaries are identical to main.

PR-specific question

The main boundary is the split-major grid on gfx950: it swaps which block-id axis names the plan slot. Any gfx950-only path that still assumes slot-major axes silently reads the wrong slot or head.

Two such paths existed:
- the BF16 D128 planned output's slot count (`grid_dim.x`);
- the one-partition empty-row zero fill (`block_id("y")`). Main now has this one through #7709, which opened split-major for #7700's gfx942 direct path.

Opening split-major on gfx950 without fixing them produced relative errors of 1-19 on BF16 D128 two-head shapes. Both now select the axis from `SPLIT_MAJOR`, and their IR is unchanged when it is off. The remaining direct `block_id`/`grid_dim` reads are gfx1250-only pipelines, or the MXFP4 direct path, which keeps slot-major. Evidence: with the two fixes reverted, the existing UT fails 9 cases; with them, all pass; every changed case is deterministic and matches the base's fp32-reference error.

The second boundary is the cache key. Main's `PaDecodeCacheKey` is built by keyword in `select()` and read by name in `create()`, so the rename covers the field names and both sites; a missed one raises on the first call. The renamed fields keep their positions ahead of `D256_PIPE`, so the test's `cache_key[-2:]` is unchanged and the pipe-policy tests pass.

Changed op tests

None. After the merge with main, this PR's diff changes no op test: the earlier `op_tests/test_flydsl_pa_decode.py` change came from #7700 and is on main now. The existing `test_pa_decode` cases reach every new gfx950 specialization: the `head1024`/`head512`/`head192` streamed rows, the MTP4/MTP8 `-direct`, `-merge`, `-probability_tail` and window cases for the query split, and the `-direct`/`-cluster` cases for split-major. The negative control shows they fail when the split-major axis fixes are missing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

…cies

main now carries #7700 (at bdabd08) and #7709 (at ce737ce, including
its own resolution against #7700) as squash merges, plus #7619's gfx1250
pa_decode changes. Every conflict in op_lds.py, pipeline.py, traits.py,
pa_decode_kernel.py, pa_decode_plan.py, pa_decode.py and the test takes
main's side, so the stack's older #7700/#7709 heads and their merge
resolutions are superseded. On top of main the branch keeps only #7701
(02dc5d1, unchanged) and this PR's three commits.

The STREAM_KV commit's flag rename now also renames main's named cache key
fields: PaDecodeCacheKey.gfx942_busy -> busy_grid and gfx942_two_per_cu ->
two_per_cu. Every consumer other than STREAM_KV stays gated on "gfx94".
Two hunks of this PR's commits were already on main through #7709's resolution
and drop out of this PR's diff: DUAL_GROUP's "not STREAM_KV" and the
_zero_rows kv_query axis follows SPLIT_MAJOR.

The merged tree is identical to main + #7701's five commits + this PR's
three commits cherry-picked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 03:38

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

main now carries #7701 at its head a8b9f03, which also honors the
kernarg preload env in the gfx950 reducer. The one conflict, in
pa_decode_reduce.py, takes main's version; the branch carried #7701 at
02dc5d1. Against main the branch now holds only this PR's three
commits (traits.py, op_epilog.py), and the merged tree is identical to
main + those three commits cherry-picked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 06:42

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

FlyDSL PA review (automated harness)

Verdict: CHANGES_NEEDED. On gfx950 the PR's big wins reproduce against current main. However, 8 cases regress by 6-18% (confirmed on a re-run), one of them an ATOM-style production shape. There is also one major code-review finding. Head c93e018031, base = merge-base 78a14ae5df (current main, which includes #7700/#7701/#7709).

Performance and correctness

arch container / GPU status verdict key numbers
gfx942 MI308X container unreachable (host reservation) NOT VERIFIED none: no pytest, ISA identity unknown
gfx950 MI355X, 256 CUs done FAIL (8 confirmed regressions) geomean time ratio head/base: unit 0.643 (303 cases), grid 0.783 (1575), prod 0.994 (104), claims 0.457 (8). pytest 433 passed / 0 failed on both sides, no newly skipped tests. Noise band 2.5% (A/A control 1.7-2.7%)
gfx1250 MI450 container unreachable (container down) NOT VERIFIED none: no pytest, ISA identity unknown

Confirmed regressions on gfx950. Cases are re-run in fresh processes with 30 ABBA pairs. A regression counts only if it was slower on every one of 3 memory layouts in both runs.

case (batch, context) base us head us time ratio
FP8 bf16-q per-tensor, plain V, MTP8 G8, page 128 (B1, 32K) 12.35 14.65 1.185
FP8 fp16-q per-tensor, plain V, MTP8 G8, page 128 (B1, 32K) 12.39 14.61 1.180
FP8 fp16-q per-tensor, plain V, MTP4 G16, page 128, direct (B1, 32K) 12.41 14.56 1.175
FP8 fp16-q per-tensor, plain V, MTP4 G16, page 128 (B1, 32K) 12.60 14.78 1.173
UT fp8-bf16-per-token-plain-v-mtp4-g16-page128-merge 22.05 25.30 1.148
prod: FP8 per-tensor G8 D128 MTP4, page 16, default plan, bounded max_context_length (B1, 32K) 9.56 10.51 1.101
UT fp8-bf16-per-token-transposed-v-mtp4-g16-page128-merge 17.78 19.03 1.068
BF16 MTP4 G16, page 128, direct (B1, 32K) 11.88 12.62 1.062

Pattern: these are almost all single-sequence long-context MTP decodes. The likely trigger is the new gfx950 MTP query split over idle CUs. The same prod shape called ATOM-style (max_context_length = table capacity) is not slower, which matches finding 1. The PR states "none is slower than 0.98x", but that was measured against the old stack 03894b767e. Against current main these cases regress. Five more first-pass candidates (BF16 D256 / D192 / packed MTP4 at B16-64) did not reproduce on the re-run and are not counted.

PR claims, claimed vs measured (gfx950):

row claimed before → after (speedup) measured base → head (speedup)
BF16 D1024 MTP4 GQA16, B16 ctx1K 202.2 → 26.2 us (7.72x) 195.1 → 33.4 us (5.84x)
BF16 D512 MTP4 GQA16, B16 ctx8K 326.5 → 91.5 us (3.57x) 319.5 → 102.8 us (3.11x)
BF16 D1024 MTP4 GQA16, B16 ctx8K 1662.0 → 389.5 us (4.27x) 1657.5 → 399.6 us (4.15x)
FP8 D1024 GQA4, B16 ctx8K 116.7 → 49.6 us (2.35x) 121.3 → 60.1 us (2.02x)
UT FP8 MTP4 G16 page128 direct 20.2 → 9.3 us (2.17x) 20.9 → 13.0 us (1.60x)
UT BF16 MTP4 G16 page128 direct D64 20.3 → 12.4 us (1.64x) 20.8 → 13.0 us (1.60x)
FP8 per-token window 257, B1 ctx8K 9.2 → 6.4 us (1.45x) 9.25 → 6.76 us (1.37x)
worst case FP8 D256 MTP4 kv2, B64 ctx32K 362.6 → 368.5 us (0.98x) 373.0 → 378.8 us (0.98x)

All 8 rows reproduce in direction. The speedups are 0-25% below the claims. The PR's base was the old stack, so this is expected. The 1.19x / 1.54x matrix geomeans were not re-derived: the harness grid uses its own case set.

Not verified:

  • gfx942: the claim "gfx942 binaries bit-for-bit unchanged" is unproven on hardware for c93e018031. Code reading agrees with it (finding 9). CI does not run gfx942 kernels.
  • gfx1250: the claim "gfx1250 binaries identical" is unproven on hardware. Code reading agrees: the gfx1250 compile path returns before PaDecodeSchedule.select/PaDecodeTraits.create reach any changed line.
  • CI at snapshot time: build_aiter_wheels (py3.12) was still in progress, so there is no MI35X op-test result for this head yet.

Code review

  1. [major] In ATOM's call style (max_context_length = block-table capacity, which pa_decode() also substitutes when the caller passes None), the new gfx950 FP8 MTP split and split-major almost never fire (inline at traits.py:347).
    • With a 128K-token table, tile_demand = seqs x kv_heads x 512. The FP8 split needs seqs x kv_heads <= 4, and then splits only 2-way. Split-major needs split_workgroups <= 64, which default plans never reach.
    • The matrix uses bounded lengths, so the 1.19x / 1.54x headline describes bounded callers only. This is not a regression; base does not split these cases either.
    • The self-review bullet "callers that pass no max_context_length get no tile bound" is wrong: they get the table-capacity bound.
    • Asks: add ATOM-style rows (bound = table capacity, FP8 per-tensor, page 16, default plan) next to their bounded twins, correct the bullet, and document the effective gates, or key the gates on a load signal that table padding does not inflate.
  2. [minor, plausible] In ATOM's call style, gfx950 decode tiles with 384-1023 B rows (FP8 D512 page 16, BF16 D192/D256 page 64/128) now stream even when few CTAs hold work, because busy_grid follows plan capacity (512 for B>=2 on decode plans). This selection is new on gfx950 and was never timed (inline at traits.py:999).
  3. [minor] two_per_cu is now a gfx950 cache-key dimension that no gfx950 code reads (WAVES_PER_EU_2 is not is_gfx950), so identical gfx950 kernels on either side of 2 x CUs are traced twice. Gate it with "gfx94" in arch (inline at traits.py:477).
  4. [minor] No UT case reaches the newly enabled busy-grid STREAM_KV arms on gfx950. The head192 cases peak at 80 workgroups, below 256 CUs. The body's statement that the head192 cases cover the streamed rows is wrong, and nothing pins STREAM_KV per arch (inline at traits.py:1000).
  5. [minor] The split-major planned-output fix (op_epilog.py:35) is covered by one BF16 case (mtp4-g16-page128-cluster, split_workgroups 60 against the 64 gate), and no FP8 case reaches it. A smaller CU count, new lengths or a retuned gate would silently stop testing it (inline).
  6. [minor] Overlap with #8000: it rewrites the same pout_slot line, still uses gfx942_busy/gfx942_two_per_cu, and its gfx950 heads_fastest order overlaps this PR's gfx950 split-major (SPLIT_MAJOR wins there). Whichever PR merges second must carry the rename, keep logical_slots for pout_slot, state the precedence, and re-time the overlap (inline at traits.py:173).
  7. [nit] The comment at traits.py:33 still says "gfx942 K/V streaming". The comment at traits.py:555-558 says "a quarter of the CUs hold work", but the gate counts tasks before query splitting: FP8 MTP4 B16 ctx1K passes with 64 tasks x 4 splits = 256 CTAs (inline at traits.py:555).
  8. [nit, plausible] The matrix's sample points do not pin either new threshold. Any FP8 tile bound from 2048 to 8191, and any split-major bound from 64 to 127, gives identical matrix results (inline at traits.py:565).
  9. [nit] There is no hardware check of the merged head on gfx942 (pytest ran on cbffdd201b only; there is no ci:mi300x label), and MI35X CI was still pending at snapshot time. By code reading, gfx942 selection is unchanged (every new branch is gated to gfx950/gfx95), so the risk is low. No human or Copilot review exists yet (Copilot hit its quota three times). Asks: add ci:mi300x or post a gfx942 pytest on c93e018031, and update the PR's performance table to timings against current main (78a14ae5df). See the regressions above.
Method
  • A/B: paired ABBA per arch. Two long-lived worker processes, one per tree (base 78a14ae5df, head c93e018031), on the same GPU. Each worker builds every case with its own tree's op_tests/test_flydsl_pa_decode.py::_run_pa_decode_case, so the input layout, reference check and API come from that tree. Each case gets 3 independent memory layouts. Timing replays a CUDA graph of 10 calls that rotates over >= 512 MB of KV copies to get past the MALL. Calls pass an explicit output and plan scratch, as ATOM does. Ratio = head / base; the default is 12 pairs x 8 replays.
  • Sets:
    • prod: ATOM's call style. FP8 per-tensor KV, page 16, default plan (D256: 64 partitions / budget 256), max_context_length = 128K-token table capacity, plus bounded twins. Geometries: llama70b-tp8 G8, qwen3-235b-tp4 G16, llama8b-tp4 kv2 G4, qwen3next-tp2 D256; MTP 1/4; B1-128; 4K-128K contexts.
    • unit: every valid test parameter at its own lengths.
    • grid: every test geometry x B{1,16,64} x ctx{1K,8K,32K}, default plan.
    • claims: the PR's table rows as case dicts. Where the PR leaves the FP8 variant open, the cases use a bf16 query, per-tensor scales and transposed V. The window row is per-token. Pages and sinks come from the test geometry. The UT rows use the UT's own parameters.
  • Planned scope: gfx950 full (prod, unit, claims, grid + pytest A/B). gfx942 and gfx1250: ISA identity plus A/B on prod and unit, plus pytest A/B.
  • Thresholds: a case counts as slower when its median ratio is > 1 + band, >= 90% of its pairs are slower, and every layout agrees. band = max(2.5%, the p1-p99 spread of the base-vs-base control). An arch FAILs on any confirmed slower case, a set geomean > 1.01, a case that errors, fails or is skipped only on the head, or new pytest failures. Slower cases are re-run with 30 pairs before they are reported.
  • This run (gfx950): MI355X with 256 CUs, torch 2.10 / ROCm 7.2.4, FlyDSL 0.5.0 on both sides. First pass: 12 pairs × 8 replays, 1990 cases, 2 GPUs. Confirm pass: 30 pairs on the 13 first-pass slower cases, in fresh processes. Noise band 2.5% (A/A base-vs-base p1-p99 spread 1.7-2.7%).
  • Base: merge-base 78a14ae5df. The one PA-shared commit on main after it (cd9f0975bb, #7727) only adds a helper that no pa_decode file calls, so the base is current for PA.

or (
not per_token_kv
and tile_demand is not None
and tile_demand <= 8 * num_compute_units

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.

[major] (finding 1) In ATOM's call style, the gfx950 FP8 MTP split and split-major almost never fire, so the PR's speedups apply to bounded calls only.

Two of the new gfx950 gates depend on max_context_length (L284-289): the FP8 split here needs tile_demand <= 8 * num_compute_units, and split-major needs split_workgroups <= num_compute_units // 4 (L565). pa_decode() always passes a bound: the caller's own, or max_blocks_per_seq * block_size (the block-table capacity) when the caller passes None (pa_decode.py:921, 1063). ATOM passes the table capacity.

MI355X, 256 CUs, 128K-token table = 512 tiles:

  • FP8 split: fires only while seqs x kv_heads <= 4, and then only 2-way. The gfx950 MTP default plan holds capacity x heads at 256 (pa_decode_plan.py:434-451), so the 4-way test 4 * 256 <= 3 * 256 fails.
  • Example: llama70b-tp8 (FP8 per-tensor, MTP4, G8, page 16), B=8, 4K real contexts. Bounded call: tile_demand 128, 4-way split. ATOM call: tile_demand 4096 > 2048, no split, same kernel as base.
  • Split-major: never fires on default plans, because capacity x heads >= 256 > 64. ATOM's D256 plan (64 partitions / budget 256) reaches 64 only at B1/H1, where FP8 D256 never query-splits.
  • The UT showcase mtp4-g16-page128-direct (2.17x) compiles the base kernel when called ATOM-style.
  • The matrix comes from the test's case dicts, which are bounded by their lengths, so the 1.19x / 1.54x headline and the per-commit 1.19x / 1.13x describe bounded callers. [FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) #7709 had the same gap (1.16x bounded vs 1.08x ATOM-style).
  • Not a regression: base does not split these cases either.

The self-review bullet "Callers that pass no max_context_length get no tile bound, so their FP8 MTP rows do not split" is wrong: they get the table-capacity bound, exactly as ATOM does. tile_demand is None only for direct PaDecodeSchedule.select / compile_pa_decode_tile callers.

Suggestions:

  • Add ATOM-style rows next to their bounded twins: bound = table capacity, default plan, FP8 per-tensor, page 16, llama70b G8 and qwen3-235b G16 MTP4 at B1-64.
  • Correct the self-review bullet.
  • Say in the comment at L338-340 and in the PR body that with a capacity-sized bound the FP8 split needs seqs x kv_heads <= 4 and split-major needs a small plan.
  • Or key these gates on a load signal that table padding does not inflate.

This harness could not re-measure it: no MI355X GPU was free at 15:27 Beijing time (UTC+8).

or (
M_TILES == 1 and gfx942_busy and kv_row_bytes >= STREAM_KV_ROW_BYTES
)
or (M_TILES == 1 and busy_grid and kv_row_bytes >= STREAM_KV_ROW_BYTES)

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.

[minor, plausible] (finding 2) In ATOM's call style, gfx950 decode tiles with 384-1023 B rows now stream even when few CTAs hold work, and this was never timed.

busy_grid = split_workgroups * query_splits > CUs (L475), with split_workgroups = min(capacity * heads, tile_demand). With a table-capacity bound, tile_demand is huge, so for decode busy_grid reduces to capacity * heads > CUs. gfx950 decode default plans have a 2 x CUs budget, so capacity x heads = 512 for B>=2 or H>=2 whatever the real lengths. This single-M-tile arm now selects on gfx950 for 384-1023 B rows without prefetch_v.

Example: FP8 D512 page 16 decode, B=2, 4K real contexts.

  • Bounded call: split_workgroups = 32, so busy_grid is False and the tile does not stream.
  • ATOM-style call: split_workgroups = 512, so busy_grid is True and the tile streams, though only 32 CTAs hold work.
  • BF16 D192/D256 decode at page 64/128 behaves the same way.

The comment at L986-988 says streaming "only pays when more CTAs than CUs hold work". Base never streams these rows on gfx950, and commit 1's A/B (96 bounded cases) did not time this selection. MTP two-M-tile rows are much less exposed: gfx950 MTP plans keep capacity x heads at 256 while B x H <= 64.

Suggestion: time FP8 D512 page 16 B2 and BF16 D256 page 128 B2 decode ATOM-style (bound = table capacity), base vs head. If streaming loses, key the gfx950 busy arms on a real-load signal instead of plan capacity.

# Two waves per SIMD only pay when two CTAs per CU have work.
gfx942_two_per_cu = (
gfx942_busy and split_workgroups * query_splits >= 2 * num_compute_units
two_per_cu = (

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.

[minor] (finding 3) two_per_cu is now a gfx950 cache-key dimension that no gfx950 code reads, so identical kernels are traced twice.

Before this PR gfx942_two_per_cu was always False on gfx950. Now two_per_cu varies on gfx950 too and is stored in PaDecodeCacheKey (L174, L607). Its only consumer is WAVES_PER_EU_2 = not is_gfx950 and two_per_cu and ... (L1011-1013), so it changes no gfx950 code. (busy_grid is exactly not sparse_grid, so it adds no new key split.)

Example: gfx950 FP8 D128 G8 decode, default plan (budget 512), bounded 4K contexts. B=24 gives split_workgroups 384 (two_per_cu False); B=32 gives 512 (True). No other key field differs. On base both batches share one key; on head each misses _PA_DECODE_TILE_CACHE (pa_decode_kernel.py:328) separately and pays one more FlyDSL trace for the same binary. That hits every warmup or graph-capture bucket on either side of 2 x CUs.

Suggestion:

two_per_cu = (
    "gfx94" in arch
    and busy_grid
    and split_workgroups * query_splits >= 2 * num_compute_units
)

gfx942 keys stay the same and gfx950 keys return to base.

M_TILES == 1 and gfx942_busy and kv_row_bytes >= STREAM_KV_ROW_BYTES
)
or (M_TILES == 1 and busy_grid and kv_row_bytes >= STREAM_KV_ROW_BYTES)
or (

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.

[minor] (finding 4) No UT case reaches the newly enabled busy-grid STREAM_KV arms on gfx950.

These arms (single M-tile with 384-1023 B rows; two M-tiles with 256-1023 B rows) select only when split_workgroups * query_splits > CUs. On MI355X no test_pa_decode case gets there:

  • head192-decode: split_workgroups 24; head192-mtp: 24 x 2 splits = 48 CTAs; head192-np80: 80;
  • FP8 packed-mtp4 (D256 kv2 page128, two M-tiles): 60;
  • BF16 window (two M-tiles after the split): 36.

In UT only rows of 1 KiB or more stream (head512, head1024), so the streamed QK with fewer than four head groups per piece (e.g. D192: piece = min(4, 3)) is never exercised. The body's "the existing cases reach every new gfx950 specialization: the head1024/head512/head192 streamed rows" is wrong for head192. The busy arms (BF16 D192/D256, FP8 D512, BF16 D128 page16/64 two-M-tile MTP, FP8 D256 page128 two-M-tile) were checked only by the offline matrix, and MI35X CI never runs them. Nothing pins STREAM_KV either: _check_pipe_policy asserts only cache_key[-2:].

Suggestions:

  • Add one or two busy-grid cases that stream on gfx950, e.g. BF16 D192 decode and FP8 D256 page128 MTP4 kv2, with lengths/budget giving more than 256 workgroups.
  • Extend _check_pipe_policy, or add PaDecodeTraits.create assertions, to pin STREAM_KV per arch: True for BF16 D512 and FP8 D1024, False under BF16_MTP_FUSED and D256_PIPE.
  • Correct the "Changed op tests" paragraph.

if const_expr(self.traits.buffer_plan_output):
# Widen before multiplying: packed storage can exceed 2 GiB.
pout_slot = fx.Int64(self.ctx.kv_h) * fx.Int64(gpu.grid_dim.x) + fx.Int64(
slots = getattr(gpu.grid_dim, "y" if self.traits.SPLIT_MAJOR else "x")

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.

[minor] (finding 5) The split-major planned-output fix is covered by a single BF16 UT case just under the gate, and no FP8 case reaches it.

This line only changes results when buffer_plan_output (gfx950 D128, BF16 query), SPLIT_MAJOR and kv_heads >= 2 all hold; with one KV head pout_slot = part whichever axis is read. Only BF16 mtp4-g16-page128-cluster reaches that combination, with split_workgroups = min(422, 62*5) = 60, just under the CU//4 = 64 gate. A device or partition with fewer than 240 CUs, a change to its lengths, or a retuned gate makes it slot-major, and the fix goes untested with nothing failing.

buffer_plan_output also covers FP8 KV with a BF16 query (traits.py:795-800), but no FP8 kv>=2 case reaches split-major: cluster16-runs-page128-kv2 has split_workgroups = 72 > 64. The negative control (9 failures) ran on cbffdd201b, not on this head, and is not part of the suite.

Suggestions:

  • Add an FP8 (BF16 query, per-tensor) twin of mtp4-g16-page128-cluster.
  • Assert split_major for both cases via PaDecodeSchedule.select, as _check_pipe_policy does for D256_PIPE.
  • Optionally use pout_slot = fx.Int64(self.ctx.partial_slot): it is the same value, and context.py:76-84 already picks the axis, so the grid axes keep one source of truth.

sparse_grid: bool
gfx942_busy: bool
gfx942_two_per_cu: bool
busy_grid: bool

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.

[minor] (finding 6) Overlap with #8000 (gfx950 MXFP4 pa_decode, open).

  1. Same op_epilog.py:35 line: [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000 rewrites pout_slot to logical_slots(self.ctx.traits), and its logical_slots already returns grid_dim.y under SPLIT_MAJOR, so taking [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000's line is correct.
  2. Renamed key fields: [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000 still declares and reads gfx942_busy / gfx942_two_per_cu in its key, select() and create(), and rewrites split_major = "gfx94" in arch and (...). All of these conflict with this rename and with the new gfx950 split_major gate.
  3. heads_fastest vs split_major: [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000's heads_fastest is not limited to MXFP4. Its condition (gfx950, non-direct, num_kv_heads * query_splits > 1, num_seqs * bound_tiles < work_capacity) covers the same sparse gfx950 FP8/BF16 regime where this PR sets split_major, e.g. FP8 MTP4 G16 B1 ctx1K with the default plan (this PR: query_splits 4 + split-major; [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000 alone: heads_fastest). In [FlyDSL] [Perf] pa_decode: gfx950 MXFP4 KV — MTP, large groups, pages 16/64, sinks/windows, head_dim 64-512, and faster decode #8000's logical_block and launch grid SPLIT_MAJOR wins, so once both land heads_fastest is dead wherever split_major fires, and neither PR measured that combination.

Suggestion for whichever PR merges second: carry the busy_grid/two_per_cu rename into #8000's key and create(), keep logical_slots for pout_slot, exclude split_major from heads_fastest explicitly or document the precedence, and re-time the overlapping gfx950 FP8/BF16 sparse cases (query_splits > 1 or kv_heads >= 2, split_workgroups <= CUs/4).

# instead of after every slot of the previous split. BF16 head-dim
# splits forced by LDS only gain when tasks are long. Several KV heads
# launch head-major on small grids, where the plan's empty slots
# otherwise delay every head after the first. gfx950 gains only while

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.

[nit] (finding 7) Comment accuracy.

  • This comment says gfx950 gains "only while at most a quarter of the CUs hold work", but the gate (L565) compares split_workgroups, the task count before query splitting. FP8 MTP4 B16 ctx1K has split_workgroups 64 and query_splits 4: it passes and launches 256 CTAs, one per CU. Reword to "while tasks, before query splitting, fill at most a quarter of the CUs", or gate on split_workgroups * query_splits if that was the intent.
  • L33 still says "# gfx942 K/V streaming (PaDecodeTraits.STREAM_KV)", but these constants now drive gfx950 too. Make it arch-neutral.

is_gfx950
and kv_dtype != MXFP4_KV_DTYPE
and (kv_dtype in FP8_KV_DTYPES or head_dim <= 128)
and split_workgroups <= num_compute_units // 4

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.

[nit, plausible] (finding 8) The matrix's sample points do not pin either new gfx950 threshold.

Every split-eligible FP8 geometry in the matrix has kv_heads = 1, so over batch {1,16,64} x ctx {1K,8K,32K} tile_demand takes only 4/32/128, 64/512/2048 and 256/2048/8192.

  • The 8 x CUs = 2048 bound admits both 2048 points and excludes only 8192 (the 0.87x case), so any bound from 2048 to 8191 gives identical matrix results.
  • This CU//4 = 64 gate admits split_workgroups up to 64 and the next sample is 128 (B1/32K), so any value from 64 to 127 gives identical results.
  • Both bounds were measured only at 256 CUs, as the body notes.

Suggestion: add intermediate points so the data pins the bounds (tile bound: e.g. B32/16K = 2048 tiles, B48/16K and B32/24K = 3072; split-major: split_workgroups 72-128), or derive both bounds instead.

…e CTAs per CU

#7709 streams K/V for single M-tiles with 384-1023 B rows and paired
M-tiles with 256-1023 B rows once more CTAs than CUs hold work. On gfx942 a
sliding window bounds every task to a few tiles, and there streaming only
pays on much fuller grids: on MI308X (80 CUs) BF16 MTP4 G16 D128 windows
(w257, w700) at 1.2-2.4 CTAs per CU ran 0.83-0.91x with streaming, and
from 3.6 CTAs per CU 1.15-1.27x.

Windowed gfx942 rows now take the busy-grid streaming arms only above
three CTAs per CU (new cache-key field stream_busy). Unwindowed rows, every
other busy_grid consumer and every gfx950/gfx1250 selection are unchanged.

MI308X, paired in-process ABBA, 20 pairs: the 13 changed cases run 1.128x
faster with cold KV (512 MB rotation; 1.095-1.221x) and 1.101x warm, all
bit-exact. Of 3726 schedule-checked cases (UT matrix, off-grid probes,
prod sweep) only these 13 change. gfx950 and gfx1250 binaries are
identical to the previous head; pytest op_tests/test_flydsl_pa_decode.py
on gfx942: 357 passed / 108 skipped, the same as main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 05:59

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FlyDSL stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants