Skip to content

[FlyDSL] [Perf] pa_decode: gfx950 reducer issues all partition loads in one rung - #7701

Merged
fsx950223 merged 6 commits into
mainfrom
fsx950223/pa-gfx950-reducer-rung
Nov 16, 2026
Merged

fsx950223 merged 6 commits into
mainfrom
fsx950223/pa-gfx950-reducer-rung

Conversation

@fsx950223

@fsx950223 fsx950223 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On gfx950 the FlyDSL pa_decode partition reducer now uses one 32-partition register rung, so all of its loads issue together. Previously it used a 1-2-4-8-16-32 rung ladder. Its cross-lane max and sum within 16 lanes now use DPP instead of LDS swizzles, and its leading kernel arguments preload into SGPRs. MiniMax-M3 decode and MTP4 verify on MI355X get a geomean of 1.059x; over all 87 timed gfx950 shapes the PR is 1.030x. Two shapes with few live partitions per sequence remain slower than main, by up to -2.6%; they are tabulated below. Outputs are bitwise identical to main, and gfx942 and gfx1250 are unchanged.

Motivation

Every gfx950 pa_decode call launches the reducer after the tile kernel. On short MiniMax-M3 workloads it is 26-53% of the call (~4.1 us of 7.5-13 us).

In dual mode the reducer picks a rung by the live partition count. LLVM hoists the rungs' shared leading loads above that count branch and waits on them there. It then issues the rest in small batches, so 32 live partitions took several serial L2 round trips.

With a single rung, every statistics and partial load issues at once. Partitions past the live count read zeros from the per-sequence buffer descriptor, whose size is the live count times the stride.

Above 32 live partitions, the previous revision issued each group's partial loads before the weight barrier and held them in registers. With one partition group, which large batches get, that rung spans all 256 partitions: the kernel compiled to 266 VGPRs, one wave per SIMD, and ran every partition count at that occupancy. Batches of 128-256 sequences with 2-8 partitions each were 4-9% slower than main.

Before any of those loads, the reducer fetches its partition range from reduce_info. On gfx950 nothing was preloaded and the reduce_info pointer sat at byte 0x50 of the kernel arguments, so every call first waited on a kernel-argument round trip.

Changes

  • gfx950 lane exchanges: the softmax weights' cross-lane max and sum steps at offsets 8/4/2/1 use 16-lane DPP xor patterns (dpp_xor_f32). Before, they used 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. The partner lanes are the same, so results are bit-identical; offsets 16/32 keep the permlane swaps.
  • gfx950 dual mode: dual_rungs = (DUAL_REGISTER_PARTITIONS,), with a sched_barrier(0) after the rung's loads.
  • gfx950 with more than 32 live partitions: each group's loads issue before the weight barrier, as on gfx1250 (_top_first LDS rungs), when a group's rung is at most 64 partitions. A single group of up to 256 keeps main's order and reuses the LDS allocated up front, so that kernel stays at 51 VGPRs instead of 266.
  • gfx950 kernel arguments: reduce_info, the statistics and partials pointers, their strides, query_rows and num_kv_heads lead the kernel's arguments. These are the 14 dwords that preload into user SGPRs, and the preload is enabled, so reduce_info is fetched at once with the remaining arguments in the same round trip. The kernel body is shared (_pa_decode_reduce_body); gfx942 and gfx1250 keep their argument order, and the launch passes arguments through _reduce_args. The preload honors AITER_FLYDSL_KERNARG_PRELOAD and its count (capped at 16), like the other FlyDSL kernels.
  • test_pa_decode_reduce_split_groups (op_tests/test_flydsl_pa_decode.py) now runs on gfx950 as well as gfx1250. On gfx950, dual-mode CTAs (bounds above 64) with split groups must match one group bit for bit, and the dual CTA's single 32-wide rung must match the register-only ladder bit for bit up to 32 live partitions.

Unchanged:

  • other architectures;
  • the register-only (non-dual) reducer;
  • plans and the API.

The PR shares only op_tests/test_flydsl_pa_decode.py with #7700, in different tests; the two heads merge without conflict.

Alternatives I measured and rejected, all keeping every load of a rung in one batch:

  • Rung ladders: (4, 16, 32), (4, 32) and (8, 32) ladders selected by the live count. The smaller rungs' loads were issued in reverse so no two rungs share a leading load.
  • Statistics placement: statistics loads issued before or after the partials.

Every variant cost the 32-partition workloads 1-4% (any count branch ahead of the 32-rung does). None recovered more than about half of the few-partition losses of the time; most of those came from the single-group register occupancy, which the last commit fixes without a branch.

Performance (if applicable)

Method:

  • Paired, in-process A/B. main's and this PR's pa_decode are loaded side by side in one process. They run on identical inputs and plans, each captured as a CUDA graph of 10 calls. Replays alternate ABBA: 20 pairs, 10 replays per sample. The columns are per-version medians; the speedup is the median paired ratio.
  • Inputs: MiniMax-M3 inputs and ATOM call style from zhiding512/pa-benchmark (bench_pa_minimax_m3.py, not part of this PR): tables padded to 256K tokens, default plan. The 67 other shapes are 16 larger page-128 batches and 51 pa_decode review shapes.
  • Environment: MI355X (gfx950, 256 CU), ROCm 7.2.4, FlyDSL 0.5.0, main at d02f9d058a.
  • Noise: a single paired run reads +-2% per shape on short shapes; the lowest readings were re-measured alone, in both orders.

Scored MiniMax-M3 workloads, this PR vs main (geomean 1.059x):

Hardware Workload/configuration Before After Speedup
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b1-q1-ctx8192, bf16 KV 7.78 us 7.03 us +10.6%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b1-q1-ctx8192, fp8 KV 7.53 us 6.78 us +10.9%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b4-q1-ctx8192, bf16 KV 8.02 us 7.12 us +12.6%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b4-q1-ctx8192, fp8 KV 7.74 us 6.90 us +12.2%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b8-q1-ctx8192, bf16 KV 10.17 us 9.37 us +8.6%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b8-q1-ctx8192, fp8 KV 8.14 us 7.25 us +12.3%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b32-q1-ctx8192, bf16 KV 23.89 us 23.62 us +1.1%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b32-q1-ctx8192, fp8 KV 16.47 us 16.17 us +1.9%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b4-q1-ctx32768, bf16 KV 15.88 us 14.97 us +6.0%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b4-q1-ctx32768, fp8 KV 11.01 us 10.36 us +6.2%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b3-q1-ctx225280, bf16 KV 66.11 us 65.07 us +1.6%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-decode-b3-q1-ctx225280, fp8 KV 34.49 us 33.79 us +1.9%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx8192, bf16 KV 12.54 us 11.77 us +6.6%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx8192, fp8 KV 11.00 us 10.21 us +7.8%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx32768, bf16 KV 25.09 us 24.20 us +3.7%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx32768, fp8 KV 16.20 us 15.24 us +6.2%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b8-q4-ctx32768, bf16 KV 38.64 us 37.77 us +2.4%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b8-q4-ctx32768, fp8 KV 23.08 us 22.35 us +3.3%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx225280, bf16 KV 91.13 us 89.96 us +1.3%
MI355X (gfx950, 256 CU) MiniMax-M3 dense-verify-b3-q4-ctx225280, fp8 KV 44.24 us 43.13 us +2.6%

Regressions. Every shape slower than -1.5% among the 67 other shapes:

  • 16 larger MiniMax-M3 page-128 batches, geomean 1.007x;
  • 51 pa_decode review shapes (page 16, D256 page 64, MXFP4, padded tables, budget/hinted plans), geomean 1.026x.

Both have few live partitions per sequence (2 and 4):

Hardware Workload/configuration Before After Speedup
MI355X (gfx950, 256 CU) MiniMax-M3 page-128 dense-decode-b256-q1-ctx4096, fp8 KV 46.91 us 48.21 us -2.6%
MI355X (gfx950, 256 CU) review set R1_fp8_d128_p16_B1H1_tbl128k_ctx1024 9.66 us 9.86 us -2.0%

Further shapes. 40 gfx950 shapes outside both benchmarks (head dim 64 and 256, D128 page 64, GQA 4 and 16, MTP 2-4, sliding windows, per-token FP8 page 16, batch 512, max_partitions and budget plans, MXFP4): 1.0043x, all 40 bit-exact. The lowest, BF16 page-16 GQA-16 B4 16K at 0.974x, reads 1.010x against the previous revision when re-measured alone (candidate first, 20 pairs).

The single-group fix alone (this PR's last commit, measured on top of #7700 and the earlier commits, same method): 1.0022x over all 87 shapes, every output bit-exact; FP8 b256 4K 1.065x, BF16 b256 1.030x, FP8 and BF16 MTP4 verify b32 1.043x and 1.030x. Re-measured alone (candidate first, 20 pairs) over 36 shapes with more than 32 live partitions it reads 1.000x.

The argument preload (the previous commit, measured on top of #7700 and the earlier commits, same method): 1.0032x over all 87 shapes (scored 1.007x, larger page-128 batches 1.006x, review set 1.001x), every output bit-exact. Its short page-16 and head-256 review shapes, re-measured alone (candidate first, 24 pairs), read 0.979x-1.045x with a geomean of 1.003x.

The DPP lane exchanges alone (this PR's second commit, measured on top of #7700 and the first commit): 1.007x over all 87 shapes, every output bit-exact. Short calls gain 1-3% (MiniMax b1 decode, R1/R5b/H1 page 16). Re-measured alone, its lowest shapes are within +-0.4%.

Testing

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

test_pa_decode_reduce_split_groups used to skip everywhere but gfx1250; it now also runs on gfx950 and checks the reducer bit for bit there (see the self-review). The rest of op_tests/test_flydsl_pa_decode.py is unchanged. MI250X is not targeted. gfx942 was tested on an MI308X (80 CU), not an MI300X.

Documentation

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

The compile_pa_decode_ps_reduce docstring gains a gfx950 note on the single rung, next to the comment at the rung selection. No user-facing behavior or API changes, so the guides are unchanged.

Dependencies

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

Breaking Changes

None

PR Self-Review

Reviewed revision

a8b9f03

Behavior and intent

On gfx950 only, the PA decode reducer always runs its widest 32-partition register rung, instead of picking a rung from the live partition count. Above 32 partitions, it issues each group's loads before the weight barrier. Its cross-lane max and sum within 16 lanes use DPP instead of ds_swizzle, whose LDS round trips sat on every short call's critical path, and the arguments its first loads need lead the kernel signature and preload into SGPRs, removing a kernel-argument round trip ahead of reduce_info. Single-group CTAs keep main's load order above 32 partitions, because holding a 256-partition rung in registers dropped the whole kernel to one wave per SIMD. The ladder made LLVM hoist and wait on shared loads, which serialized 32-partition reductions into several L2 round trips. Results are unchanged; only timing changes, in both directions, as tabulated.

Validation and unverified scope

Validation:

  • gfx950 (MI355X): pytest op_tests/test_flydsl_pa_decode.py (main's file with this PR's test change, as CI merges it) passed: 361 passed, 31 skipped. The six test_pa_decode_reduce_split_groups cases that used to skip on gfx950 now run and pass; they pass against main's reducer too.
  • Negative control: a copy of this reducer that adds the dual rung's products in reverse order fails test_pa_decode_reduce_split_groups on gfx950 (head 64, 256 and 512).
  • MiniMax-M3 benchmark correctness, 62 workloads (BF16 and FP8), eager and graph replay with changed inputs and a NaN-filled output: passed. Every output is bitwise identical to main's stored outputs: relative L2 0.00000 for standard and peaked (Q x32) inputs.
  • Paired A/B over 87 shapes: all 87 outputs are bitwise identical to main's.
  • gfx942 (MI308X): pytest gave 285 passed, 107 skipped, both on main d02f9d058a and with this PR (at 02dc5d11b8; the last commit touches only the gfx950 preload hint and a test that skips on gfx942). All 232 compiled PA kernels have identical gpu.binary code.
  • Preload change: the 45 gfx950 PA kernels the 87-shape set compiles have identical gpu.binary code before and after it (default environment).
  • Formatting: black 25.1.0 and ruff 0.16.0 (the version CI pins) are clean.

Not verified:

  • gfx1250 was not run (no hardware). The change is gated on architecture == "gfx950".
  • MI300X was not run.
  • No end-to-end serving run.
  • Beyond the 87 timed shapes and the 40-shape sweep above, other shapes were not measured.

PR-specific question

The changed test is test_pa_decode_reduce_split_groups, the canonical reducer test. Before this PR it skipped on every arch but gfx1250, so on gfx950 nothing in the repository checked the reducer bit for bit; only end-to-end tolerances did. It now runs on gfx950 and fails if:

  • the dual CTA's single 32-wide rung adds products in a different order or rounding than the register-only ladder (the reversed-order copy fails it);
  • split partition groups (dual mode, bounds above 64) diverge from one group, including the single-group LDS path this PR keeps after the weight barrier;
  • a slot past a sequence's live count leaks into the sum: those slots hold NaN, so a leak breaks the bitwise and float64-reference checks.

It passes on main as well, since main's dual rungs are the same ladder, so it guards this PR's claim of unchanged results rather than reproducing an old failure. No other test compares reducer variants bitwise.

The boundary this rests on: partitions past a sequence's live count must contribute exactly zero now that the reducer always loads 32 slots. The logits buffer descriptor is sized to part_count * stride_logits_part, so loads beyond it return hardware zeros, and the statistics are masked with live.select before the weights. All 62 benchmark workloads (2-170 live partitions) and all 87 paired shapes reproduce main's outputs bit for bit. dpp_xor_f32 reaches only lanes within a 16-lane row, so it is used for offsets 8/4/2/1 on gfx950 only; each lane receives the partner value ds_swizzle gave it. The argument reorder is a positional contract between _reduce_args and the gfx950 kernel signature; a mismatch would read wrong pointers or strides, which every pytest case and the 62-workload gate would catch.

Changed op tests

op_tests/test_flydsl_pa_decode.py, only test_pa_decode_reduce_split_groups: it now runs on gfx950 as well as gfx1250. On gfx950 it checks split groups against one group (dual mode, bounds above 64) and the dual CTA's single 32-wide rung against the register-only ladder, both bit for bit, with NaN in every slot past the live partitions. It is not redundant: it was the only bitwise reducer check, and it skipped on gfx950.

🤖 Generated with Claude Code

…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]>
@fsx950223
fsx950223 requested review from a team and a balanced review from Copilot November 10, 2026 03:55

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

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

…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]>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 07:32

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 10, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision a8b9f032b942 · 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 only, the PA decode reducer always runs its widest 32-partition register rung, instead of picking a rung from the live partition count. Above 32 partitions, it issues each group's loads before the weight barrier. Its cross-lane max and sum within 16 lanes use DPP instead of `ds_swizzle`, whose LDS round trips sat on every short call's critical path, and the arguments its first loads need lead the kernel signature and preload into SGPRs, removing a kernel-argument round trip ahead of `reduce_info`. Single-group CTAs keep main's load order above 32 partitions, because holding a 256-partition rung in registers dropped the whole kernel to one wave per SIMD. The ladder made LLVM hoist and wait on shared loads, which serialized 32-partition reductions into several L2 round trips. Results are unchanged; only timing changes, in both directions, as tabulated.

Validation and unverified scope

Validation:
- **gfx950 (MI355X):** `pytest op_tests/test_flydsl_pa_decode.py` (main's file with this PR's test change, as CI merges it) passed: 361 passed, 31 skipped. The six `test_pa_decode_reduce_split_groups` cases that used to skip on gfx950 now run and pass; they pass against main's reducer too.
- **Negative control:** a copy of this reducer that adds the dual rung's products in reverse order fails `test_pa_decode_reduce_split_groups` on gfx950 (head 64, 256 and 512).
- **MiniMax-M3 benchmark correctness, 62 workloads (BF16 and FP8), eager and graph replay with changed inputs and a NaN-filled output:** passed. Every output is bitwise identical to main's stored outputs: relative L2 0.00000 for standard and peaked (Q x32) inputs.
- **Paired A/B over 87 shapes:** all 87 outputs are bitwise identical to main's.
- **gfx942 (MI308X):** pytest gave 285 passed, 107 skipped, both on main `d02f9d058a` and with this PR (at `02dc5d11b8`; the last commit touches only the gfx950 preload hint and a test that skips on gfx942). All 232 compiled PA kernels have identical `gpu.binary` code.
- **Preload change:** the 45 gfx950 PA kernels the 87-shape set compiles have identical `gpu.binary` code before and after it (default environment).
- **Formatting:** black 25.1.0 and ruff 0.16.0 (the version CI pins) are clean.

Not verified:
- gfx1250 was not run (no hardware). The change is gated on `architecture == "gfx950"`.
- MI300X was not run.
- No end-to-end serving run.
- Beyond the 87 timed shapes and the 40-shape sweep above, other shapes were not measured.

PR-specific question

The changed test is `test_pa_decode_reduce_split_groups`, the canonical reducer test. Before this PR it skipped on every arch but gfx1250, so on gfx950 nothing in the repository checked the reducer bit for bit; only end-to-end tolerances did. It now runs on gfx950 and fails if:
- the dual CTA's single 32-wide rung adds products in a different order or rounding than the register-only ladder (the reversed-order copy fails it);
- split partition groups (dual mode, bounds above 64) diverge from one group, including the single-group LDS path this PR keeps after the weight barrier;
- a slot past a sequence's live count leaks into the sum: those slots hold NaN, so a leak breaks the bitwise and float64-reference checks.

It passes on main as well, since main's dual rungs are the same ladder, so it guards this PR's claim of unchanged results rather than reproducing an old failure. No other test compares reducer variants bitwise.

The boundary this rests on: partitions past a sequence's live count must contribute exactly zero now that the reducer always loads 32 slots. The logits buffer descriptor is sized to `part_count * stride_logits_part`, so loads beyond it return hardware zeros, and the statistics are masked with `live.select` before the weights. All 62 benchmark workloads (2-170 live partitions) and all 87 paired shapes reproduce main's outputs bit for bit. `dpp_xor_f32` reaches only lanes within a 16-lane row, so it is used for offsets 8/4/2/1 on gfx950 only; each lane receives the partner value `ds_swizzle` gave it. The argument reorder is a positional contract between `_reduce_args` and the gfx950 kernel signature; a mismatch would read wrong pointers or strides, which every pytest case and the 62-workload gate would catch.

Changed op tests

`op_tests/test_flydsl_pa_decode.py`, only `test_pa_decode_reduce_split_groups`: it now runs on gfx950 as well as gfx1250. On gfx950 it checks split groups against one group (dual mode, bounds above 64) and the dual CTA's single 32-wide rung against the register-only ladder, both bit for bit, with NaN in every slot past the live partitions. It is not redundant: it was the only bitwise reducer check, and it skipped on gfx950.

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

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]>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:37

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.

…ts first loads' and preload them

The reducer's first load is reduce_info, whose pointer sat at byte 0x50 of
the kernel arguments; on gfx950 nothing was preloaded, so every call
waited on a kernarg round trip before it could fetch its partition range.

gfx950 now orders the reducer's arguments as reduce_info, the statistics
and partials pointers, their strides, query_rows and num_kv_heads, which
are the 14 dwords that preload into user SGPRs, and enables the preload.
reduce_info is then fetched at once, with the remaining arguments in the
same round trip. The kernel body is shared; gfx942 and gfx1250 keep their
argument order.

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

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.

…ngs after the weight barrier

Above 32 live partitions the gfx950 reducer issued each group's partial
loads before the weight barrier and held them in registers until then.
With one partition group, which large batches get, that rung spans all
256 partitions: the kernel compiled to 266 VGPRs, one wave per SIMD, and
every partition count ran at that occupancy. Batches of 128-256 sequences
with 2-8 partitions each were 4-9% slower than main.

gfx950 now issues loads ahead of the barrier only when a group's rung is
at most 64 partitions; a single group keeps main's order and reuses the
LDS allocated up front. That kernel drops to 51 VGPRs. Outputs are
bit-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 11: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.

@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: no correctness issue found; two small fixes suggested.

What I ran (MI355X / gfx950, 256 CUs, FlyDSL 0.5.0; this PR applied on main cb4ac34):

  • Reducer bit-exactness: compiled compile_pa_decode_ps_reduce for gfx950 over 184 configs (head dims 64/128/192/256/512, bf16/f16 logits, with and without sinks, NP 24-256, 1-16 partition groups, num_xcds 0 and 8, NaN in every slot past the live partitions). The output is bit-identical to main in 184/184 configs (148 dual-mode, 100 multi-group, 66 with num_xcds=8), all finite.
  • Latency: MiniMax-M3 TP4 shapes (Hq16 / Hkv1 / D128, page 128), ATOM call style (block table padded to 256K tokens, no max_context_length, default plan, scratch sized from plan.capacity, FP8 with per-tensor scale tensors), CUDA graph of 10 decodes, main and the PR in separate interleaved processes (main 4, PR 3, 30 samples each). Geomean 1.064x over 12 shapes, worst 1.006x; b1-b8 decode +10.8-11.8%, in line with your table. With max_context_length set to the real length the reducer compiles register-only (NP <= 64) and the gain drops to about 1.6-1.9%, so the headline comes from the dual-mode reducer.
Per-shape latency (us), main vs this PR
shape main this PR speedup
decode b1 ctx8K bf16 7.69 6.94 1.108x
decode b1 ctx8K fp8 7.32 6.58 1.112x
decode b4 ctx8K bf16 7.86 7.03 1.118x
decode b8 ctx8K fp8 7.86 7.03 1.118x
decode b32 ctx8K bf16 23.62 23.20 1.018x
decode b32 ctx8K fp8 15.65 15.33 1.021x
decode b4 ctx32K fp8 10.40 9.68 1.074x
decode b3 ctx225K bf16 65.72 65.33 1.006x
verify b3 q4 ctx8K bf16 12.50 11.73 1.066x
verify b3 q4 ctx8K fp8 11.46 10.71 1.070x
verify b8 q4 ctx32K bf16 38.63 37.63 1.027x
verify b8 q4 ctx32K fp8 24.30 23.35 1.041x

⚠️ The split-groups test cited in the self-review doesn't run on gfx950. test_pa_decode_reduce_split_groups skips unless get_gfx_runtime() == "gfx1250" (op_tests/test_flydsl_pa_decode.py L218-219) and compiles with architecture="gfx1250" (L260). On gfx950 the reducer is only covered end-to-end with tolerances, so the bit-exactness this PR relies on has no in-repo guard (the 184/184 result above is out-of-tree). Could you parametrize that test over the runtime arch (on gfx950, groups > 1 only when NP > 64) so the bitwise check runs here too?

The kernarg-preload point is inline.

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

…; honor the preload env

Review follow-ups:
- test_pa_decode_reduce_split_groups ran only on gfx1250, so on gfx950 the
  reducer's bit-exactness had no in-repo guard. It now runs on gfx950 too:
  dual-mode CTAs (bounds above 64) with split groups must match one group
  bit for bit, and the dual CTA's single 32-wide rung must match the
  register-only ladder bit for bit up to 32 live partitions. A copy of the
  reducer that adds the dual rung's products in reverse order fails it.
- The gfx950 reducer launch takes AITER_FLYDSL_KERNARG_PRELOAD and the
  count from tensor_shim (capped at 16), so AITER_FLYDSL_KERNARG_PRELOAD=0
  reaches it. Defaults compile as before.

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

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.

@fsx950223

Copy link
Copy Markdown
Contributor Author

Thanks for the review, and for the 184-config bit-exactness sweep.

You're right that test_pa_decode_reduce_split_groups never ran on gfx950, so the self-review overstated its coverage. In a8b9f03 it runs on gfx950 as well as gfx1250, with these checks on gfx950:

  • Split groups: dual-mode CTAs (bounds above 64) with split groups must match one group bit for bit. This includes the single-group path that keeps main's load order above 32 partitions. Register-only bounds keep one group there, as you suggested.
  • New, gfx950 only: the dual CTA's single 32-wide rung must match the register-only ladder (NP 32) bit for bit for every sequence with at most 32 live partitions. That is the property this PR's "unchanged results" claim rests on.
  • Unchanged: NaN in every slot past the live partitions, and the float64-reference check above 32 partitions.

Results:

  • gfx950 (MI355X): main's test file with this change, as CI merges it, gives 361 passed / 31 skipped. The six split-group cases that used to skip now pass, and they pass against main's reducer too.
  • Negative control: a copy of this reducer that adds the dual rung's products in reverse order fails the test (head 64, 256, 512).

The self-review and Testing sections are updated accordingly. The preload point is answered inline.

@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. Both points from my earlier review are addressed in a8b9f03 (the preload honors its env var; the split-group test now runs on gfx950), and outputs stay bit-identical.

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
fsx950223 merged commit 3f15a7b into main Nov 16, 2026
@fsx950223
fsx950223 deleted the fsx950223/pa-gfx950-reducer-rung branch November 16, 2026 06:31
fsx950223 added a commit that referenced this pull request Nov 16, 2026
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]>
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