Skip to content

[FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) - #7709

Merged
coderfeli merged 19 commits into
mainfrom
fsx950223/pa-gfx942-opt
Nov 13, 2026
Merged

coderfeli merged 19 commits into
mainfrom
fsx950223/pa-gfx942-opt

Conversation

@fsx950223

@fsx950223 fsx950223 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Speeds up the FlyDSL pa_decode tile kernel on gfx942 (MI300-series) by fixing register spills, hiding load latency and picking schedules by grid size. gfx950 and gfx1250 kernels are bit-for-bit unchanged.

On all 786 cases of the unit-test-geometry matrix described below, against current main (which now includes #7700): geomean 1.34x (unit-test cases 1.39x, grid cases 1.33x). Six cases are below 0.995x, the lowest at 0.97x; see "Known regressions".

Commit 17 fixes a first-tile LDS race in the streamed path (commit 1), found while porting streaming to gfx950.

After #7700 landed, this branch merged main (71af0c22ba). #7700 extends four gfx950 paths to gfx942. The merge keeps both sides, and commit 18 (ce737ce698) resolves the one interaction that cost speed.

Motivation

The gfx9 schedule was tuned on gfx950. On gfx942 it has four problems.

  1. Spills at large head dims.
    • The tile holds the next tile's whole K prefetch and the tile's whole V gather in VGPRs.
    • At D512/D1024 this hits 512 VGPRs and spills 350-2000 registers to scratch: 15-300x off the HBM roofline.
  2. Exposed load latency. V loads issue after the P barrier and are consumed at once. ATT on MI308X also shows two in-order vmcnt waits:
    • Q staging waited behind the first tile's K loads (about 1000 cycles of a 9500-cycle task).
    • The next tile's page-id read sat behind V loads (vmcnt(0), about 1000 of 4400 cycles per tile).
  3. Occupancy.
    • FP8 D128 MTP tiles need 260-272 VGPRs, and FP8 D256 / BF16 two-M-tile MTP 272-324. Either way, one wave per SIMD.
    • The default plan launches 2 CTAs per CU, so on busy grids half of them wait.
  4. Small grids. MTP rows run all query positions in one CTA. With few sequences most CUs idle, and that CTA's serial latency is the decode time.

Changes

The changes are all in aiter/ops/flydsl/kernels/pa_decode/{traits,pipeline,op_lds}.py and pa_decode_kernel.py. They are gfx942-only, selected by "gfx94" in arch or not is_gfx950. One commit each:

  1. c52a931dfb K/V streaming (STREAM_KV).
    • Applies to rows of at least 1 KiB (FP8 D1024, BF16 D512+) on any grid.
    • The tile carries page ids instead of K. K streams in pieces of 4 head groups (2 in flight), V in head chunks (4 in flight), with a sched_barrier(0) per chunk.
    • M-tiles share every chunk, each with a private P slot behind one barrier.
  2. a5a617efcc V prefetch for single M-tiles: FP8 up to D256 and BF16 page16 D128. This reuses gfx950's prefetch_v schedule.
  3. 9428a0946d Busy-grid flag gfx942_busy (host-bounded busy CTAs above the CU count). It is a cache-key field placed before D256_PIPE. On busy grids:
    • FP8 D128 MTP compiles with waves_per_eu=2;
    • single-M-tile streaming of 384 B-1 KiB rows (BF16 D192/D256) is enabled.
  4. 2fa4680059 Q loads before the first K tile. Padding rows are clamped to the last real row and still zero-filled when staged.
  5. 20ee766cfb The next tile's page-table read before this tile's V loads, fenced. The pin to the context runs at the use.
    • Applies to FP8 per-tensor single M-tiles and MTP M-tiles.
    • Excludes BF16 with two M-tiles.
  6. b499cb7234 FP8 per-tensor page128 vectorized-V prefetch only on busy grids.
  7. 64a9ea306a waves_per_eu=2 for busy streamed BF16 D256 (254 VGPRs, no spills).
  8. 1df843bf23 Streaming for two-M-tile MTP from 256-byte rows on busy grids (FP8 D256 and BF16 D128 GQA8 MTP4).
  9. d5691dd522 Idle-CU query split for MTP rows. Each split CTA re-reads K/V, mostly from L2.
    • FP8 up to D128: 4-way while 4 * busy CTAs <= 3 * CU, else 2-way while busy CTAs <= CU.
    • BF16: 2-way while 2 * busy CTAs <= CU.
  10. 8f9fe39e4d No V prefetch for busy FP8 per-token D256 page64 (that gfx950-tuned schedule was 0.88-0.93x there).
  11. ece634218b Split-major grid (KV heads x query splits, capacity) for query-split kernels.
    • The tile grid dispatches x first, so a task's later splits waited behind every slot of the previous split, empty padding slots included.
    • Now a task's splits dispatch together and share the K/V they re-read.
    • BF16 splits forced by the LDS limit at large head dims use it only when tasks own at least 4 tiles.
  12. db5c85c726 Head-major grid for several KV heads on small grids, for the same reason.
  13. 922fde04d7 Windowed MTP splits on busier grids. A sliding window bounds each task to a few tiles, so:
    • FP8 splits into single-M-tile CTAs on any grid;
    • BF16 splits two-way while four split CTAs fit per CU.
  14. 26f640138e BF16 D64 MTP splits like FP8: 128-byte rows, as with FP8 D128.
  15. df92172a41 waves_per_eu=2 only when the host-bounded busy CTAs fill two per CU (cache-key field gfx942_two_per_cu). Below that it only cost spills: the long-row UT case mtp4-g16-page128-varied was 0.94x.
  16. 8274dfbc42 Busy BF16 D128 MTP4 rows split two-way.
    • With split-major launches the two CTAs share K/V and fit two per CU (360 -> two-M-tile streamed tiles).
    • D192 and two-M-tile rows measured slower and are excluded.
  17. 65eed8399b [Bugfix] Streamed tasks read the first tile's page ids before restaging them.
    • Streamed tiles stage the next tile's page ids in LDS at the tile start. The prologue stages the first tile's ids, and every wave reads them back after its barrier.
    • Nothing ordered that read before the first tile's restaging. A slow wave could therefore gather 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.
    • Seen as run-to-run output differences of up to 1.4e-3 on FP8 per-tensor D256 MTP4 two-head B64 grids: 2 of 200 runs on gfx942, and 8-16 of 20 on gfx950 once streaming is enabled there.
  1. ce737ce698 No BF16 page16 V prefetch under gfx942 dual tile groups.

Not changed:

  • the API, plan_pa_decode and its 2CU default budget (a 3CU budget measured 0.956x on the tuned head);
  • the reducer, the softmax/scaling math and its order.

Performance (if applicable)

Measured on an 80-CU MI308X (gfx942) with FlyDSL 0.5.0. Before = main 769ba404ba (with #7700), after = ce737ce698.

  • Timing: paired in-process A/B. Main and this PR run in one process on the same inputs, each as a CUDA graph of 10 decodes, with ABBA-alternated replays (20 pairs x 10 replays). The time is the median per decode, including the reducer.
  • Plan: the default (max_partitions = CU, budget 2*CU, with [FlyDSL] [Perf] pa_decode: gfx950 fused BF16 MTP4 verify tile, decode load scheduling and lean FP8 MTP4; four paths extended to gfx942 #7700's min-max task balancing on gfx942).
  • Cases: the unit-test geometries of op_tests/test_flydsl_pa_decode.py, each at its own UT lengths plus batch {1,16,64} × uniform context {1K,8K,32K}.
  • Noise: unchanged control cases read 0.98-1.02. A watcher checked for foreign GPU workloads; the end-to-end run was clean.
Hardware Workload/configuration Before After Change
MI308X (gfx942, 80 CU) All matrix cases, 786 cases geomean 1.34x (0.97-6.60x)
MI308X Unit-test cases at their own lengths and plans, 111 cases geomean 1.39x (1.00-5.87x)
MI308X Grid cases (batch 1/16/64 x ctx 1K/8K/32K), 675 cases geomean 1.33x (0.97-6.60x)
MI308X BF16 D1024 (MTP1, split MTP3/4), 30 cases geomean 5.12x (3.01-6.60x)
MI308X BF16 D512 MTP4, 10 cases geomean 3.15x (2.32-4.34x)
MI308X FP8 D1024 page128 GQA4, 40 cases geomean 2.48x (1.91-5.50x)
MI308X Sliding-window MTP4, 70 cases geomean 1.41x (1.00-1.94x)
MI308X FP8 D128 MTP4/5/8 page128, 172 cases geomean 1.35x (1.01-2.73x)
MI308X BF16 D64/D128/D192 MTP, 112 cases geomean 1.13x (0.97-1.91x)
MI308X BF16 D192/D256 decode, 21 cases geomean 1.16x (1.00-1.43x)
MI308X FP8 page16 D128 decode, 88 cases geomean 1.15x (1.01-1.48x)
MI308X FP8 D256 (page16/64/128), 120 cases geomean 1.13x (0.98-1.52x)
MI308X FP8 D64 MTP3 (2 KV heads), 40 cases geomean 1.12x (1.00-1.48x)
MI308X BF16 page16 D128 decode, 24 cases geomean 1.10x (1.00-1.21x)
MI308X FP8 page128 D128 decode, 48 cases geomean 1.09x (1.00-1.31x)
MI308X BF16 page128 D128 decode, 11 cases geomean 1.01x (0.97-1.04x)
MI308X FP8 page16 D128 per-tensor, B64 ctx32K 349.5 us 239.7 us 1.46x
MI308X FP8 page16 D128 per-tensor, B1 ctx1K 8.8 us 8.5 us 1.03x
MI308X UT mtp4-g16-page128-direct (FP8 per-token) 46.9 us 18.2 us 2.57x
MI308X FP8 MTP4 window 257, B1 ctx8K 16.0 us 8.9 us 1.79x
MI308X BF16 MTP4 window 257, B16 ctx8K 19.1 us 14.2 us 1.35x
MI308X FP8 MTP4 GQA16 page128, B64 ctx8K 232.6 us 177.8 us 1.31x
MI308X BF16 MTP4 GQA16 page128, B64 ctx8K 342.2 us 302.7 us 1.13x
MI308X FP8 D1024, B16 ctx8K 317.3 us 111.0 us 2.86x
MI308X BF16 D1024, B16 ctx8K 1268.0 us 236.5 us 5.36x
MI308X BF16 D1024 MTP4, B16 ctx32K 15931.6 us 2414.5 us 6.60x

The end-to-end run covers every case on an idle GPU. Commit 18 changes only the three cases it targets, and their numbers above are its re-measurement. Outputs:

  • 0 errors, 0 non-finite;
  • 720 of 786 are bit-exact vs main;
  • the other 66 (streamed MTP, per-token V prefetch, split windowed rows) differ by at most one bf16 ulp (4.1e-3 relative). On each, the max error against the fp32 reference is identical to main's.

Per-commit A/B for commits 13-16, measured against the pre-#7700 main:

Hardware Commit / workload Change
MI308X 13: windowed MTP4, 70 cases geomean 1.045x (BF16 window B16 1.32-1.34x, FP8 window B64 1.18-1.20x)
MI308X 14: BF16 D64 MTP, 41 cases geomean 1.017x (UT mtp4-g16-page128-cluster-d64 1.38x)
MI308X 15: mtp4-g16-page128-varied UT case 1.01-1.10x, removing the earlier 0.94x regression
MI308X 16: BF16 D128 MTP4/8 page128, batch >= 16 1.03-1.10x

Commit 17 (the race fix) against 8274dfbc42, on all 161 streamed matrix cases: geomean 1.0005x (clean MI308X run). The end-to-end numbers above are from 8274dfbc42; the fix only adds one barrier per streamed task.

Known regressions against main with #7700. They were none below 0.99x before #7700; the attribution comes from an A/B of early Q on/off over all 786 cases:

Early Q still gains 0.9% over the whole matrix, so it stays on. A shape-specific rule is left to a follow-up tuning pass.

Testing

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

op_tests/test_flydsl_pa_decode.py passes in full on MI308X (gfx942) at every commit, including the merge and ce737ce698: 285 passed, 107 skipped (MXFP4 is gfx950-only). On MI355X (gfx950) the merged branch passes 355, with 37 skipped. The existing cases cover:

  • every streamed path: head1024 (FP8 and BF16), head1024-mtp-split3/4, head512-mtp-split2, head192-*, head256 (BF16);
  • the new V-prefetch shapes: decode, small_query/probability_tail page16/page128, cluster8/16, head256, d256-*, mtp, in per-tensor, per-token, plain-V and vectorized-V variants;
  • window, sink and capture variants;
  • query splitting: the MTP4/MTP8 -direct/-merge/-probability_tail cases, window, head192-mtp, graph-workspace.

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 selection of supported shapes are unchanged; the change is internal to the gfx942 tile schedule.

Dependencies

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

Breaking Changes

None

PR Self-Review

Reviewed revision

ce737ce

Behavior and intent

On gfx942 the pa_decode tile schedule now follows its register budget and grid size. gfx950 and gfx1250 compile to identical binaries.

  • Spill avoidance: K/V streaming at large head dims removes 350-2000-VGPR spills (2-6x on D512/D1024).
  • Latency hiding:
    • V prefetch;
    • Q loads before K;
    • next-tile page ids before V.
      Each removes an in-order vmcnt wait that ATT showed on the critical path.
  • Busy grids: two waves per SIMD for 260-324-VGPR MTP tiles.
  • Small grids: MTP query rows split over idle CUs. Split and multi-head grids launch split-/head-major, so useful CTAs no longer queue behind the plan's empty slots.

The old schedule was tuned on gfx950 and left these on the table on MI300.

Commit 17 also orders the streamed prologue's page-id read before the first tile restages those ids. Without it, streamed outputs could differ between identical runs.

The merge with main keeps #7700's new gfx942 paths: one-partition direct output, the min-max planner, dual-group CTAs and packed Q absmax. This branch's policies are layered on top of them. Commit 18 keeps BF16 page16 V prefetch out of dual-group tasks, where it lost.

Validation and unverified scope

Evidence:

  • pytest op_tests/test_flydsl_pa_decode.py on MI308X (gfx942, FlyDSL 0.5.0) at every commit: 285 passed, 107 skipped.
  • Paired in-process A/B (CUDA graphs, ABBA replays): per commit vs its parent, plus end-to-end main (with [FlyDSL] [Perf] pa_decode: gfx950 fused BF16 MTP4 verify tile, decode load scheduling and lean FP8 MTP4; four paths extended to gfx942 #7700) vs ce737ce on all 786 matrix cases. Geomean 1.34x, two cases below 0.98x (see Known regressions), 0 errors, 0 non-finite.
  • Changed numerics:
    • query splits and the page-id order are bit-exact;
    • streamed MTP and per-token V prefetch move outputs by at most one bf16 ulp, with unchanged max error against the fp32 reference.
  • Adversarial magnitudes: with K/V scaled per token by exp(N(0,1)) before per-token FP8 quantization, main and 8274dfb have identical relative max error against the fp32 reference on every changed per-token path (page16/page128 decode, D256 page64, MTP4, window, D1024).
  • Compile-only cross-arch replay of every matrix case under COMPILE_ONLY=1, main (with [FlyDSL] [Perf] pa_decode: gfx950 fused BF16 MTP4 verify tile, decode load scheduling and lean FP8 MTP4; four paths extended to gfx942 #7700) vs ce737ce: gfx950 148/148 and gfx1250 166/166 binaries identical.
  • After the merge, every one of 246 streamed, one-partition and dual-group matrix cases repeats bit-exactly over 20 launches. The 66 non-bit-exact cases match main's max error against the fp32 reference.
  • Determinism, 200 launches per case on the FP8 D256 MTP4 two-head B64 cases (det_check.py): 8274dfb differs in 2/200 runs on two of them (up to 1.4e-3); 65eed83 repeats bit-exactly in 200/200 everywhere.
  • Commit 17 cost: 1.0005x geomean over all 161 streamed matrix cases (paired A/B).

Unverified:

  • Not run on MI300X (304 CU), MI325X or MI250X. The busy and idle-CU thresholds scale with the CU count but were only measured at 80 CUs.
  • Shapes outside the unit-test geometry matrix are not covered.
  • Callers that pass no max_context_length use the block-table capacity as the bound. They therefore see busy-grid schedules and no query split.

PR-specific question

There are three boundaries.

The gfx942-only selectors ("gfx94" in arch in select, not is_gfx950 in create) must never change gfx950 or gfx1250:

  • gfx950's tuned prefetch, MTP4-fused and MXFP4 schedules own the same shapes.
  • The compile-only replay shows 133/133 gfx950 and 166/166 gfx1250 binaries identical to main.

The new cache-key fields (gfx942_busy, gfx942_two_per_cu, split_major) must keep the test's cache_key[-2:] = (D256_PIPE, stage_pages):

Split-major grids must not misplace one-partition output on gfx942. #7700 brought direct one-partition output to gfx942. Its empty-row zero fill now takes the KV head from the grid axis that SPLIT_MAJOR selects. With that fix reverted on gfx950 (where #7858 opens split-major), 9 unit tests fail; with it they pass.

Query splits must keep every query row's math unchanged:

  • The split goes through the existing query_splits path that BF16 LDS splitting already uses.
  • Split-/head-major grids only swap which block-id axis names the slot. partial_slot stays kv_head * capacity + slot, so the reducer's partial layout is unchanged.
  • The query_splits in (1, 2, 4) and query_length % query_splits == 0 asserts stay.
  • Split outputs are bit-exact in the A/B, and the MTP unit tests pass.

Changed op tests

None. The existing test_pa_decode cases already exercise every streamed, prefetched, query-split and waves_per_eu=2 specialization and pass. The MTP4/8 cases reach the split path, and the -varied long-row case reaches the busy-grid path.

🤖 Generated with Claude Code

… 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]>
@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 7709 --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 and others added 2 commits November 10, 2026 07:18
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]>
@fsx950223 fsx950223 changed the title [FlyDSL] [Perf] pa_decode: gfx942 tile-kernel tuning (stream K/V at large head dims) [FlyDSL] [Perf] pa_decode: gfx942 tile-kernel tuning (K/V streaming, V prefetch, occupancy policy) Nov 10, 2026
fsx950223 and others added 7 commits November 10, 2026 09:10
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]>
A CTA runs all query positions of an MTP row together. On small grids (few
sequences, short contexts, sliding windows) most CUs are idle, and the
CTA's serial latency (four M-tiles of QK, softmax and PV per tile) is the
decode time. On gfx942 the schedule now splits the query positions over
more CTAs when they fit; each re-reads the row's K/V, mostly from L2:
- FP8 up to D128: one M-tile per CTA (4-way) while 4x the host-bounded busy
  CTAs fit about three per CU, else 2-way while two per CU fit.
- BF16: 2-way while one per CU fits.
Busy grids keep the unsplit occupancy schedules. Outputs and their fp32-
reference error are unchanged, since rows are independent.

Paired in-process A/B vs 9428a09 on MI308X (gfx942):
- 111 unit-test cases: geomean 1.19x (MTP4/8 UT cases 1.4-2.4x)
- 180 MTP grid cases: geomean 1.056x (batch 1 up to 1.45x; busy grids 1.00x)
FP8 D256 (0.93-1.05x) is excluded.

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

FP8 per-token D256 page64 single tiles with V prefetch take the per-token
M1 schedule, which was tuned on gfx950. On busy gfx942 grids it was
0.88-0.93x vs main (B16 ctx32K, B64 ctx8K/32K). On small grids it gains
1.01-1.07x. Busy grids keep the unprefetched schedule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fsx950223 fsx950223 changed the title [FlyDSL] [Perf] pa_decode: gfx942 tile-kernel tuning (K/V streaming, V prefetch, occupancy policy) [FlyDSL] [Perf] pa_decode: gfx942 schedule tuning (K/V streaming, latency hiding, grid-size policies) Nov 10, 2026
fsx950223 and others added 6 commits November 10, 2026 10:57
The tile grid is (plan capacity, KV heads x query splits). Dispatch walks x
first, so split 1 of task 0 dispatches only after every slot of split 0,
padding slots included. On small grids, where the plan has many more slots
than tasks, the splits ran in sequential waves of mostly empty CTAs. On
large grids a task's splits ran far apart, each re-reading the task's K/V
from HBM.

On gfx942, split kernels now launch (KV heads x query splits, capacity), so a
task's splits dispatch together. They run concurrently and share the K/V
they re-read. The cache key records the choice. BF16 splits forced by the LDS
limit at large head dims only use it when tasks own at least four tiles; with
fewer, the split-major grid measured 0.93-0.97x.

Paired in-process A/B vs 8f9fe39 on MI308X (gfx942):
- 180 MTP grid cases: geomean 1.092x
  - FP8 MTP4/8 batch 1: 1.04-1.45x
  - FP8 sliding-window MTP4 batch 1/16: 1.28-1.63x
  - BF16 D1024 MTP batch >= 16 with ctx >= 8K: 1.10-1.26x
- 111 unit-test cases: geomean 1.018x (MTP4/8 and window cases 1.16-1.20x)
gfx950 binaries are unchanged.

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

The same dispatch-order effect as query splits: with grid (capacity, KV
heads), a second KV head's tasks dispatch only after every slot of the
first head, including the plan's empty padding slots. On small gfx942 grids
the planned capacity far exceeds the tasks, so heads now launch head-major
there. Busy grids keep the slot-major order, which measured slightly better
for them (0.93-0.98x head-major).

Paired in-process A/B vs ece6342 on MI308X (gfx942), two-KV-head
geometries: batch 1 ctx 1K/8K 1.11-1.29x (FP8 D64 MTP3, FP8 D256 page16,
BF16 D64 MTP4); other grid sizes and the unit-test cases unchanged.

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

A sliding window bounds every MTP task to a few KV tiles. The task's serial
latency therefore stays the decode time even on grids the idle-CU rule
counts as busy. Windowed MTP tiles on gfx942 now split FP8 into single-M-tile
CTAs on any grid, and BF16 two-way while four split CTAs fit per CU.
Unwindowed rows keep the idle-CU thresholds.

Paired in-process A/B vs db5c85c on MI308X (gfx942), 70 windowed MTP4
cases: geomean 1.045x (grid 1.050x)
- BF16 window 257 batch 16: 1.32-1.34x
- BF16 window 700 batch 64: 1.12-1.18x
- FP8 per-tensor vectorized V batch 64: 1.18-1.20x
Unit-test cases unchanged. The max error against the fp32 reference is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
BF16 D64 rows are 128 bytes, the same as FP8 D128, and their split CTAs
stay small. BF16 D64 MTP rows now split two-way while the unsplit busy CTAs
fit one per CU, as FP8 does, rather than only while the split ones do.

Paired in-process A/B vs 922fde0 on MI308X (gfx942), BF16 D64 MTP
geometries:
- UT mtp4-g16-page128-cluster-d64: 1.38x
- B1 ctx32K and B16 ctx1K: 1.12-1.13x
- everything else 0.99-1.01x
41 cases: geomean 1.017x.

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

waves_per_eu=2 trades spills (FP8 D128 MTP) or nothing (streamed BF16 D256)
for a second resident CTA per CU. That only pays when the host-bounded busy
CTAs fill two per CU. Between one and two per CU it only costs spills: the
long-row UT case mtp4-g16-page128-varied (6 rows up to 4100 tokens) ran at
0.94-0.97x vs main. The cache key gains the two-per-CU flag (before
D256_PIPE).

Paired in-process A/B vs 26f6401 on MI308X (gfx942):
mtp4-g16-page128-varied 1.01-1.10x; grid MTP and BF16 D256 cases unchanged
(0.99-1.01x).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four BF16 D128 M-tiles per CTA hold 360 VGPRs: one wave per SIMD. With
split-major launches (ece6342) a two-way split no longer re-reads K/V
from HBM, since a task's two CTAs dispatch together and share it. Each CTA
then holds two M-tiles and, on busy grids, takes the streamed two-M-tile
schedule at two CTAs per CU. Busy BF16 D128 MTP rows with at least four
M-tiles now split two-way. D192 (0.76-0.83x) and two-M-tile rows
(0.85-0.96x) measured slower and keep their schedules.

Paired in-process A/B vs df92172 on MI308X (gfx942): BF16 D128
MTP4/MTP8 page128 at batch >= 16: 1.03-1.10x; other BF16 MTP cases
unchanged. 92 cases: geomean 1.020x. Max error against the fp32 reference
is unchanged.

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

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

Advisory review. I only have gfx950 here (MI355X): with this PR applied on main cb4ac34, op_tests/test_flydsl_pa_decode.py gives 355 passed / 37 skipped, the same as main, so gfx950 is unaffected, but none of the gfx942 changes were exercised. The points below come from reading the code.

⚠️ No CI job runs the changed code yet. Everything here is gfx942-only, but PR CI runs MI35X by default and the MI300X standard tests are opt-in via ci:mi300x; this PR has no labels and, as a draft, skipped even the MI35X standard tests. Please add ci:mi300x before marking it ready.

⚠️ Thresholds tuned at 80 CUs only. The busy test (split_workgroups * query_splits > CU) and the split rules (for example 4 * busy <= 3 * CU) scale with the CU count, but 304-CU MI300X / MI325X weren't measured (as you note). A small MI300X subset would help before merge.

⚠️ Merge order with #7700. This PR conflicts with #7700 in op_lds.py, pipeline.py, traits.py and pa_decode_kernel.py. Both insert cache-key fields ahead of D256_PIPE (and the positional unpack in create()), and in the launch block #7700 needs block=(traits.CTA_THREADS, 1, 1) for its dual-group CTAs where this PR keeps traits.BLOCK_THREADS. Please agree an order with #7700 and keep CTA_THREADS when rebasing.

Inline: how max_context_length=None callers interact with the busy-grid flag, and the gfx942 gating predicate.

Advisory review, AI-assisted; the runtime numbers come from the runs described above.

…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]>
@fsx950223
fsx950223 marked this pull request as ready for review November 12, 2026 07:35
@fsx950223
fsx950223 requested review from a team and a balanced review from Copilot November 12, 2026 07:35

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 ce737ce698e8 · 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 gfx942 the pa_decode tile schedule now follows its register budget and grid size. gfx950 and gfx1250 compile to identical binaries.
- **Spill avoidance:** K/V streaming at large head dims removes 350-2000-VGPR spills (2-6x on D512/D1024).
- **Latency hiding:**
  - V prefetch;
  - Q loads before K;
  - next-tile page ids before V.
  Each removes an in-order vmcnt wait that ATT showed on the critical path.
- **Busy grids:** two waves per SIMD for 260-324-VGPR MTP tiles.
- **Small grids:** MTP query rows split over idle CUs. Split and multi-head grids launch split-/head-major, so useful CTAs no longer queue behind the plan's empty slots.

The old schedule was tuned on gfx950 and left these on the table on MI300.

Commit 17 also orders the streamed prologue's page-id read before the first tile restages those ids. Without it, streamed outputs could differ between identical runs.

The merge with main keeps #7700's new gfx942 paths: one-partition direct output, the min-max planner, dual-group CTAs and packed Q absmax. This branch's policies are layered on top of them. Commit 18 keeps BF16 page16 V prefetch out of dual-group tasks, where it lost.

Validation and unverified scope

Evidence:
- `pytest op_tests/test_flydsl_pa_decode.py` on MI308X (gfx942, FlyDSL 0.5.0) at every commit: 285 passed, 107 skipped.
- Paired in-process A/B (CUDA graphs, ABBA replays): per commit vs its parent, plus end-to-end main (with #7700) vs ce737ce698 on all 786 matrix cases. Geomean 1.34x, two cases below 0.98x (see Known regressions), 0 errors, 0 non-finite.
- Changed numerics:
  - query splits and the page-id order are bit-exact;
  - streamed MTP and per-token V prefetch move outputs by at most one bf16 ulp, with unchanged max error against the fp32 reference.
- Adversarial magnitudes: with K/V scaled per token by `exp(N(0,1))` before per-token FP8 quantization, main and 8274dfbc42 have identical relative max error against the fp32 reference on every changed per-token path (page16/page128 decode, D256 page64, MTP4, window, D1024).
- Compile-only cross-arch replay of every matrix case under `COMPILE_ONLY=1`, main (with #7700) vs ce737ce698: gfx950 148/148 and gfx1250 166/166 binaries identical.
- After the merge, every one of 246 streamed, one-partition and dual-group matrix cases repeats bit-exactly over 20 launches. The 66 non-bit-exact cases match main's max error against the fp32 reference.
- Determinism, 200 launches per case on the FP8 D256 MTP4 two-head B64 cases (`det_check.py`): 8274dfbc42 differs in 2/200 runs on two of them (up to 1.4e-3); 65eed8399b repeats bit-exactly in 200/200 everywhere.
- Commit 17 cost: 1.0005x geomean over all 161 streamed matrix cases (paired A/B).

Unverified:
- Not run on MI300X (304 CU), MI325X or MI250X. The busy and idle-CU thresholds scale with the CU count but were only measured at 80 CUs.
- Shapes outside the unit-test geometry matrix are not covered.
- Callers that pass no `max_context_length` use the block-table capacity as the bound. They therefore see busy-grid schedules and no query split.

PR-specific question

There are three boundaries.

**The gfx942-only selectors** (`"gfx94" in arch` in `select`, `not is_gfx950` in `create`) must never change gfx950 or gfx1250:
- gfx950's tuned prefetch, MTP4-fused and MXFP4 schedules own the same shapes.
- The compile-only replay shows 133/133 gfx950 and 166/166 gfx1250 binaries identical to main.

**The new cache-key fields** (`gfx942_busy`, `gfx942_two_per_cu`, `split_major`) must keep the test's `cache_key[-2:]` = (`D256_PIPE`, `stage_pages`):
- In #7700's named `PaDecodeCacheKey` they sit before `D256_PIPE`, and `create()` reads them by name.
- The pipe-policy checks pass.

**Split-major grids must not misplace one-partition output on gfx942.** #7700 brought direct one-partition output to gfx942. Its empty-row zero fill now takes the KV head from the grid axis that `SPLIT_MAJOR` selects. With that fix reverted on gfx950 (where #7858 opens split-major), 9 unit tests fail; with it they pass.

**Query splits must keep every query row's math unchanged:**
- The split goes through the existing `query_splits` path that BF16 LDS splitting already uses.
- Split-/head-major grids only swap which block-id axis names the slot. `partial_slot` stays `kv_head * capacity + slot`, so the reducer's partial layout is unchanged.
- The `query_splits in (1, 2, 4)` and `query_length % query_splits == 0` asserts stay.
- Split outputs are bit-exact in the A/B, and the MTP unit tests pass.

Changed op tests

None. The existing `test_pa_decode` cases already exercise every streamed, prefetched, query-split and `waves_per_eu=2` specialization and pass. The MTP4/8 cases reach the split path, and the `-varied` long-row case reaches the busy-grid path.

🤖 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.

fsx950223 added a commit that referenced this pull request Nov 12, 2026
…split-major on gfx950 (#7858)

* [FlyDSL] [Perf] pa_decode: stream K/V for long head rows on gfx950

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]>

* [FlyDSL] [Perf] pa_decode: split MTP query rows over idle gfx950 CUs

#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]>

* [FlyDSL] [Perf] pa_decode: launch sparse gfx950 grids split-major

#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]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
fsx950223 and others added 2 commits November 13, 2026 05:41
Union of #7700 and this branch in the pa_decode tile kernel: this
branch's policies stay gfx942-only and #7700's paths keep their
conditions.

- traits: STREAM_KV, WAVES_PER_EU_2, PAGES_EARLY, GFX942_Q_EARLY and the
  gfx942 V-prefetch rule sit beside #7700's gfx950 flags; the busy,
  two-per-CU and split-major fields join the named PaDecodeCacheKey
  ahead of D256_PIPE, so tests still read (D256_PIPE, stage_pages) last;
  P_BUFFERS covers MTP4_FUSED, D256_PIPE, BF16_MTP_FUSED and STREAM_KV;
  dual-group CTAs exclude streamed tiles.
- pipeline: the streamed prologue barrier precedes #7700's Q-operand
  selection; tile() issues both next-page lookaheads; single_query_tile
  takes the STREAM_KV 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, with #7700's padded-row clamp.
- launch: split-major grid with CTA_THREADS blocks, #7700's gfx950
  kernarg preload, waves_per_eu=2 for FP8_MTP4_LEAN or WAVES_PER_EU_2.
- #7700 now runs one-partition plans on gfx942, whose empty-row zero fill
  read the KV head from block_id("y"); it follows the split-major grid.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l tile groups

#7700 now runs gfx942 one-partition D128 decode on sparse grids as two
tile groups per CTA. There, this branch's BF16 page16 V prefetch measured
0.97x against main (UT decode, small_query and probability_tail page16
GQA8), so the rule now skips those tasks. The selection mirrors the
dual-group preconditions known before the layout: gfx942, one partition,
at most one CTA per CU, one query row, no window, D128, no single-tile
plan. FP8 page16 keeps its V prefetch there (1.03-1.15x vs main).

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

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.

Approving. Checked on gfx942 (MI308X, FlyDSL 0.5.0): pa_decode pytest 285 passed / 107 skipped on both this PR and main; a 40-case A/B is bit-exact vs main; geomean 1.16x with real context lengths and 1.08x (worst 0.996x) ATOM-style without max_context_length, so no regressions.

Non-blocking follow-ups:

  1. The busy/split decisions use plan capacity rather than actual lengths, so most of the MTP short-context gain goes away when max_context_length is not passed (e.g. FP8 MTP4 b4 1K 1.72x -> 1.00x).
  2. Gate the gfx942 paths on is_gfx942 instead of not is_gfx950.
  3. Consider adding the ci:mi300x label so the gfx942 code is exercised in CI.

@coderfeli
coderfeli merged commit 64a9373 into main Nov 13, 2026
@coderfeli
coderfeli deleted the fsx950223/pa-gfx942-opt branch November 13, 2026 11:52
fsx950223 added a commit that referenced this pull request Nov 16, 2026
…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]>
fsx950223 added a commit that referenced this pull request Nov 16, 2026
Resolve conflicts with #7619 (gfx1250 wide steps, shared clusters, MTP4)
and #7709 (gfx942 schedule tuning).

- gfx1250_tile_traits also selects MXFP4 tiles: direct_output becomes
  plan_free, per_token_kv is off, query splits default to
  mxfp4_gfx1250_query_splits, and latency_grid stays off (no page16
  stages). compile_gfx1250_pa_decode(t) validates the MXFP4 limits on the
  traits and refuses cluster_steps/cluster_runs/cluster_seqs for MXFP4.
- Gfx1250Traits keeps plan_free/fuse_tasks after the new fields, which
  the selection passes positionally.
- Kernel: the fuse_tasks branch is unchanged; its else holds main's task
  selection plus the plan-free tasks and the MXFP4 pipeline.
- Host: cluster kernels now read work as context lengths and take
  run_tiles, so MXFP4 cluster launches pass context_lengths and 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fsx950223 added a commit that referenced this pull request Nov 17, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants