You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HIP] [FlyDSL] [CI] [Perf] gfx950 small-M BF16 ring GEMM policies (rg lm_head, rk DSpark FC) in the hgemm catalog, tuner and tgemm path - #8675
Change: two gfx950 small-M BF16 "ring" GEMMs, rg (lm_head, N=50016 K=6144) and rk (DSpark draft FC, N=1536 K=30720), added to the FlyDSL hgemm catalog, the gemm tuner and the unified tgemm path, with tuned rows for MiniMax-M3.1 TP4 (M <= 128).
Why it is faster: purpose-built skinny-M kernels replace torch's default path for these two shapes (rk splits K into five K/5 chunks with a split-K reduce; both read AITER's (16, 16) shuffled weight in place when bpreshuffle=True, with no second weight copy). Which ring feature gives the gain was not ablated.
How much (MI355X gfx950, public tgemm.mm, CUDA-graph replay, ABAB, cold weights): DSpark FC (rk) vs default torch: 18.66 vs 25.4 us at M=8 (27% faster), 30.15 vs 38.9 at M=128 (22%), 18-27% across M=8..128. lm_head (rg, shuffled weight) vs default torch: 95.6 vs 100.7 us at M=8, 106.3 vs 179.9 at M=64, 124.4 vs 197.0 at M=128. Against main's row-major lm_head rows (exact-M rows of [Config] [Perf] MiniMax-M3.1 TP4 lm_head BF16 (N50016 K6144) gfx950: exact-M rows for verify row counts and M 192-512 #8598) the shuffled rg is 3-9% slower (M=64: 105.0 us vs 99.7; M=128: 127.4 vs 119.9): its use is the caller that keeps the lm_head weight AITER-shuffled (is_shuffled=True, which ATOM does not do today).
End to end: not measured; ATOM benefits from the FC rows only until it keeps the lm_head weight shuffled (separate thin ATOM change, not in this PR).
Two gfx950 small-M BF16 "ring" GEMMs, wired into the FlyDSL hgemm catalog, the gemm tuner and the unified tgemm path, so they are reached through the usual aiter interface and tuned rows rather than called directly:
policy
kernel names
shape it targets
weight layout
rg
aiter_ring_bf16_gemm_*
lm_head, N=50016 K=6144, M<=128
row-major, or AITER shuffle_weight(w, (16, 16)) read in place
rk
aiter_cat_ring_* + the FlyDSL split-K reduce of the mxscale preshuffle GEMM (fp32 slabs summed in ascending split order, one bf16 rounding)
Supersedes #8554 (lm_head ring) and #8573 (DSpark FC split-K ring), which are closed in favour of this single branch. The kernels are ported into aiter (no dependency on amd-kernels; the source is credited in the file headers).
How each is reached
Catalog: flydsl_hgemm(policy="rg" | "rk", ...); kernel names reuse the HGEMM name grammar (..._t<rows>x16x64x<ring>_ks1_w<halves>x4x1_..._prg_gfx950, ..._t<rows>x64x64x<ring>_ks<K splits>_w1x4x1_..._prk_gfx950). _HGEMM_KERNEL_RE accepts rg|rk; get_flydsl_hgemm_kernel_params rejects any name whose fields are not a legal ring tiling.
Tuner: get_flydsl_a16w16_configs enumerates the legal ring tilings (get_flydsl_ring_configs, get_flydsl_ring_splitk_configs). gemm_a16w16_tune.py gets --flydsl-policies rg,rk,... (narrow the sweep, e.g. at large K where the full ft/ht catalog has ~10^4 candidates) and tunes preshuffled shapes (bpreshuffle=True) with the shuffleweights input.
kernelName round trip: tuner config -> name -> parsed params -> ring_name_tiling / ring_splitk_name_tiling -> same tiling.
Tuned rows: minimax_m3_eagle_bf16_tuned_gemm.csv (lm_head, preshuffled, M=8,16,32,64,128) and minimax_m3_mxfp4_bf16_tuned_gemm.csv (FC, shuffled and row-major, M=8..128); matching untuned rows added.
tgemm: get_GEMM_A16W16_tuned_config accepts rg/rk rows for bpreshuffle; flydsl_gemm treats both as no-bias / input-dtype-output policies and passes the tiling and bpreshuffle through.
Shuffled layout: with bpreshuffle=True the kernels read AITER's (16, 16) shuffled weight in place; there is no second weight copy and no extra memory.
(the default-torch column is the pre-existing default path at the time of measurement; main now also has row-major exact-M rows for this shape from #8598, see Limits: against them the shuffled rg is slower, so this table is the comparison for a caller that keeps the weight shuffled.)
Verification
Every shuffled lm_head row (M=8..128) and every FC row (shuffled and row-major) is tuned to a ring kernel and tgemm.mm launches it (eager and graph; 51 launched ring symbols matched their kernelName tilings).
Correctness vs an fp32 reference: max-abs-err / max|ref| 0.18% - 0.95%.
Negative controls: shapes with no ring row are unchanged vs main; a shuffled lm_head with no row asserts "no solution" on both the branch and main.
New CPU tests (op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py, already run by the tuning-tests workflow): the policies filter, the is_shuffle catalog restriction (shuffled candidates only rg/rk), the ring pass-through in _flydsl_b_non_temporal_configs, run_flydsl_gemm_bf16(bpreshuffle), and every committed rg/rk row parses with _HGEMM_KERNEL_RE, passes the policy tiling check and re-generates its own name. Ring kernel tests (GPU) are registered in .github/scripts/aiter_test.sh and split_tests.sh.
Fast op_tests/tuning_tests subset (everything except test_run_config / test_tune_pipeline), branch vs a main tree: the failing-test-id lists are identical. CPU-only: 48 failed on both (same 48 ids). One single-GPU lease (MI355X, GPU 6): 27 failed on both, diff of the sorted FAILED/SUBFAILED id lists is empty (417 passed on the branch, 403 on main; the difference is the new tests). The shared failures are pre-existing and unrelated to this change: test_a16w16_tuned_config_lookup gfx1250 wrapper routing (TDM policies need gfx1250), test_grouped_ep_fused_lookup, test_fhmoe_tuner, test_fast_tuning, test_grouped_gemm_launch_abi. The ring GPU tests (test_flydsl_gemm_a16w16_ring.py, test_flydsl_gemm_a16w16_cat_x_ring.py) pass. After merging main, the lookup / config-shape-collision / csv-validation tests were re-run: only the same 8 gfx1250 routing failures remain.
Limits and caveats
Row-major lm_head M=8/16/32 is not ring: the ring takes about 122 us there versus 92-95 us for the pft bnt catalog kernels.
This PR does not touch main's row-major lm_head rows. While this PR was open, main gained row-major rows for M=40..128 (99.7 us at M=64, 119.9 us at M=128, pft/pht bnt). Those beat this branch's own row-major ring rows (129.7 / 139.9 us), so the merge drops our row-major M=64/128 ring rows. The preshuffled ring rows are compared against torch above, not against those row-major rows: at M=64/128 the shuffled ring (105.0 / 127.4 us in the tuner) is slower than main's row-major rows; it is only the choice for callers that keep the weight shuffled.
The shuffled layout costs +1.5 / 2.2 / 2.8 / 6.3 / 19.4% (M=8..128) over the ring's own tile layout; the cause is only narrowed to the 2 KiB weight-stage chunk stride, and the M=128 gap is open.
Tuner coverage: for preshuffled shapes the tuner compares only rg/rk, never shuffled ft/sk (the catalog restriction is_shuffle). The behaviour is intentional and unchanged here.
ATOM's lm_head weight is row-major today (ParallelLMHead, no shuffle), so ATOM only benefits from the FC rows until it keeps the lm_head weight shuffled with is_shuffled=True (separate thin ATOM change, not in this PR).
A production shuffled lm_head with no tuned row asserts "no solution" exactly as on main.
All 15 rg / rk rows replay in the FlyDSL AOT dry run (tests/test_flydsl_aot_replay.py::test_bf16_ring_csv_rows_reach_flydsl_through_public_replay, which also replays the probe at the smallest M a row serves); the ring kernels are not yet aot_factory-registered (JIT-compiled per process), follow-up.
Review-pr by hand (.claude/skills/review-pr, aiter-config-shape)
Read the full diff against the rules; fetch.sh needs a PR number so the collectors were not run. Checked: device / stream / i32-offset bounds in the host wrappers, output and weight validation, compile cache keyed on device and layout, graph-safe workspace (never evicted), CI registration of the new tests, no duplicate shape keys across the bf16 tuned family (script check plus test_config_shape_collision), untuned rows for every tuned shape. Deviations: the collectors were not run (no PR number before opening); the AOT pairing is not done (above).
Review-fix update (head 282306df4)
The ring support checks ask torch.cuda.is_available() only without a device (tuner-catalog callers), the rk reduce is the FlyDSL one (timing re-measured, cat_x_ring us new / old Triton reduce: M8 18.46 / 19.67, M16 19.54 / 20.28, M32 20.40 / 20.97, M64 24.81 / 24.53, M128 31.23 / 32.35; all rows err 0).
Row-stride, descriptor-span and output validation: out must be non-overlapping with an even row stride, a 4-byte aligned base and a physical byte span below 2**31; the activation descriptor is (M-1)*stride + seg_k*2 bytes.
_lds_ptr uses the backend fx.to_llvm_ptr(fx.inttoptr(...)) form (ring bench us new / old: M8 93.4 / 93.7, M16 93.7 / 93.5, M32 94.6 / 95.3, M64 95.8 / 96.1, M96 99.9 / 99.8, M128 107.9 / 112.4: no regression); the raw mfma_* calls keep a comment on why.
CI: the wheel-build AOT replay failed on the rows themselves (fixed above) and then on the replay's probe at the smallest M the first shuffled lm_head row serves (M=1 has no solution below the smallest tuned M of a shuffled shape): that limit is now named in the AOT REFUSALS (32de24874).
Tests: tile larger than the rows (mt 3/4 at M=40, 7/8 at M=100), a tuned rk row at a padded M through tgemm.mm, expanded / padded output, a 2**28-element row stride refused, the 15-row replay test.
Re-verified on gfx950: ring 54 passed, cat-x 48 passed (including the new refusal), the fast tuning subset 417 passed / 27 failed (the same 27 as on main: 8 gfx1250 wrapper routing, 19 GroupedEpFusedLookupTest, none touched by this PR), the AOT test files 58 passed / 4 skipped; the ring replay test fails without and passes with the REFUSALS change (CPU, GPU hidden). The slow test_run_config / test_tune_pipeline bf16 subsets were started but not completed within a lease.
Merged origin/main (b66ea0d9c): no conflicts in the ring files; main's retune of 8 unrelated large-M (N>=2048) BF16 rows from flydsl/asm to torch in minimax_m3_eagle_bf16_tuned_gemm.csv is outside this PR's M<=128 rg/rk rows, and tests/test_flydsl_aot_replay.py gained unrelated main tests; neither touches the ring/cat-x-ring code.
Copilot 4705271116: gemm_a16w16_ring and the cat-x ring's shared _launch read n = w.shape[0] and check w.shape[1], which a weight with an extra trailing dimension (e.g. [N, K, 0]) still passes while supplying the wrong element count to the raw-pointer kernel. Both now require w.ndim == 2 before any launch.
Copilot 4705271204: warmup_cat_x_ring only compiled tiers at multiples of 16 rows, so m_max=8 compiled nothing and m_max=17 stopped at the mt=1 tier, leaving the mt=2 tier the caller actually uses uncompiled before CUDA-graph capture. It now also warms the exact m_max when it is not itself a multiple of 16.
Tests added: non-2D weight rejection for both entry points; a cache-miss check that warmup_cat_x_ring(m_max=8) and (m_max=17) leave no compile for a later call at that exact M.
Re-verified on gfx950 (MI355X, node 034 GPU 0, lease Lee74d6): 106 passed (ring + cat-x-ring suites), including the 4 new tests.
PR Self-Review
Reviewed revision
508716c52
Behavior and intent
Adds two small-M BF16 GEMM policies for gfx950 behind the usual catalog / tuner / tgemm path and tuned rows, instead of direct kernel calls. They give 18-27% (FC, rk) and, for a shuffled weight, 37-41% (lm_head, rg, M=64..128) lower latency than the default torch path; against main's row-major lm_head rows rg is slower, as stated above.
Validation and unverified scope
Commands and results are in the Measured, Verification and review-fix sections (gfx950 MI355X): every shuffled lm_head row and every FC row is tuned to a ring kernel and launched by tgemm.mm (eager and graph), correctness vs an fp32 reference 0.18%-0.95% max-abs-err, name round trip 0 failures on 17 CSV rows + 1264 catalog names. Not verified: end-to-end effect; the slow tuning tests; the ring kernels' AOT registration; the shuffled lm_head at M = 1, 2, 4 and M > 128 has no row (no solution, as on main).
PR-specific question
What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
The CI change is two lines: .github/scripts/aiter_test.sh adds the two new ring test files to an existing case list and .github/scripts/split_tests.sh lists them. No workflow file is edited, no secrets, permissions or pull_request_target are involved; the lines only name repository test files that the existing job runs with python3 -m pytest -q <file>.
Changed op tests
op_tests/flydsl_tests/test_flydsl_gemm_a16w16_ring.py: GPU tests of the rg ring kernel against torch (row-major and shuffled weights, M 1..128, padded tiles) and a ring bench; no existing test exercises this kernel.
op_tests/flydsl_tests/test_flydsl_gemm_a16w16_cat_x_ring.py: GPU tests of the rk split-K ring (cat-x taps, expanded / padded inputs and outputs, tile larger than the rows, the refusal of a 32-bit-unsafe output span) and a bench that asserts zero mismatches.
op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py: CPU tests of the tuner and lookup side: the policies filter, the is_shuffle catalog restriction, the ring pass-through in the non-temporal configs, run_flydsl_gemm_bf16(bpreshuffle), and that every committed rg / rk row parses, passes the tiling check and regenerates its own name; it is the existing tuned-config lookup test.
…M<=128)
out[M, N] = x[M, K] @ w[N, K]^T for 1 <= M <= 128 on a weight read once per
call (a vocabulary-shard lm_head: N=50016, K=6144 at TP4 of a 200k vocab).
One launch, 256 XCD-interleaved column tiles, buffer-load-to-LDS DMA ring,
mfma_f32_16x16x32_bf16, no split-K and no cross-tile reduction, so it is
deterministic and CUDA-graph safe.
- aiter/ops/flydsl/kernels/gemm_a16w16_ring_gfx950.py: the kernel, generalized
in N and K (N % 16 == 0, N / 16 >= 256, K % 64 == 0) with the M-halves and
ring-depth parameters free; one M half up to 64 rows, two halves for 65-128.
- aiter/ops/flydsl/gemm_a16w16_ring.py: host op (gemm_a16w16_ring,
ring_supported, shuffle_weight_ring / unshuffle_weight_ring, warmup_ring).
The weight is read in a [N/16, K/64, 16, 64] tile layout (a bit-exact
permutation made once at load); the row-major weight also works but is
~30 us slower at N=50016, K=6144.
- op_tests/flydsl_tests/test_flydsl_gemm_a16w16_ring.py: correctness vs a torch
fp32 reference over three (N, K) shapes x 12 row counts, layout / row-tier
invariance, CUDA-graph replay, and a ring-vs-tgemm perf table.
Kernel adapted from the amd-kernels project's gemm/bf16_n50016_k6144 (MIT),
revision fd233ef; bit-identical to that kernel at every row count 7-128.
Co-Authored-By: Claude <[email protected]>
…on, benchmark assert
- gemm_a16w16_ring requires CUDA x/w/out on one device, launches under that device and its stream, and
keys the compiled handle per device.
- supported_shape rejects weights whose N*K*2 bytes reach the 0x70000000 DMA-offset sentinel
(N=K=65536 passed fits() and wrapped the 32-bit offset).
- the standalone benchmark asserts the ring result matches the fp32 reference instead of only logging it.
- register test_flydsl_gemm_a16w16_ring.py in split_tests.sh and dispatch it through pytest in
aiter_test.sh so CI runs the pytest cases.
- tests for the 32-bit bound and the CPU / foreign-device rejection.
Co-Authored-By: Claude <[email protected]>
… for the DSpark draft fc
out[M, N] = concat(x0..x4)[M, 5*seg_k] @ w[N, 5*seg_k]^T without materializing
the concat. Built on the small-M ring GEMM (previous commit): K is split ks
ways (default 10, two splits per tap) so each workgroup reads ONE tap, chosen
once from five kernel-argument base pointers (no host-side pointer table, so
the launch is CUDA-graph capturable). Each split stores an fp32 partial; aiter's
Triton split-K reduce kernel sums the partials in ascending order with one
bf16 rounding: deterministic, not bit-identical to a single-pass K order.
Adapted in idea from the amd-kernels project's gemm/bf16_concat_linear_n1536_k30720
(Apache-2.0), reimplemented on the ring kernel.
Co-Authored-By: Claude <[email protected]>
… on it, bound i32 byte offsets
review-pr D13/D14 on the raw-pointer launch: the taps, out and workspace must
be on the weight's CUDA device, the launch runs under torch.cuda.device(), the
compiled-handle cache is keyed on the device index, and cat_x_ring_supported
refuses a weight or fp32 partial buffer of 2 GiB or more (i32 byte offsets).
Co-Authored-By: Claude <[email protected]>
…licy rk, tuner candidates, tuned rows
The split-K ring of the DSpark draft fc becomes the FlyDSL hgemm policy 'rk'
(name t<mt*16>x64x64x<r>_ks<ks>_w1x4x1_..._prk_gfx950): K is read as five chunks
of a plain [M, K] activation, the weight is row-major or AITER (16,16)-preshuffled
(read in place, no second copy). The tuner enumerates it (also for bpreshuffle rows),
flydsl_hgemm/tuned_gemm dispatch it, and --flydsl-policies narrows the huge
large-K FlyDSL catalog. Tuned rows for N=1536 K=30720 M=8..128 go to the minimax_m3
bf16 model config.
Co-Authored-By: Claude <[email protected]>
…6144, M 8..128)
Preshuffled-weight (bpreshuffle=True) rows at M 8/16/32/64/128 select the rg ring; the
row-major rows at M 64/128 switch to it, M 8/16/32 keep their faster existing rows.
Co-Authored-By: Claude <[email protected]>
- test_a16w16_tuned_config_lookup: --flydsl-policies filter, shuffled catalog
restricted to rg/rk, ring pass-through in _flydsl_b_non_temporal_configs,
run_flydsl_gemm_bf16(bpreshuffle), and every committed rg/rk row parses with
_HGEMM_KERNEL_RE, passes the policy tiling check and round-trips to its name.
CPU only; the file is already run by the tuning-tests workflow.
- gemm_kernels.__all__ exports RING_POLICY next to RING_SPLITK_POLICY.
- minimax_m3_mxfp4_bf16_untuned_gemm.csv: the ten DSpark FC shapes (N=1536,
K=30720) that the tuned rows already cover, so the tuner input matches.
Co-Authored-By: Claude <[email protected]>
Main now carries row-major lm_head rows for M=40..128 (pft/pht bnt, 99.7 us at
M=64, 119.9 us at M=128) that beat the row-major ring rows of this branch
(129.7 / 139.9 us), so the conflicting row-major M=64/128 ring rows are dropped.
The preshuffled lm_head ring rows (bpreshuffle=True, M=8..128) are kept: there
is no other kernel for that layout.
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 8675 --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.
github-actionsBot
changed the title
[FlyDSL] [Perf] gfx950 small-M BF16 ring GEMM policies (rg lm_head, rk DSpark FC) in the hgemm catalog, tuner and tgemm path
[HIP] [FlyDSL] [CI] [Perf] gfx950 small-M BF16 ring GEMM policies (rg lm_head, rk DSpark FC) in the hgemm catalog, tuner and tgemm path
Nov 25, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active findings identify invalid split-K descriptor sizing, missing output-row overlap validation, and standalone tests that can succeed despite numerical mismatches.
Adds gfx950 small-M BF16 ring GEMMs for lm_head and DSpark draft FC workloads, integrating them into AITER’s existing kernel catalog, tuner, and tgemm dispatch.
Changes:
Introduces rg and split-K rk policies supporting row-major and AITER-preshuffled weights.
Adds policy filtering and model-specific tuned rows with matching untuned inputs.
Adds numerical, layout, graph-replay, and dispatch tests, with CI registration.
The reason will be displayed to describe this comment to others. Learn more.
Read-through of c10f093 (the diff plus the tgemm, tuner and AOT code around it) and of this revision's CI logs. I have not run anything on gfx950.
The kernels look right to me. I checked the tile and fragment split (NBIG tiles of NR fragments and the rest of NRB, summing to N / 16), the byte offsets of the three weight layouts, the descriptor bounds and 32-bit offset limits, the LDS budgets of the committed tilings, and that a padded-M lookup always lands on a row whose tile holds the actual M. My concerns are in the integration.
Blocking: the wheel build fails on the 15 new rows
build_aiter_wheels fails on this revision in the FlyDSL AOT replay, on exactly the rows this PR adds:
[FAIL] bf16_tuned_gemm ..._prg_gfx950 M=8 N=50016 K=6144 ... bpreshuffle=True arch=gfx950: ValueError: ring GEMM does not take M=8 N=50016 K=6144 on this device
[FAIL] bf16_tuned_gemm ..._prk_gfx950 M=8 N=1536 K=30720 ... arch=gfx950: ValueError: ring split-K GEMM does not take M=8 N=1536 K=30720 ks=10 on this device
AssertionError: [aiter] FlyDSL AOT failures: FlyDSL GEMM replay failed for 1 arch(es)
All 5 rg rows and all 10 rk rows fail this way. Because the build failed, Aiter Test Gate failed and split_aiter_tests / standard were skipped, so the two GPU test files registered here have not run in CI on this revision. The cause, and a second failure behind it for rk, are in the first two inline comments.
The two failing Triton shards look unrelated: shard 5 is test_kda_gating.py importing kimi_delta_attn.fast_launch, which does not exist on main either, and shard 3 is three test_gemm_a16wfp4 cases.
Inline
The torch.cuda.is_available() gate that fails the replay.
The Triton reduce, which fails the rk replay next.
The preshuffled lm_head rows leave M <= 4 and M > 128 at "no solution".
rk is never run with a tile larger than M, which is what a padded-M lookup does.
Minor
aiter/ops/flydsl/AGENTS.md asks new kernels to use FlyDSL buffer tensors and fx.copy rather than the legacy buffer_ops; both new kernels use buffer_ops. The raw DMA op and s_barrier are commented in the ring kernel as the rule asks. A note on why buffer_ops stays, or a tracking issue, would cover it.
The title carries two backend tags, [HIP] (presumably from csrc/gemm_a16w16/gemm_a16w16_tune.py) and [FlyDSL]; the CI guide asks for a split in that case.
The PR Self-Review sections the bot asks for are missing from the description.
The reason will be displayed to describe this comment to others. Learn more.
Second pass, checking this PR against the repo's .claude/skills (aiter-op-test, flydsl-kernel-code-cleanup, review-pr). Only points that are not already raised in this PR:
Test placement and form (aiter-op-test). Inline.
Raw MFMA and raw LDS pointers (flydsl-kernel-code-cleanup, sections 6 and 3b). Inline.
Size (review-pr). 2296 added lines in 17 files, over both review bars (1000 lines, 15 files), where the skill recommends a stacked split. The natural seams are the two PRs this replaced (#8554 for rg, #8573 for rk) and the catalog, tuner and rows wiring on top.
Downstream CI (review-pr). The row-major FC rows in minimax_m3_mxfp4_bf16_tuned_gemm.csv change the default kernel for N = 1536, K = 30720, and no ci:* label is set, so no downstream job ran. ci:vllm is the label whose benchmark runs amd/MiniMax-M3-MXFP4.
Named constants (review-pr). Both kernels compute LDS and weight offsets with raw 16 / 64 / 128 / 1024 / 2048 literals. Naming the fragment, stage and chunk sizes would make that math checkable.
… ring-rk coverage
- tests/test_flydsl_aot_replay.py: the 15 rg / rk rows replay to a FlyDSL kernel in a GPU-hidden process
- cat-x ring reduce launches with current_stream_arg (as the other FlyDSL launchers)
- cat-x ring tests: padded-M tile larger than the rows (mt 3 vs 4, 7 vs 8), injected rk row through tgemm.mm at M 40 / 100
Co-Authored-By: Claude <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved findings show incomplete row-tier warmup, acceptance of invalid kernel settings and overflowing output spans, and GPU test gates that enable tests on unsupported devices.
Zero satisfies this modulo check, so an otherwise valid rk name containing _ks0_ is recognized even though cat_x_ring_supported rejects ks < 1. The tuned lookup consequently treats that unusable row as valid instead of skipping it and trying another candidate. Require a positive multiple of NSEG here.
Warmup skips valid partial row tiers
aiter/ops/flydsl/gemm_a16w16_cat_x_ring.py:336
For m_max=8 this loop has no iterations; for m_max=17 it only warms the first 16-row tier and misses mt=2. The helper therefore leaves a valid maximum-sized call cold despite promising to compile every row tier before graph capture. Iterate one representative row count per tier, including the partial final tier.
On a gfx950 device with fewer than 256 CUs, this gate enables GPU tests even though _device_ok rejects every ring launch. CI invokes pytest directly, so the filtering in main() does not protect these tests. Gate them with ring_supported and apply the equivalent cat_x_ring_supported gate in op_tests/flydsl_tests/test_flydsl_gemm_a16w16_cat_x_ring.py:42–44.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Weight validation accepts higher-dimensional tensors that can cause invalid device reads, and warm-up skips the final partial row tier needed before CUDA-graph capture.
… warm-up tier
gemm_a16w16_ring and the cat-x ring's shared _launch read n = w.shape[0] and check
w.shape[1], which a weight with an extra trailing dimension (e.g. a [N, K, 0] view)
still passes while supplying the wrong element count to the raw-pointer kernel.
Both now require w.ndim == 2 before any launch (Copilot 4705271116).
warmup_cat_x_ring only compiled tiers at multiples of 16 rows (range(16, m_max+1, 16)),
so m_max=8 compiled nothing and m_max=17 stopped at mt=1, leaving the mt=2 tier the
caller actually uses uncompiled before CUDA-graph capture. It now also warms the exact
m_max when it is not itself a multiple of 16 (Copilot 4705271204).
Tests added: non-2D weight rejection for both entry points, and a cache-miss check
that warmup_cat_x_ring(m_max=8) and (m_max=17) leave no compile for gemm_a16w16_cat_x_ring
at that exact M. 106 passed (gfx950, MI355X node 034 GPU 0, lease Lee74d6), including the
4 new tests.
Co-Authored-By: Claude <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because support checks can approve launches that fail row-capacity validation, while zero-split tuned entries can bypass the invalid-row fallback.
I read the new commit (the 2-D weight check and the warm-up of the last partial tier). The merge of main leaves the rest of this PR's diff as it was at 282306d.
CI on this head
Required checks. All four are green, including Aiter Test Gate with all eight MI35X standard shards. test_topk_per_row.py and test_flydsl_mega_mhc.py, which crashed on the previous head, pass here.
This PR's tests.test_flydsl_gemm_a16w16_ring.py ran 55 tests and test_flydsl_gemm_a16w16_cat_x_ring.py ran 51, with none skipped.
Wheel build. The GEMM replay reports 24885 ok and 0 failed.
The red Triton shard
It is not this PR, and a re-run will not clear it. test_gemm_a16wfp4[True-False-False-True-16-4096-11008] failed in all six main runs on 2026-11-25 and 2026-11-26 that ran that file on MI35X, most recently 45768483011 and 45876301969. The green main runs in between skip the Triton shards or run a subset without it. Triton Test Results is not a required check.
My last comment suggested a re-run for it. That will not help.
Basis
This rests on reading the code and on this CI run. I did not run anything on gfx950 myself.
My two open threads (the preshuffled lm_head rows and the test placement) are follow-ups and do not block.
@zufayu thanks for the flag — the conflict is now resolved.
Merged current origin/main into the branch (merge commit 1eba498c7b3ba86d051b574e80a54081d96d3403). The only conflict was in aiter/ops/flydsl/gemm_kernels.py, resolved as a union of both sides' policy entries:
Kept this PR's RING_POLICY = "rg" / RING_SPLITK_POLICY = "rk" definitions and their dispatch/validation branches.
Kept main's TDM_POLICIES = {"tdm": False, "tdmi": True} (tuple→bool value form) and its new _REMOVED_TDM_POLICIES = {"tdma": "tdm", "tdmia": "tdmi"} guard. This PR had not touched TDM_POLICIES, so the two changes are orthogonal — no policy/entry was dropped or duplicated.
In flydsl_hgemm_kernel_name the gate now runs main's _REMOVED_TDM_POLICIES rejection and includes the ring policies in the supported set; the kernel-name regex keeps both rg|rk and tdma|tdmia.
Tuned-config CSVs (minimax_m3_*bf16_tuned_gemm.csv) auto-merged cleanly; a family-wide duplicate-shape check over the full bf16_tuned_gemm family reports 0 duplicate shapes. Static checks on the merged Python (py_compile, ruff check, black --check) are clean.
GPU perf / bit-exact re-verification is pending a free gfx950 node (not available in this CPU-only env).
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unaligned contiguous operands can still make GEMM launches fail, and the ring support predicate accepts tilings with insufficient row capacity that the kernel later rejects.
…the rg/rk tgemm path
ring_supported now rejects a tiling whose row capacity (mt*mh*16) cannot hold M,
matching gemm_a16w16_ring's own check and cat_x_ring_supported, so the dispatch
gate and the launch agree (fits() only checks N/K resources, not row capacity).
In the rg/rk policy dispatch, a contiguous activation/weight with a 16-byte
misaligned base (e.g. buf[1:].view(...)) survived .contiguous() unchanged and the
ring launchers reject it; realign such A/B by copy before launch. No change on the
common aligned path (only a data_ptr()%16 check, no copy).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…apshot fix (#8790) and clear the conflicts with main.
The three conflicts keep both sides: main's MiniMax exports, ring catalog and policy_runs_on next to the decode exports, candidates and launch helpers. Main's ring tuning (#8675) dropped the early return for preshuffled shapes, which had kept decode candidates out of them; the tuner now skips decode candidates when is_shuffle, since decode kernels read the plain weight and the runtime rejects a preshuffled decode row.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At a glance
rg(lm_head, N=50016 K=6144) andrk(DSpark draft FC, N=1536 K=30720), added to the FlyDSL hgemm catalog, the gemm tuner and the unifiedtgemmpath, with tuned rows for MiniMax-M3.1 TP4 (M <= 128).rksplits K into five K/5 chunks with a split-K reduce; both read AITER's (16, 16) shuffled weight in place whenbpreshuffle=True, with no second weight copy). Which ring feature gives the gain was not ablated.tgemm.mm, CUDA-graph replay, ABAB, cold weights): DSpark FC (rk) vs default torch: 18.66 vs 25.4 us at M=8 (27% faster), 30.15 vs 38.9 at M=128 (22%), 18-27% across M=8..128. lm_head (rg, shuffled weight) vs default torch: 95.6 vs 100.7 us at M=8, 106.3 vs 179.9 at M=64, 124.4 vs 197.0 at M=128. Against main's row-major lm_head rows (exact-M rows of [Config] [Perf] MiniMax-M3.1 TP4 lm_head BF16 (N50016 K6144) gfx950: exact-M rows for verify row counts and M 192-512 #8598) the shuffledrgis 3-9% slower (M=64: 105.0 us vs 99.7; M=128: 127.4 vs 119.9): its use is the caller that keeps the lm_head weight AITER-shuffled (is_shuffled=True, which ATOM does not do today).What
Two gfx950 small-M BF16 "ring" GEMMs, wired into the FlyDSL hgemm catalog, the gemm tuner and the unified
tgemmpath, so they are reached through the usual aiter interface and tuned rows rather than called directly:rgaiter_ring_bf16_gemm_*shuffle_weight(w, (16, 16))read in placerkaiter_cat_ring_*+ the FlyDSL split-K reduce of the mxscale preshuffle GEMM (fp32 slabs summed in ascending split order, one bf16 rounding)Supersedes #8554 (lm_head ring) and #8573 (DSpark FC split-K ring), which are closed in favour of this single branch. The kernels are ported into aiter (no dependency on amd-kernels; the source is credited in the file headers).
How each is reached
flydsl_hgemm(policy="rg" | "rk", ...); kernel names reuse the HGEMM name grammar (..._t<rows>x16x64x<ring>_ks1_w<halves>x4x1_..._prg_gfx950,..._t<rows>x64x64x<ring>_ks<K splits>_w1x4x1_..._prk_gfx950)._HGEMM_KERNEL_REacceptsrg|rk;get_flydsl_hgemm_kernel_paramsrejects any name whose fields are not a legal ring tiling.get_flydsl_a16w16_configsenumerates the legal ring tilings (get_flydsl_ring_configs,get_flydsl_ring_splitk_configs).gemm_a16w16_tune.pygets--flydsl-policies rg,rk,...(narrow the sweep, e.g. at large K where the full ft/ht catalog has ~10^4 candidates) and tunes preshuffled shapes (bpreshuffle=True) with theshuffleweightsinput.ring_name_tiling/ring_splitk_name_tiling-> same tiling.minimax_m3_eagle_bf16_tuned_gemm.csv(lm_head, preshuffled, M=8,16,32,64,128) andminimax_m3_mxfp4_bf16_tuned_gemm.csv(FC, shuffled and row-major, M=8..128); matching untuned rows added.tgemm:get_GEMM_A16W16_tuned_configacceptsrg/rkrows forbpreshuffle;flydsl_gemmtreats both as no-bias / input-dtype-output policies and passes the tiling andbpreshufflethrough.bpreshuffle=Truethe kernels read AITER's (16, 16) shuffled weight in place; there is no second weight copy and no extra memory.Measured (public
tgemm.mm, CUDA-graph replay, ABAB, cold weights, MI355X)DSpark FC, N=1536 K=30720:
rk(us)lm_head, N=50016 K=6144, preshuffled weight:
rg(us)(the default-torch column is the pre-existing default path at the time of measurement; main now also has row-major exact-M rows for this shape from #8598, see Limits: against them the shuffled
rgis slower, so this table is the comparison for a caller that keeps the weight shuffled.)Verification
tgemm.mmlaunches it (eager and graph; 51 launched ring symbols matched theirkernelNametilings).kernelNameround trip: 0 failures on 17 CSV rows + 1264 catalog names.op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py, already run by the tuning-tests workflow): thepoliciesfilter, theis_shufflecatalog restriction (shuffled candidates onlyrg/rk), the ring pass-through in_flydsl_b_non_temporal_configs,run_flydsl_gemm_bf16(bpreshuffle), and every committedrg/rkrow parses with_HGEMM_KERNEL_RE, passes the policy tiling check and re-generates its own name. Ring kernel tests (GPU) are registered in.github/scripts/aiter_test.shandsplit_tests.sh.op_tests/tuning_testssubset (everything except test_run_config / test_tune_pipeline), branch vs a main tree: the failing-test-id lists are identical. CPU-only: 48 failed on both (same 48 ids). One single-GPU lease (MI355X, GPU 6): 27 failed on both,diffof the sorted FAILED/SUBFAILED id lists is empty (417 passed on the branch, 403 on main; the difference is the new tests). The shared failures are pre-existing and unrelated to this change:test_a16w16_tuned_config_lookupgfx1250 wrapper routing (TDM policies need gfx1250),test_grouped_ep_fused_lookup,test_fhmoe_tuner,test_fast_tuning,test_grouped_gemm_launch_abi. The ring GPU tests (test_flydsl_gemm_a16w16_ring.py,test_flydsl_gemm_a16w16_cat_x_ring.py) pass. After merging main, the lookup / config-shape-collision / csv-validation tests were re-run: only the same 8 gfx1250 routing failures remain.Limits and caveats
rg/rk, never shuffled ft/sk (the catalog restrictionis_shuffle). The behaviour is intentional and unchanged here.ParallelLMHead, no shuffle), so ATOM only benefits from the FC rows until it keeps the lm_head weight shuffled withis_shuffled=True(separate thin ATOM change, not in this PR).tests/test_flydsl_aot_replay.py::test_bf16_ring_csv_rows_reach_flydsl_through_public_replay, which also replays the probe at the smallest M a row serves); the ring kernels are not yetaot_factory-registered (JIT-compiled per process), follow-up.Review-pr by hand (
.claude/skills/review-pr,aiter-config-shape)Read the full diff against the rules;
fetch.shneeds a PR number so the collectors were not run. Checked: device / stream / i32-offset bounds in the host wrappers, output and weight validation, compile cache keyed on device and layout, graph-safe workspace (never evicted), CI registration of the new tests, no duplicate shape keys across the bf16 tuned family (script check plustest_config_shape_collision), untuned rows for every tuned shape. Deviations: the collectors were not run (no PR number before opening); the AOT pairing is not done (above).Review-fix update (head
282306df4)torch.cuda.is_available()only without a device (tuner-catalog callers), therkreduce is the FlyDSL one (timing re-measured, cat_x_ring us new / old Triton reduce: M8 18.46 / 19.67, M16 19.54 / 20.28, M32 20.40 / 20.97, M64 24.81 / 24.53, M128 31.23 / 32.35; all rowserr 0).outmust be non-overlapping with an even row stride, a 4-byte aligned base and a physical byte span below 2**31; the activation descriptor is(M-1)*stride + seg_k*2bytes._lds_ptruses the backendfx.to_llvm_ptr(fx.inttoptr(...))form (ring bench us new / old: M8 93.4 / 93.7, M16 93.7 / 93.5, M32 94.6 / 95.3, M64 95.8 / 96.1, M96 99.9 / 99.8, M128 107.9 / 112.4: no regression); the rawmfma_*calls keep a comment on why.REFUSALS(32de24874).mt3/4 at M=40, 7/8 at M=100), a tunedrkrow at a padded M throughtgemm.mm, expanded / padded output, a 2**28-element row stride refused, the 15-row replay test.Re-verified on gfx950: ring 54 passed, cat-x 48 passed (including the new refusal), the fast tuning subset 417 passed / 27 failed (the same 27 as on main: 8 gfx1250 wrapper routing, 19
GroupedEpFusedLookupTest, none touched by this PR), the AOT test files 58 passed / 4 skipped; the ring replay test fails without and passes with theREFUSALSchange (CPU, GPU hidden). The slowtest_run_config/test_tune_pipelinebf16 subsets were started but not completed within a lease.Reproduce:
python3 -m pytest op_tests/flydsl_tests/test_flydsl_gemm_a16w16_ring.py op_tests/flydsl_tests/test_flydsl_gemm_a16w16_cat_x_ring.py,python3 -m pytest tests/test_flydsl_aot_replay.py -k bf16_ring.Review-fix update (head
508716c52)origin/main(b66ea0d9c): no conflicts in the ring files; main's retune of 8 unrelated large-M (N>=2048) BF16 rows fromflydsl/asmtotorchinminimax_m3_eagle_bf16_tuned_gemm.csvis outside this PR's M<=128 rg/rk rows, andtests/test_flydsl_aot_replay.pygained unrelated main tests; neither touches the ring/cat-x-ring code.gemm_a16w16_ringand the cat-x ring's shared_launchreadn = w.shape[0]and checkw.shape[1], which a weight with an extra trailing dimension (e.g.[N, K, 0]) still passes while supplying the wrong element count to the raw-pointer kernel. Both now requirew.ndim == 2before any launch.warmup_cat_x_ringonly compiled tiers at multiples of 16 rows, som_max=8compiled nothing andm_max=17stopped at themt=1tier, leaving themt=2tier the caller actually uses uncompiled before CUDA-graph capture. It now also warms the exactm_maxwhen it is not itself a multiple of 16.warmup_cat_x_ring(m_max=8)and(m_max=17)leave no compile for a later call at that exact M.Re-verified on gfx950 (MI355X, node 034 GPU 0, lease
Lee74d6): 106 passed (ring + cat-x-ring suites), including the 4 new tests.PR Self-Review
Reviewed revision
508716c52Behavior and intent
Adds two small-M BF16 GEMM policies for gfx950 behind the usual catalog / tuner /
tgemmpath and tuned rows, instead of direct kernel calls. They give 18-27% (FC,rk) and, for a shuffled weight, 37-41% (lm_head,rg, M=64..128) lower latency than the default torch path; against main's row-major lm_head rowsrgis slower, as stated above.Validation and unverified scope
Commands and results are in the Measured, Verification and review-fix sections (gfx950 MI355X): every shuffled lm_head row and every FC row is tuned to a ring kernel and launched by
tgemm.mm(eager and graph), correctness vs an fp32 reference 0.18%-0.95% max-abs-err, name round trip 0 failures on 17 CSV rows + 1264 catalog names. Not verified: end-to-end effect; the slow tuning tests; the ring kernels' AOT registration; the shuffled lm_head at M = 1, 2, 4 and M > 128 has no row (no solution, as on main).PR-specific question
What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
The CI change is two lines:
.github/scripts/aiter_test.shadds the two new ring test files to an existingcaselist and.github/scripts/split_tests.shlists them. No workflow file is edited, no secrets, permissions orpull_request_targetare involved; the lines only name repository test files that the existing job runs withpython3 -m pytest -q <file>.Changed op tests
op_tests/flydsl_tests/test_flydsl_gemm_a16w16_ring.py: GPU tests of thergring kernel against torch (row-major and shuffled weights, M 1..128, padded tiles) and a ring bench; no existing test exercises this kernel.op_tests/flydsl_tests/test_flydsl_gemm_a16w16_cat_x_ring.py: GPU tests of therksplit-K ring (cat-x taps, expanded / padded inputs and outputs, tile larger than the rows, the refusal of a 32-bit-unsafe output span) and a bench that asserts zero mismatches.op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py: CPU tests of the tuner and lookup side: thepoliciesfilter, theis_shufflecatalog restriction, the ring pass-through in the non-temporal configs,run_flydsl_gemm_bf16(bpreshuffle), and that every committedrg/rkrow parses, passes the tiling check and regenerates its own name; it is the existing tuned-config lookup test.🤖 Generated with Claude Code