Skip to content

[HIP] [OPUS] [FlyDSL] gfx950 MXFP8 bmm: 1x32 weight scales, grouped XCD order, MiniMax-M3 configs - #6060

Merged
valarLip merged 9 commits into
ROCm:mainfrom
sshlyapn:sshliapn/features/mxfp8
Oct 27, 2026
Merged

valarLip merged 9 commits into
ROCm:mainfrom
sshlyapn:sshliapn/features/mxfp8

Conversation

@sshlyapn

@sshlyapn sshlyapn commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

#5896 added the gfx950 FlyDSL MXFP8 e8m0 GEMM/bmm, but only for square weight-scale blocks (32x32, 128x128, DeepSeek-V4/V4.1). OCP MX checkpoints such as MiniMax-M3 carry 1x32 weight scales (one e8m0 per weight row per 32 K), so they could not use it. This PR extends the same kernel, with no new kernel and no change to the 32x32 / 128x128 paths.

Resolves: #5916

Changes

  • 1x32 weight scales: w_scale [B, N, K/32] is accepted (W_SCALE_ROWS = (1, 32, 128)).
    The kernel reads the B-scale panel one row per B row, the same way it reads A's.
    This is wired through dispatch (_RUNNERS, gemm_a8w8_blockscale_bpreshuffle) and AOT.
    • The layout is row-major, the same as x_scale: no repack, independent of config.
  • xcd_swizzle (_xcd<g> in kernel names): inside each XCD's contiguous run of tiles
    (xcd_order), tiles are re-ordered M-major in groups of g M tiles, as
    xcd_remap_bx_by does. Fewer B column blocks are live per XCD, so L2 reuse improves.
    • The heuristic for b_direct configs now picks _xcd4 instead of _xcd.
    • Existing _xcd CSV rows parse and run unchanged.
  • LDS: the 16-byte split-K flag is reserved only when K is actually split. This lets a
    few large tiles fit.
  • Tuned configs: model_configs/minimax_m3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv
    • 342 rows: 18 MiniMax-M3 dense N x K shapes (TP1/TP2/TP4) x M in {1..512, 1k..64k}.
  • Tests: test_flydsl_batched_gemm.py adds a 1x32 case (weight magnitudes change every
    row). test_gemm_group32_interface.py routes 1x32 and checks that 1x128 is still rejected.

Performance (MI355, gfx950, 256 CU)

vLLM MiniMaxAI/MiniMax-M3-MXFP8 performance (TP4, 8k/1k random dataset):

Metric C=1 C=16 C=64
Output throughput +4.4% +4.1% +5.0%
TTFT mean -5.8% -8.0% -8.8%
TTFT p99 -4.7% -8.9% -9.1%
TPOT mean -4.2% -3.4% -4.3%
TPOT p99 -3.9% -3.4% -5.3%
E2E latency mean -4.2% -3.9% -4.8%

Speedup of this PR (tuned CSV) over each MXFP8 1x32 baseline: geomean over the 18 M3 shapes.
Above 1 means this PR is faster.

M vs vLLM Triton MXFP8 vs AITER group32 Triton (#5750/#5862), tuned
1-16 1.30-1.35x 0.99-1.03x
32-256 1.54-2.07x 1.05-1.15x
1k 2.06x 1.42x
2k-16k 1.57-1.70x 1.30-1.34x
24k-128k 1.74-2.18x 1.33-1.35x

Effect of the tile order alone: 15 tuned _xcd4 rows were re-timed with the same config,
changing only the tile order to _xcd (#5896's order) or to no XCD order.

  • _xcd4 vs _xcd: never slower, 0.3-27% faster.
  • _xcd4 vs no XCD order: about equal at M <= 16k (-1% to +5%, one +20% case),
    5-26% faster at M >= 32k.

Protocol:

  • Weights rotate between 2 copies; each point is the median of 3 interleaved rounds.
  • Every timed config was checked against a dequantized fp32 reference: rel err < 3e-3.

Tests

  • op_tests/test_gemm_group32_interface.py: 146 passed.
  • op_tests/test_flydsl_batched_gemm.py, 1x32 / 32x32 / 128x128 a8w8:
    • b in {1, 8, 16}, M from 1 to 16384, N=1024, K=4096.
    • 0 cases with cos < 0.99.
  • black: clean. ruff: no new findings.

Not a duplicate

@sshlyapn
sshlyapn requested review from a team and a balanced review from Copilot October 1, 2026 17:07
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
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
multigpu 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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 6060 --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.

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 review overview

🟡 Changes recommended

The shared rowwise test input weakens existing square-block scale-indexing coverage, and one public layout description incorrectly implies 1x128 support.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Extends the gfx950 FlyDSL MXFP8 GEMM path for MiniMax-M3’s 1x32 weight scales and improves tile ordering.

Changes:

  • Adds 1x32 scale support across kernel, dispatch, and AOT.
  • Adds grouped XCD swizzling and conditional split-K LDS storage.
  • Adds MiniMax-M3 tuning rows and test coverage.
File Description
op_tests/​test_gemm_group32_interface.py Tests 1x32 routing and 1x128 rejection.
op_tests/​test_flydsl_batched_gemm.py Adds 1x32 numerical coverage.
aiter/​ops/​flydsl/​kernels/​bmm_a8w8_mxscale_gfx950.py Implements scale loading, XCD swizzling, and LDS sizing.
aiter/​ops/​flydsl/​batched_gemm_a8w8.py Registers gfx950 1x32 dispatch.
aiter/​ops/​flydsl/​batched_gemm_a8w8_gfx950.py Extends parsing, validation, and launch configuration.
aiter/​ops/​batched_gemm_op_a8w8.py Documents the public 1x32 contract.
aiter/​configs/​model_configs/​minimax_m3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv Adds 324 MiniMax-M3 tuned configurations.
aiter/​aot/​flydsl/​gemm.py Adds 1x32 AOT compilation wiring.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread op_tests/test_flydsl_batched_gemm.py Resolved
Copilot AI balanced review requested due to automatic review settings October 1, 2026 18:03
@sshlyapn
sshlyapn force-pushed the sshliapn/features/mxfp8 branch from 41fb2df to 2e00a4d Compare October 1, 2026 18: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 review overview

🟡 Changes recommended

The kernel-name formatter can silently encode xcd_swizzle as a different split-K value.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)

@zufayu
zufayu requested a review from coderfeli October 2, 2026 00:32
@sshlyapn
sshlyapn force-pushed the sshliapn/features/mxfp8 branch from 2e00a4d to 70f36c1 Compare October 2, 2026 09:46
Copilot AI balanced review requested due to automatic review settings October 2, 2026 09:46

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 review overview

🔵 Needs a closer look

The low-level GPU scheduling and scale-loading changes require final hardware-backed human validation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (3)

Copilot AI balanced review requested due to automatic review settings October 2, 2026 09:50

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 review overview

🔵 Needs a closer look

GPU kernel correctness and performance require final gfx950 hardware validation.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

@sshlyapn

sshlyapn commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@valarLip could you please take a look at these changes when you have a moment?

@sshlyapn

sshlyapn commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderfeli could you please take a look at this PR?

@valarLip

Copy link
Copy Markdown
Collaborator

Per the CI guide's one-concern / stacked-PR rule, this PR is now split into three, with @sshlyapn kept as commit author:

  1. [FlyDSL] gfx950 MXFP8 bmm: accept 1x32 (OCP MX) weight scales #6439 — [FlyDSL] gfx950 MXFP8 bmm: accept 1x32 (OCP MX) weight scales (based on main)
  2. [FlyDSL] gfx950 MXFP8 bmm: grouped XCD tile order, split-K LDS flag only when split #6440 — [FlyDSL] gfx950 MXFP8 bmm: grouped XCD tile order, split-K LDS flag only when split (based on main, independent of 1)
  3. [FlyDSL] MiniMax-M3 MXFP8 1x32 tuned GEMM configs #6441 — [FlyDSL] MiniMax-M3 MXFP8 1x32 tuned GEMM configs (stacked on 1 and 2; review only its last commit)

Together they equal this PR's code exactly, plus new 32x32 _xcd4 accuracy and kernel-name round-trip tests in #6440 so it is tested on its own. Copilot's open M=512 note is addressed in #6441's description (the CSV covers 19 M buckets, including 512).

Suggest closing this PR once the split is acknowledged.

i would like this style more, thank you both for your great works @andrei-kochin @sshlyapn

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this at 2471108c. The new 1x32 path computes correctly. I ran it on gfx950 against a dequantized fp32 reference, and everything passed with a max relative error under 3e-3. The cases covered:

  • K % 128 == 64 (half step, byte-slot scale panel);
  • a 1x128 x_scale with a 1x32 w_scale;
  • batch 3/5 with _xcd4/_xcd3 on a padded grid;
  • split-K with _sps;
  • heuristic picks.

The PR's own route/rejects/1x32 tests (97) also pass. All 342 CSV rows parse and pass check_bmm_config, they don't collide with the existing mxscale tables, and the swizzle is a bijection for every M/N/batch I tried.

I see this has been split into #6439/#6440/#6441. The points below should carry over to whichever of those holds the same code.

1. Most of the large-M rows in the new CSV cannot be reached

get_mxscale_bpreshuffle_config looks up M, then getPaddedM(gl=0), then getPaddedM(gl=1):

  • gl=0 only rounds M > 4096 up to a multiple of 128;
  • gl=1 clamps any M > 8192 && N > 4096 to 8192.

So for the 14 shapes with N > 4096, the 12288/16384/24576/32768/49152 rows are used only when M equals the bucket exactly.

Here is the real lookup at N = K = 6144 on this head:

runtime M row used
12288 12288 (t192x256x128_nb3_bd2_xcd4)
12300, 16000, 20000, 30000, 40000, 100000 8192 (t256x256x128_nb2_bd1_xcd4)
24576 24576

For N = 1536 (gl=1 rounds to the next power of 2), M = 100000 misses entirely and falls back to the heuristic.

The "24k-128k: 1.33-1.35x" in the description therefore mostly applies only at the exact tuned M. Possible fixes:

  • tune at the M values getPaddedM actually produces;
  • or keep only one large-M row per shape and drop the rest, so the table doesn't suggest coverage it lacks.

2. The heuristic change also moves the 32x32 / 128x128 paths

The description says "no change to the 32x32 / 128x128 paths". However, pick_bmm_kernel_name now returns _xcd4 instead of _xcd for every b_direct pick, whatever the w_scale block. An untuned DeepSeek-V4 shape such as b=1, M=4096, N=1536, K=1024 with 128x128 scales now gets t256x256x128_w1x4_nb2_sk1_bd1_xcd4.

I ran 8 such cases (32x32 and 128x128, b = 1/3/5/16) on GPU and they are numerically correct, so this is not a bug. It is a behaviour change on those paths, though, and in this PR they are covered only indirectly through the heuristic. Please say so in the description, and either back it with a perf number for a DSV4 shape or keep _xcd for the square blocks.

3. Some configs the parser and checker accept are not what they say

  • Split-K drops the XCD order without saying so. In the kernel, splits > 1 takes the 1-D split branch first, so xcd_order/xcd_swizzle never apply. check_bmm_config still accepts e.g. ..._sk2_bd1_xcd4, which compiles and caches as a separate kernel identical to ..._sk2_bd1. Neither the heuristic nor this CSV produces that combination today. A tuner sweeping the flags would, and its timing would be credited to a swizzle that never ran. Rejecting splits > 1 and xcd_order in check_bmm_config closes this.

  • Kernel names have more than one spelling. _xcd(?P<xcd_swizzle>\d*) accepts digits the builder never emits. On this head:

    • _xcd0 parses to swizzle 0 and rebuilds as _xcd;
    • _xcd04 rebuilds as _xcd4;
    • _xcd1 is accepted and kept as its own name, although xcd_swizzle > 1 is the only case that re-tiles, so it is the same kernel as _xcd compiled twice.

    Restricting the regex to _xcd(?:[2-9]|[1-9]\d+)? and rejecting xcd_swizzle == 1 keeps one name per kernel. That matters for CSV/AOT dedup.

  • The shape check got looser. _scale_block(n, w_scale.shape[1], ..., W_SCALE_ROWS) now accepts a 1-row w_scale without looking at the K edge. A direct run_bmm_a8w8_mxfp8_gfx950 call with a 1x128 w_scale ([B, N, K/128]) used to fail there with a message naming the block. It now gets through and only fails later in pick_bmm_kernel_name/check_bmm_config, with "no kernel config runs" or a generic scale-block error. Checking w_scale_n == 1 implies w_scale_k == 32 at this point would keep the early, clear error.

4. Duplication in the new swizzle

  • The M-group re-tiling (num_wgid_in_group/first_pid_m/group_size_m/wgid_in_group) repeats xcd_remap_bx_by in mfma_preshuffle_pipeline.py line for line. A shared helper keeps a future tail-group fix from landing in only one place.
  • When xcd_swizzle > 1, the bid_x, bid_y, bid_z assignment just above is overwritten in full, so it only adds reading cost. Computing the N-fastest mapping in an else branch would make clear which mapping is in effect.
  • The xcd_swizzle < 0 or (xcd_swizzle and not xcd_order) rule is written twice, in bmm_kernel_name and check_bmm_config. If the rule is tightened (as in section 3), it must change in both places.

5. Tests

  • Wasted work in test_batched_gemm. Each a8w8 candidate now has its own w_blk and reference. On gfx950, which has no a8w4, w_bnk and ref = run_torch_wo_a(o_mbn, w_bnk, dtype) are still generated and computed but never used. That is a full-size randn and a BF16 einsum per case (up to M = 16384, b = 16) for nothing. They could be built only when a8w4 is a candidate.
  • A missing reject case. The rewritten test_mxscale_bpreshuffle_rejects_row_scales covers a 1x128 weight block. Nothing covers a 1x32 weight paired with a 128-wide (column-major) x_scale, which the 2-D route must also reject. Today _RUNNERS has no ("gfx950", "1x32", True) entry. If one is added, or if the k // x_scale.shape[-1] == 128 check changes, no test would fail.

gfx950,256,2048,6144,6144,1x32,flydsl,bmm,1,76.382,flydsl_bmm_mxfp8_mfma_t256x192x128_w1x4_nb2_sk1_bd1_xcd4,2024.28,1009.01,0.0
gfx950,256,4096,6144,6144,1x32,flydsl,bmm,1,145.303,flydsl_bmm_mxfp8_mfma_t128x256x128_w1x4_nb3_sk1_bd2_xcd4,2128.23,792.91,0.0
gfx950,256,8192,6144,6144,1x32,flydsl,bmm,1,275.907,flydsl_bmm_mxfp8_mfma_t256x256x128_w1x4_nb2_sk1_bd1_xcd4,2241.61,694.06,0.0
gfx950,256,12288,6144,6144,1x32,flydsl,bmm,1,403.02,flydsl_bmm_mxfp8_mfma_t192x256x128_w1x4_nb3_sk1_bd2_xcd4,2301.9,664.43,0.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This row (and the 16384/24576/32768/49152 ones for N > 4096) is reached only at exactly this M. getPaddedM gl=0 rounds M to a multiple of 128 and gl=1 clamps M > 8192 && N > 4096 to 8192. So M = 12300, 16000, 20000, 30000, 40000 or 100000 at N = K = 6144 all use the 8192 row above. See section 1 of the review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for N>4096 shapes, untuned M above 8192 falls back to the 8192 row through find_padded_m_row. However, those prefill M values are tuned at common max num batched tokens settings (8k, 12k, 16k, 24k, 32k, 48k, 64k). Full chunked-prefill steps run at exactly that M, so they hit these rows

# The XCD tile order wants the N x batch tiles in 8s, as split K does.
xcd_order = cfg["b_direct"] and runs({**cfg, "xcd_order": True})
return bmm_kernel_name(**cfg, splits=splits, xcd_order=xcd_order)
xcd = {"xcd_order": True, "xcd_swizzle": 4}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to every b_direct pick, so untuned 32x32 / 128x128 (DeepSeek-V4) shapes move from _xcd to _xcd4 too. For example, b=1, M=4096, N=1536, K=1024 with 128x128 scales now gets t256x256x128_w1x4_nb2_sk1_bd1_xcd4. It is numerically fine on GPU, but it contradicts "no change to the 32x32 / 128x128 paths" in the description.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually verified this as default for 32x32 and 128x128 as well, and noticed neutral to positive impact, but I limited swizzle back only for 1x32 weight scales to minimize the changes for now

raise ValueError(
"[FlyDSL gfx950] a column-major x_scale is 1x128 blocks at batch 1"
)
if xcd_swizzle < 0 or (xcd_swizzle and not xcd_order):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't reject splits > 1 with xcd_order, but the kernel's split branch ignores the XCD order entirely. ..._t64x128x128_w1x4_nb3_sk2_bd1_xcd4 passes here and compiles as a separate kernel identical to ..._sk2_bd1, so a tuner would credit its timing to a swizzle that never ran. The same rule also lives in bmm_kernel_name, so both copies would need to change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed, split K combined with a swizzle number is now rejected

r"_t(?P<tile_m>\d+)x(?P<tile_n>\d+)x(?P<tile_k>\d+)"
r"_w(?P<m_warp>\d+)x(?P<n_warp>\d+)_nb(?P<num_buffers>\d+)_sk(?P<splits>\d+)"
r"(?:_bd(?P<b_ahead>\d+))?(?P<b_nt>_nt)?(?P<xcd_order>_xcd)?(?P<per_stage>_sps)?$"
r"(?:_bd(?P<b_ahead>\d+))?(?P<b_nt>_nt)?(?P<xcd_order>_xcd(?P<xcd_swizzle>\d*))?"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\d* admits names the builder never emits: _xcd0 rebuilds as _xcd, _xcd04 as _xcd4, and _xcd1 is kept although swizzle 1 doesn't re-tile, so it is the same kernel as _xcd under a second name and cache entry. Something like _xcd(?:[2-9]|[1-9]\d+)?, plus rejecting xcd_swizzle == 1, keeps one name per kernel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

scale_args = (
_scale_block(k, x_scale.shape[2], "x_scale K"),
_scale_block(n, w_scale.shape[1], "w_scale N"),
_scale_block(n, w_scale.shape[1], "w_scale N", W_SCALE_ROWS),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With W_SCALE_ROWS the N edge may now be 1 whatever the K edge is, so a 1x128 w_scale ([B, N, K/128]) passes here. Before this PR it failed at this line with a message naming the block; now it fails later, in pick_bmm_kernel_name / check_bmm_config, with a vaguer error. Checking that a 1-row w_scale is 1x32 here keeps the early error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. It now fails up front with "a 1-row w_scale must be 1x32 blocks"

tile = bid_x % 8 * per_xcd + bid_x // 8
rest = tile // (N // tile_n)
bid_x, bid_y, bid_z = rest % m_tiles, tile % (N // tile_n), rest // m_tiles
if const_expr(xcd_swizzle > 1):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines repeat xcd_remap_bx_by (mfma_preshuffle_pipeline.py) line for line. A shared helper would keep a tail-group fix in one place. Also, in this branch the bid_x, bid_y, bid_z computed on the line above are all overwritten, so the N-fastest mapping could move to an else branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied, I unified and reused the logic between implementations

Comment thread op_tests/test_flydsl_batched_gemm.py Outdated
@@ -198,7 +200,7 @@ def test_batched_gemm(b, m, n, k, dtype, layout):
y_out = y_phys

ref = run_torch_wo_a(o_mbn, w_bnk, dtype)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On gfx950 (no a8w4) every a8w8 candidate uses its own refs[name], so w_bnk and this ref are never read. That is a full-size randn and a BF16 einsum per case (up to M=16384, b=16). They could be built only when a8w4 is a candidate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. They're built only when a8w4 runs, and each candidate uses its own reference

Comment thread op_tests/test_gemm_group32_interface.py Outdated
)
with pytest.raises(NotImplementedError, match="1x32"):
gemm_op_a8w8.gemm_a8w8_blockscale_bpreshuffle(*_mxscale_operands(w_rows=1))
with pytest.raises(NotImplementedError, match="1x128"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers a 1x128 weight block. Nothing covers a 1x32 weight paired with a 128-wide (column-major) x_scale, which must also be rejected. Adding ("gfx950", "1x32", True) to _RUNNERS, or changing the k // x_scale.shape[-1] == 128 check, would currently go unnoticed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a reject test

Copilot AI balanced review requested due to automatic review settings October 15, 2026 12:15

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 reached their quota limit.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked at bb68f70. The kernel side looks right to me:

  • the 1x32 panel row mapping;
  • half-step K;
  • dropping the LDS flag at splits == 1;
  • the _xcd<g> names round-trip, and the swizzled tile map is a bijection on every padded grid / batch > 1 / short last group I simulated;
  • the new CSV's 342 rows all parse, and they merge with the dsv4 / dsv41 tables without a duplicate key.

What remains is in table loading and dispatch. Inline comments point at the lines.

1. The new w_scale_block check in _load_mxscale_bpreshuffle_tuned can fail the whole table

Both of these reproduce on CPU (pandas + AITER_CONFIGS.update_config_files):

  • A merged table fills the missing column with 0, not a blank. update_config_files fills columns a source lacks with _FILL_DEFAULTS.get(c, 0) (aiter/jit/core.py). So merging a table from before the column (via AITER_CONFIG_GEMM_A8W8_BLOCKSCALE_MXSCALE_BPRESHUFFLE=new.csv:old.csv, or a model_configs/ file) gives w_scale_block = '0', and the loader raises w_scale_block ['0'] not in (...). Every gfx950 E8M0 bpreshuffle GEMM in the process then fails, where on the base those rows just never matched. with_mxscale_w_scale_block's docstring describes this case as blank cells, but the merge never produces them.
  • drop_duplicates() runs before the blanks are filled. A shape with one blank row and one 128x128 row passes the duplicate check, which sees NaN and '128x128' as different keys. After the fill they share a key, and to_dict("index") raises DataFrame index must be unique for orient='index' on the first call.

Normalising before both checks would avoid each failure: treat 0/blank as the default first, then de-duplicate and check.

2. A blank w_scale_block means 128x128 at runtime but 1x32 in AOT for blockscale-table mxfp8 rows

The runtime loader now reads a blank cell as 128x128 for every row of the blockscale table. AOT parse_csv changed the default only for kernelId=bmm rows. Its kernelId=mxfp8 branch still uses row.get("w_scale_block") or "1x32". So for such a row, AOT compiles the 1x32 build while runtime runs 128x128 and JIT-compiles on first use.

3. 1x32 FlyDSL rows and non-bf16 outputs

The batched tuner no longer rejects FlyDSL for 1x32, so it can now write libtype=flydsl 1x32 rows. It times bf16 only, and the table has no dtype key. A tuned 1x32 FlyDSL row then raises Out must be bf16 (a RuntimeError from the runner) for an fp32 or fp16 call. On the base, every 1x32 call went to OPUS, which writes fp32.

The new bf16 check covers only the untuned branch, and raises NotImplementedError there, so the same condition surfaces as two exception types. Checking it once where libtype == "flydsl" (and falling back to OPUS when a kid runs the shape) would cover tuned and untuned 1x32 alike.

4. Smaller points

  • Pairing check order. In _gemm_mxscale_bpreshuffle, the x_scale/w_scale pairing check comes after the lookup and the libtype check. As a result, a call whose row will be discarded anyway (for example, 1x128 x_scale with 1x32 w_scale):

    • still logs "untuned" on a miss;
    • raises NotImplementedError if the row isn't FlyDSL;
    • silently drops the row if it is FlyDSL.

    Checking the pairing first avoids all three.

  • _opus_1x32_bpreshuffle_kid repeats the kid search that bmm_a8w8_mxscale_opus_bpreshuffle already runs when kernelId=None. Its cache key includes M, so decode sees a fresh search per M.

  • test_mxscale_table_tuner_times_bmm generates candidates for N=4608 (bmm_candidates(1, 4608, 6144, block)) but validates them with N=6144 (check_bmm_config(6144, 6144, ...)).

  • test_batched_untuned_1x32_runs_flydsl_where_opus_cannot clears _opus_1x32_bpreshuffle_kid at the end, not in a finally. A failing assert leaves kids computed under the faked gfx950 in the module cache, whose key has no gfx.

  • test_mxscale_bpreshuffle_32_wide_w_blockscale_x is parametrized over row=[None, BMM_ROW]. With a 1x128 x_scale and a 1x32 / 32x32 w_scale, dispatch always drops the row, so 6 of its 12 GPU cases run the same heuristic kernel twice.

  • GPU coverage of the new untuned 1x32 routing. The new 1x32 GPU case in test_flydsl_batched_gemm.py calls run_bmm_a8w8_mxfp8 directly. The public entry's new untuned routing (OPUS kid, else FlyDSL when K % 128 != 0) is covered only by the CPU mock test.

  • Duplicated check_bmm_config wrapper. "try check_bmm_config / except ValueError → bool" now exists four times: batched_gemm_a8w8_gfx950._runs, the batched tuner's _runs, runs_row_major in the 2-D tuner, and the test's _bmm_legal. Exporting _runs would leave one.

  • AOT FlyDSL depends on the OPUS policy. It now gets block → (rows, cols) from opus.policy.mxscale_bmm_groups_of_block, whose error reads "unsupported OPUS MXFP8 BMM scale block". That mapping fits better in gemm_op_common next to mxscale_w_scale_block.

  • Launcher docstring. It says xcd_swizzle > 0 re-tiles. The code branches on > 1, and xcd_swizzle_runs rejects 1.

Comment thread aiter/ops/gemm_op_a8w8.py Outdated
table for preshuffled weights."""
path = AITER_CONFIGS.AITER_CONFIG_GEMM_A8W8_BLOCKSCALE_MXSCALE_BPRESHUFFLE_FILE
df = pd.read_csv(path).drop_duplicates()
df = with_mxscale_w_scale_block(pd.read_csv(path).drop_duplicates(), path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two ways this raises for the whole table (both reproduced on CPU): a merge with a table from before the column fills it with 0, which this check rejects; and drop_duplicates() runs before the blanks become 128x128, so a blank row and a 128x128 row of one shape end up with the same key and to_dict("index") raises. See section 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. 0 and blank cells now read as the default (mxscale_w_scale_block_cell) before the duplicate check. A table merged with an older one loads, and a blank row plus a 128x128 row of the same shape loads with a warning; the first row is used.

Comment thread aiter/aot/flydsl/gemm.py Outdated
layouts = (
(False, True)
if row.get("w_scale_block", "128x128").strip() == "128x128"
if (row.get("w_scale_block") or "128x128").strip() == "128x128"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the bmm branch moved to a 128x128 default. The kernelId=mxfp8 branch above still reads a blank as 1x32, while the runtime loader now reads it as 128x128 for every row of this table (section 2).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. AOT and the runtime share mxscale_w_scale_block_cell now: a blank cell is 128x128 in the blockscale table and 1x32 in the mxfp8 table.

kid = _opus_1x32_bpreshuffle_kid(g, m, n, k, dtype)
if kid is not None:
libtype = "opus"
elif dtype != dtypes.bf16:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers untuned 1x32 only. With the tuner now writing 1x32 FlyDSL rows (timed in bf16, no dtype key), a tuned one raises the runner's RuntimeError('Out must be bf16') for fp32/fp16, which OPUS served on the base. One check where libtype == "flydsl" would cover both (section 3).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. There is one check where libtype is flydsl, for tuned and untuned rows and every w_scale block. Non-bf16 output goes to OPUS when one of its kids runs the shape; otherwise it raises NotImplementedError.

Comment thread aiter/ops/gemm_op_a8w8.py Outdated
# (1x128 with 128x128, else 1x32); bmm reads every other pairing too, its
# heuristic picks.
if x_block != (_BLOCKSCALE_X_BLOCK if w_scale_block == "128x128" else 32):
config = backend = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the pairing before the lookup would skip the 'untuned' warning and the libtype check for a row that is dropped here anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, the pairing is checked before the lookup.

return _batched_gemm_a8w8_mxscale_impl(x, wo_a, x_scale, w_scale, dtype=dtype)


@functools.lru_cache(maxsize=1024)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bmm_a8w8_mxscale_opus_bpreshuffle runs this same kid search when kernelId=None, and with M in the key decode searches per M.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This search is the FlyDSL fallback from r4334427972: dispatch has to know whether an OPUS kid runs the shape before choosing OPUS, and with kernelId=None OPUS raises ValueError instead of falling back. The kid found here is passed on as kernelId (already at bb68f70), so OPUS only validates it and doesn't search again. M stays in the key because the pick depends on M (1x32: kid 9713 from M>=64 with >=256 wide tiles, 9703 from M>=256). Each M is searched once and cached; OPUS's own kernelId=None path searches on every call. The helper is now _opus_bpreshuffle_kid, since the non-bf16 check also uses it.

Comment thread op_tests/test_gemm_group32_interface.py Outdated
batched._batched_gemm_a8w8_mxscale_bpreshuffle_impl(
*operands, dtype=torch.float16
)
batched._opus_1x32_bpreshuffle_kid.cache_clear()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in a finally: a failing assert above leaves kids computed under the faked gfx950 in the cache, whose key has no gfx.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, the cache clears are in finally.

Comment thread op_tests/test_gemm_group32_interface.py Outdated
@pytest.mark.parametrize("m,n,k", [(1, 1536, 1024), (37, 5120, 1536), (300, 512, 5120)])
@pytest.mark.parametrize("row", [None, BMM_ROW])
@pytest.mark.parametrize("w_rows", [1, 32])
def test_mxscale_bpreshuffle_32_wide_w_blockscale_x(monkeypatch, m, n, k, row, w_rows):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a 1x128 x_scale and a 1x32 / 32x32 w_scale, dispatch always drops the row, so row=BMM_ROW reruns the row=None case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, removed the row parameter.

return names
row_major = {**scale_args, "x_scale_transposed": False}

def runs_row_major(name):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fourth copy of try check_bmm_config / except → bool (with batched_gemm_a8w8_gfx950._runs, the batched tuner's _runs and the test's _bmm_legal).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. bmm_config_runs in batched_gemm_a8w8_gfx950 is now the only wrapper; both tuners and the test use it.

Comment thread aiter/aot/flydsl/gemm.py Outdated
rows, cols = (int(v) for v in w_scale_block.split("x"))
if rows != cols:
raise ValueError(f"{kernel_name}: no AOT wiring for a {w_scale_block} w_scale")
from aiter.ops.opus.policy import mxscale_bmm_groups_of_block

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlyDSL AOT now depends on the OPUS policy for this mapping, and its error says 'unsupported OPUS MXFP8 BMM scale block'. It fits better in gemm_op_common next to mxscale_w_scale_block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. mxscale_bmm_groups_of_block is in gemm_op_common now, with a neutral error message; opus.policy imports it from there.

contiguous run of tiles so neighbours share its L2. x_scale_k and
w_scale_n x w_scale_k are the e8m0 block edges, each 32 or 128.
w_scale_n may also be 1 with w_scale_k 32 (1x32), a scale per B row.
xcd_swizzle > 0 re-tiles the xcd_order run M-major in groups of

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code branches on xcd_swizzle > 1, and xcd_swizzle_runs rejects 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, it says xcd_swizzle >= 2.

…iMax-M3 configs

- Accept 1x32 (OCP MX) w_scale [B, N, K/32] in the gfx950 mxscale bmm,
  dispatch and AOT paths; 32x32 / 128x128 are unchanged.
- Add xcd_swizzle (_xcd<g> names): M-major groups of g tiles inside each
  XCD's run; the b_direct heuristic now picks _xcd4.
- Reserve the split-K flag in LDS only when K is split.
- Add the MiniMax-M3 1x32 tuned CSV (TP1/2/4, M 1..64k).

Signed-off-by: Sergei Shliapnikov <[email protected]>
…split-K swizzle names at parse time, and pass splits to the LDS layout.
- Tune bmm 1x32 in the --mxscale_table tuner and point the README there.
- Share bmm_candidate_names between tuners; split variants drop swizzle and xcd order.
- Add FlyDSL runners for column-major 1x32 and 32x32 x_scale.
- Fall back to FlyDSL for untuned 1x32 when OPUS has no kid for the shape.
- Keep tuned rows on their tuned x_scale block; AOT covers every dispatched layout.
- Move the swizzle rule to xcd_swizzle_runs and the name suffix to bmm_config_name.
- check_bmm_config returns the LDS layout used by the launcher.
@sshlyapn
sshlyapn force-pushed the sshliapn/features/mxfp8 branch from bb68f70 to c65f871 Compare October 26, 2026 09:28
- Read a blank or merge-filled 0 w_scale_block cell as the default in the
  runtime loader and AOT alike; a blank row repeating a 128x128 shape loads.
- gfx950 flydsl writes bf16 only: non-bf16 output runs OPUS's kid, tuned row
  or not, and raises when no kid runs the shape.
- Check the x/w scale pairing before the table lookup.
- Move mxscale_bmm_groups_of_block to gemm_op_common; export bmm_config_runs
  as the one check_bmm_config -> bool wrapper.
- Tests: try/finally cache clears, N=4608 in the tuner test, drop the
  redundant row parametrize, GPU check of the public untuned 1x32 entry.
@sshlyapn
sshlyapn force-pushed the sshliapn/features/mxfp8 branch from c65f871 to 94d5d6a Compare October 26, 2026 09:30
@sshlyapn

Copy link
Copy Markdown
Contributor Author

Thanks! Addressed in 94d5d6a, rebased onto 778d74d. I also added test_batched_untuned_1x32_matches_dequant, which runs the untuned batched entry on GPU at K=512 (OPUS) and K=576 (FlyDSL) against the dequantized reference. It passes on MI355X.

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked at 94d5d6a. This looks good to merge once the four small points below are addressed. Inline comments point at the lines.

The two loader failures from the last round are fixed. Blank or 0 cells are normalised before the check, and duplicates are dropped after the normalisation. Both of last round's repros now load. On the kernel side, I found nothing wrong in the 1x32 scale path:

  • the panel sizing;
  • the global→LDS offsets;
  • the per-row scale read;
  • the split-K flag being reserved only when K is split;
  • the xcd_swizzle tile map, which is a bijection with padded tiles still guarded.

All 2394 gfx950 bmm kernelNames in the shipped CSVs parse and pass check_bmm_config. The MiniMax CSV duplicates no shape, and AOT compiles what the runtime runs.

  1. The public docstring of batched_gemm_a8w8_mxscale_bpreshuffle is stale for 32x32 / 128x128. It still says these blocks run "flydsl's heuristic off the table". On gfx950, though, any non-bf16 output now goes to OPUS, even over a tuned FlyDSL row, and raises NotImplementedError when no OPUS kid runs the shape. Only the private _impl docstring says so.
  2. The README states OPUS's K limit for 1x32. It says that for 1x32, "K a multiple of 128". FlyDSL now runs 1x32 at K ≡ 64 (mod 128), e.g. K = 576, which the group32 interface test asserts, so the tuner can produce such rows.
  3. _load_mxscale_bpreshuffle_tuned keeps the first of two rows with the same key, not the faster one. A blank cell (read as 128x128) and an explicit 128x128 row of the same shape are different raw cells, so both survive the merge's lowest-us dedup. The model_configs glob is unsorted, so which row comes first can differ between machines. Sorting by us before duplicated(...) would match the merge's rule.
  4. _launch_config returns None for names that break the swizzle rule (e.g. _sk2_..._xcd4, _xcd1), and runtime and AOT then disagree. At runtime, _require_config raises "unrecognised kernelName" for such a tuned row instead of falling back to the heuristic. AOT skips the same row silently. No shipped row has such a name. But a warning on both sides, plus a heuristic fallback at runtime, would make a bad hand-edited row visible without breaking the shape.

where one of its kids runs the shape (N a multiple of 16, K of 128, bf16
or fp32 out), else flydsl (bf16 out).
* gfx950, 32x32 or 128x128: the tuned row's libtype, opus or flydsl,
whichever was faster at that shape; flydsl's heuristic off the table.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On gfx950 a non-bf16 output now goes to OPUS here, even over a tuned FlyDSL row, and raises NotImplementedError when no OPUS kid runs the shape; only the _impl docstring says so.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The public docstring now has a gfx950 "any block" bullet: flydsl writes bf16 only, so another output runs OPUS (bf16 or fp32), even over a tuned flydsl row, and raises NotImplementedError where no OPUS kid runs the shape.

have shape `[b,n/32,k/32]`. Per-row weight quantization (`1x32`) uses
weight scales `[b,n,k/32]` and activation scales `[m,b,k/32]`. It is supported
by OPUS kids 9700--9710 and 9713; the joint tuner skips FlyDSL candidates for this block.
by OPUS kids 9700--9710 and 9713, and by FlyDSL.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 62 below still says 1x32 needs K a multiple of 128, which is OPUS's limit; FlyDSL runs K = 576 (asserted in the group32 test).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. For 1x32 it now says K a multiple of 64: OPUS needs 128, and FlyDSL also runs K = 64 mod 128 (e.g. 576).

Comment thread aiter/ops/gemm_op_a8w8.py
f"{path}: {int(repeated.sum())} rows repeat a tuned shape; "
f"using the first row of each."
)
df = df[~repeated]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeps the first row, whose position depends on the unsorted model_configs glob. Sorting by us first would keep the faster one, as the merge does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The loader sorts by us before dropping repeated keys, so the fastest row wins, as in the merge. The blank + 128x128 test now gives the later row the lower us and checks that it's the one used.

cfg["xcd_order"] = xcd_order is not None
cfg["xcd_swizzle"] = int(xcd_swizzle or 0)
cfg["scale_preload"] = per_stage is None
if not xcd_swizzle_runs(cfg["xcd_swizzle"], cfg["xcd_order"], cfg["splits"]):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tuned row named e.g. ..._sk2_..._xcd4 then makes _require_config raise at runtime, while AOT skips it silently. A warning on both sides and a heuristic fallback at runtime would surface it without breaking the shape.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Raising at runtime and skipping silently in AOT was already upstream's behaviour for any kernelName that doesn't parse; this PR only made more names unparseable (_xcd1, _sk<n>_xcd<g>). Now, for such a name, the gfx950 runner warns once and runs the heuristic's pick, and AOT prints Unknown FlyDSL BMM kernel name: ..., skipping. test_bmm_unrecognised_tuned_name_warns_and_runs_heuristic covers both.

- Document in the public batched entry that gfx950 non-bf16 output runs
  OPUS for every w_scale block, even over a tuned flydsl row.
- README: 1x32 K is a multiple of 64 (FlyDSL runs K = 64 mod 128).
- The mxscale loader keeps the fastest of repeated rows, as the merge does.
- A gfx950 bmm kernelName that does not parse warns and runs the
  heuristic's pick at runtime; AOT warns instead of skipping silently.
@sshlyapn

Copy link
Copy Markdown
Contributor Author

Thanks @valarLip! All four points are addressed

valarLip
valarLip previously approved these changes Oct 27, 2026
Conflicts:
- aiter/ops/batched_gemm_op_a8w8.py: take upstream's scoped
  (gfx, cu_num) lookup from _device_arch_and_cu; keep our routing
  (untuned 1x32 tries an OPUS kid and falls back to FlyDSL when none
  runs the shape; non-bf16 tuned flydsl rows go to OPUS or raise).
- csrc/opus_gemm/opus_bmm_mxscale_tune.py: keep upstream's local
  BMM_BLOCK_DATA_KIDS (1x32 -> 235); BMM_DATA_KIDS stays removed.

op_tests/test_gemm_group32_interface.py: also patch
_arch._device_arch_and_cu in the two CPU-tensor routing tests, since the
impl now resolves the arch scope from the input device.
@valarLip
valarLip merged commit 66c8630 into ROCm:main Oct 27, 2026
67 of 91 checks passed
zhiding512 added a commit that referenced this pull request Oct 28, 2026
#6362, which this branch was stacked on, landed squashed as fc0a013.
Every file except the 12 of the replay commit is therefore taken as main
has it, which also leaves the PR's diff against main at those 12.

Conflicts:

- aiter/aot/flydsl/gemm.py: #6060 taught the hand-written AOT the gfx950
  1x32 BMM (mxscale_bmm_groups_of_block) and to read a blank or 0
  w_scale_block cell as the runtime's loaders do
  (mxscale_w_scale_block_cell). The replay calls the public entries, which
  take the scale block from the caller's w_scale, so none of that code
  returns. The cell reading does: _blocks() reads a cell through
  mxscale_w_scale_block_cell, 1x32 for the mxfp8 table and 128x128 for the
  others, as their loaders default. A 0 cell made it raise before.

Main also brought #6060's BMM changes and #6946's launcher cache, which
this branch had not been validated against. Ten rows from the tables they
touch (gfx950 1x32, 32x32 and 128x128 through the 2D and batched entries,
gfx950 mxfp8, gfx1250 batched and a8w8 bpreshuffle) replay into a cache
that --check accepts, and on gfx950 the real calls of those rows and of
the sizes between them (9 calls) all run from it under
FLYDSL_RUNTIME_RUN_ONLY=1.

Co-authored-by: Cursor <[email protected]>
zhuyuhua-v added a commit to ROCm/ATOM that referenced this pull request Nov 1, 2026
…shuffled GEMM (opt-in)

ATOM_MXFP8_1X32_PRESHUFFLE=1 (default 0) holds native FP8 weights with 1x32
E8M0 scales (16, 16)-preshuffled on gfx950, so native_quant_linear's existing
AITER call (gemm_a8w8_blockscale, isBpreshuffled=True) runs them on FlyDSL's
MXFP8 bmm / mxpsh kernels, picked by AITER's mxscale bpreshuffle tuned table,
instead of the Triton group32 GEMM. Weight bytes and scales stay the
checkpoint's, so the output is bit-identical. The target is the MiniMax-M3.1
DSpark draft, whose MXFP8 linears may not be re-quantized; AITER already
ships MiniMax-M3 1x32 rows for its shapes (ROCm/aiter#6060).

weight_is_stored_preshuffled answers for both the load and the weight sync.
Tests: truth table, dispatch, and a gfx950 bit-exact comparison against the
row-major path.
zhuyuhua-v added a commit to ROCm/ATOM that referenced this pull request Nov 2, 2026
…ITER's group32 GEMM

Native FP8 weights with 1x32 E8M0 scales (MXFP8; e.g. the MiniMax-M3.1
DSpark draft, whose linears are kept as shipped) are now (16, 16)-preshuffled
on gfx950, like the 32x32 group32 weights already are, under the same
ATOM_GROUP32_WEIGHT_PRESHUFFLE switch. native_quant_linear's existing AITER
call then runs them on FlyDSL's MXFP8 bmm / mxpsh kernels instead of the
Triton group32 GEMM. Weight bytes and scales stay the checkpoint's, so the
output is bit-identical. AITER ships MiniMax-M3 1x32 rows for these shapes
(ROCm/aiter#6060). gfx1250 keeps 1x32 weights row-major.

Tests: truth table, dispatch, and a gfx950 bit-exact comparison against the
row-major path.
zhiding512 added a commit that referenced this pull request Nov 3, 2026
#6362, which this branch was stacked on, landed squashed as fc0a013.
Every file except the 12 of the replay commit is therefore taken as main
has it, which also leaves the PR's diff against main at those 12.

Conflicts:

- aiter/aot/flydsl/gemm.py: #6060 taught the hand-written AOT the gfx950
  1x32 BMM (mxscale_bmm_groups_of_block) and to read a blank or 0
  w_scale_block cell as the runtime's loaders do
  (mxscale_w_scale_block_cell). The replay calls the public entries, which
  take the scale block from the caller's w_scale, so none of that code
  returns. The cell reading does: _blocks() reads a cell through
  mxscale_w_scale_block_cell, 1x32 for the mxfp8 table and 128x128 for the
  others, as their loaders default. A 0 cell made it raise before.

Main also brought #6060's BMM changes and #6946's launcher cache, which
this branch had not been validated against. Ten rows from the tables they
touch (gfx950 1x32, 32x32 and 128x128 through the 2D and batched entries,
gfx950 mxfp8, gfx1250 batched and a8w8 bpreshuffle) replay into a cache
that --check accepts, and on gfx950 the real calls of those rows and of
the sizes between them (9 calls) all run from it under
FLYDSL_RUNTIME_RUN_ONLY=1.

Co-authored-by: Cursor <[email protected]>
zhuyuhua-v added a commit to ROCm/ATOM that referenced this pull request Nov 4, 2026
…ITER's group32 GEMM

Native FP8 weights with 1x32 E8M0 scales (MXFP8; e.g. the MiniMax-M3.1
DSpark draft, whose linears are kept as shipped) are now (16, 16)-preshuffled
on gfx950, like the 32x32 group32 weights already are, under the same
ATOM_GROUP32_WEIGHT_PRESHUFFLE switch. native_quant_linear's existing AITER
call then runs them on FlyDSL's MXFP8 bmm / mxpsh kernels instead of the
Triton group32 GEMM. Weight bytes and scales stay the checkpoint's, so the
output is bit-identical. AITER ships MiniMax-M3 1x32 rows for these shapes
(ROCm/aiter#6060). gfx1250 keeps 1x32 weights row-major.

Tests: truth table, dispatch, and a gfx950 bit-exact comparison against the
row-major path.
zhuyuhua-v added a commit to ROCm/ATOM that referenced this pull request Nov 4, 2026
…ffled GEMM

The MiniMax-M3.1 DSpark draft keeps its linears as shipped: MXFP8, FP8 E4M3
with a 1x32 E8M0 scale, read as native group32 weights. Row-major, they ran
on the Triton group32 GEMM (gemm_afp8wfp8, default config).

The draft now asks for its qkv / o / gate_up / down weights to be
(16, 16)-preshuffled (needs_preshuffled_weight), and weight_is_stored_preshuffled
honours that for a 1x32 weight on gfx950 under ATOM_GROUP32_WEIGHT_PRESHUFFLE.
native_quant_linear's existing AITER call then runs them on FlyDSL's MXFP8
bmm, whose MiniMax-M3 1x32 tuned rows (ROCm/aiter#6060) cover these shapes.
Only the layout changes: the output is bit-identical. Every other 1x32
weight, and every other arch, stays row-major.

Tests: the 1x32 truth table, load-vs-sync parity on the native group32
branch, and a gfx950 bit-exact check at the draft's TP4 shapes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Centralized MXFP8 (E4M3 + E8M0 1x32) dense GEMM support

4 participants