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
[FlyDSL] [Perf] gfx950: 4-wave MXFP8 backend and MiniMax-M3.1 o_proj_full rows (stacked on #8582, #8578) - #8584
Stacked on #8582 (the persistent 4-wave MXFP8 kernel) and #8578 (o_proj_full 8-wave rows): the first commits of this branch are those PRs, review the top commit only; the diff shrinks as they land.
Makes the 4-wave kernel reachable through gemm_a8w8_blockscale(..., isBpreshuffled=True) / gemm_a8w8_mxfp8_bpreshuffle and puts it in the MiniMax-M3.1 TP4 o_proj_full (N6144 x K8192) rows, so the aiter-only path matches amd-kernels' ak_gemm for the sequence-parallel prefill.
aiter/ops/flydsl/gemm_a8w8_mxfp8_4wave.py (new): backend with the 8-wave module's shape: kernelName flydsl_mxfp8_4w_256x256x128_F8_F8_B16_xcd{0|1}[_nt] (make / parse), flydsl_mxfp8_4wave_gemm (raw row-major e8m0 scales in), launch_mxfp8_4wave_shuffled (for a producer that emits the kernel's scale layout), run_gemm_a8w8_mxfp8_4wave (the kernelName entry).
Scales: the kernel wants both scales in shuffle_scale_a16w4 order. A's is shuffled per call by one small Triton kernel (the torch 7-D permute copy costs 5-13 us at M 1024-16384, this 2.5-10 us, bit-identical, rows padded to 32 with 127 in the same pass); W's once per weight-scale tensor (cache keyed by device / pointer / shape / strides / _version, the entry holds the tensor so its storage cannot be freed and reused under the key, 512 entries). A caller that already has shuffled A scales (a quantizer emitting them) calls launch_mxfp8_4wave_shuffled and skips the 3-6 us; amd-kernels' numbers below do that.
Launch plan (same as amd-kernels' _fourwave_plan, generalized to get_cu_num()): one persistent round of 256x256 tiles; a remainder of R <= cus/2 parent tiles runs as one round of 128x128 (R <= cus/4) or 128x256 sub-tiles.
mxscale_preshuffle_kernels.run_gemm_a8w8_mxfp8_gfx950: routes the flydsl_mxfp8_4w_ prefix; a non-bf16 Out or a non-1x32 w_scale falls back to the mxpsh heuristic tile, as the 8-wave prefix does.
Tuner: a 4wave pipeline (4 candidates: xcd remap x non-temporal stores) in the 1x32 pipeline list, ids from 2_000_000; fits = N % 256 == 0, K % 256 == 0, K >= 512, 32-bit extents.
minimax_m3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv: N6144 K8192 rows at M = 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 8192, 12288, 16384, 24576, 32768, 49152, 65536 -> 4-wave (the rows at 2048, 4096 and at M >= 8192 replace bmm / 8-wave rows; M <= 1024 rows unchanged). us is the measured public-path time.
Results (MI355X, gfx950; public path gemm_a8w8_blockscale(isBpreshuffled=True), graph of 8 cold weight copies, median us/call, A scale shuffle included)
Between the table's rows (M = 1088 ... 3840, 4608) the new path is 0-48% faster than before (e.g. 2304: 176.7 -> 93.1, 2816: 180.7 -> 125.8) and never slower; against amd-kernels it is within +0-9% for M 2048-16384 (the gap is the per-call A-scale shuffle, 3-6 us) and 21-26% faster above 16384 (amd-kernels' own table picks a slower row there). Output is bit-identical to amd-kernels' at every M >= 1280 above (pub_eq_ak); M = 1024 is a different kernel on both sides (unchanged rows, not bit-identical to ak's split kernel, as before).
Correctness
op_tests/test_mxfp8_gemm_4wave_dispatch.py (28 tests, all pass) plus #8582's 20: kernelName round trip, the launch plan (no remainder / 128x128 / 128x256 remainder, with and without XCD dealing), the Triton scale shuffle == shuffle_scale_a16w4 over padded rows (M 1 ... 8192, K 512 / 8192), run_gemm_a8w8_mxfp8_gfx950 with the 4-wave name bit-identical to the 8-wave kernel at (300, 512, 1024), (3072 / 4096 / 4100, 6144, 8192) (the three remainder-round plans) and (5120, 2560, 6144), both store modes, and the W-scale cache following an in-place scale update (version bump). The tuner's pipelines list the 4-wave candidates for (4096, 6144, 8192) and refuse N = 6000 / K = 256.
Notes for review
No AOT registration (aot_factory) for the 4-wave launcher yet: first use JIT-compiles it (a few seconds, cached in the FlyDSL cache). Follow-up.
A caller must have called the op once with a given w_scale tensor before CUDA-graph capture (the first call shuffles it; later calls hit the cache). ATOM's warm-up already runs each linear before capture; a producer that holds pre-shuffled scales can use launch_mxfp8_4wave_shuffled and has no cache.
Rows only for the o_proj_full shape: 6144x2048 / 6144x3072 / 6144x6144 / 2560x6144 also gain 5-12% at M >= 6144 in the same sweep, but their margin over the current rows is within the run-to-run noise at M < 6144, so they are left to the tuner (gemm_a8w8_mxfp8_bpreshuffle_tune.py now enumerates the 4-wave kernels).
The DBO plain-grid switch of amd-kernels (_PLAIN_GRID_MAX while two microbatches share the GPU) is not ported: grid_max is a parameter of the kernel, the policy belongs to the engine.
Review
Run by hand through the repo's review-pr triage (rules A1 A3 A4 B1 B3 B4 B6 B7 C4 C5 D1 D3 D8 D10 D12 D13 D14 E2 P1-P3 P5 P6): siblings / guards / aot-pairing / symbols / ci-coverage / flydsl-bounds checks clean. B4 (new dispatch value): the prefix is handled in run_gemm_a8w8_mxfp8_gfx950 with a documented fallback for non-bf16 out / non-1x32 scales, and the backend raises on a shape it cannot run instead of falling through; D13: the compiled-handle cache keys K, xcd, nt, tiles and grid size, and every launch passes the device as the specialization key; D14: operands are checked for device, contiguity, shape, dtype width and 32-bit extents before the raw-pointer launch, under torch.cuda.device; D3: no hipblaslt rows; D12: AOT not added (stated above); P6: base vs head measured back to back (tables above). Findings fixed before opening: a bf16-only / 1x32-only fallback for the 4-wave prefix (first version raised for an fp16 out), device check, rows restricted to the verified shape.
…ave picks at M >= 8192 on gfx950
Replace the 7 FlyDSL bmm rows of the 6144x8192 1x32 shape at M = 8192 ... 65536
in model_configs/minimax_m3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv
with FlyDSL 8-wave MXFP8 (256x256x128) picks. Config only, no code change;
output is bit-identical to the previous kernels.
Co-Authored-By: Claude <[email protected]>
…shuffle and MiniMax-M3.1 o_proj_full rows
The dispatcher half of the persistent 4-wave MXFP8 kernel: a gemm_a8w8_mxfp8_4wave backend
(kernelName flydsl_mxfp8_4w_..., raw scales in, shuffled in the backend), the tuner pipeline,
and N6144 x K8192 rows from M 1536 to 65536.
Co-Authored-By: Claude <[email protected]>
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 8584 --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.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical issues can crash valid inference calls, expose unfinished cached scales across streams, and corrupt output when unsupported shapes reach an unguarded kernel.
Connects the persistent 4-wave MXFP8 kernel from #8582 to AITER’s gfx950 GEMM dispatch and tuning, targeting faster MiniMax-M3.1 sequence-parallel prefill.
Changes:
Adds a backend wrapper with scale shuffling, weight-scale caching, and remainder-tile launch planning.
Registers four tuning candidates and selects 4-wave kernels for 15 N6144 × K8192 configuration rows.
Adds dispatch, scale-layout, cache-update, and numerical correctness tests.
File
Description
op_tests/test_mxfp8_gemm_4wave.py
Stacked kernel tests for tile variants, scheduling, and numerical accuracy.
op_tests/test_mxfp8_gemm_4wave_dispatch.py
Tests backend naming, launch plans, scale shuffling, dispatch, and caching.
aiter/ops/flydsl/mxscale_preshuffle_kernels.py
Routes 4-wave names and falls back for unsupported output or scale formats.
aiter/ops/flydsl/kernels/mxfp8_gemm_4wave.py
Stacked persistent 4-wave gfx950 kernel from #8582.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical cache invalidation and cross-stream synchronization gaps can cause GEMMs to consume stale or unfinished scales, while missing launcher shape checks permit output-corrupting writes.
When a tuned row selects 4-wave, a caller-owned BF16 output such as backing[:, :6144] now raises because the runner requires contiguous Out. The public bpreshuffle API accepts this layout, and the previous 8-wave path supports it (gemm_a8w8_mxfp8_8wave.py:199-207,306-307). Preserve that support by using a contiguous temporary and copying back for strided outputs.
GPU tests use incorrect availability and architecture gates
op_tests/test_mxfp8_gemm_4wave_dispatch.py:54
The scale-shuffle tests allocate CUDA tensors without an availability guard, while the dispatch/cache tests use build-time get_gfx() and can skip supported gfx950 hardware when GPU_ARCHS='gfx950;gfx942'. Gate GPU cases with CUDA availability and get_gfx_runtime() for both script execution and pytest collection, while leaving the host-only name/plan tests runnable. Apply the runtime gate to all three dispatch/cache tests below.
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.
Summary
Stacked on #8582 (the persistent 4-wave MXFP8 kernel) and #8578 (o_proj_full 8-wave rows): the first commits of this branch are those PRs, review the top commit only; the diff shrinks as they land.
Makes the 4-wave kernel reachable through
gemm_a8w8_blockscale(..., isBpreshuffled=True)/gemm_a8w8_mxfp8_bpreshuffleand puts it in the MiniMax-M3.1 TP4 o_proj_full (N6144 x K8192) rows, so the aiter-only path matches amd-kernels'ak_gemmfor the sequence-parallel prefill.aiter/ops/flydsl/gemm_a8w8_mxfp8_4wave.py(new): backend with the 8-wave module's shape: kernelNameflydsl_mxfp8_4w_256x256x128_F8_F8_B16_xcd{0|1}[_nt](make / parse),flydsl_mxfp8_4wave_gemm(raw row-major e8m0 scales in),launch_mxfp8_4wave_shuffled(for a producer that emits the kernel's scale layout),run_gemm_a8w8_mxfp8_4wave(the kernelName entry).shuffle_scale_a16w4order. A's is shuffled per call by one small Triton kernel (the torch 7-D permute copy costs 5-13 us at M 1024-16384, this 2.5-10 us, bit-identical, rows padded to 32 with 127 in the same pass); W's once per weight-scale tensor (cache keyed by device / pointer / shape / strides /_version, the entry holds the tensor so its storage cannot be freed and reused under the key, 512 entries). A caller that already has shuffled A scales (a quantizer emitting them) callslaunch_mxfp8_4wave_shuffledand skips the 3-6 us; amd-kernels' numbers below do that._fourwave_plan, generalized toget_cu_num()): one persistent round of 256x256 tiles; a remainder of R <= cus/2 parent tiles runs as one round of 128x128 (R <= cus/4) or 128x256 sub-tiles.mxscale_preshuffle_kernels.run_gemm_a8w8_mxfp8_gfx950: routes theflydsl_mxfp8_4w_prefix; a non-bf16Outor a non-1x32 w_scale falls back to the mxpsh heuristic tile, as the 8-wave prefix does.4wavepipeline (4 candidates: xcd remap x non-temporal stores) in the 1x32 pipeline list, ids from 2_000_000; fits = N % 256 == 0, K % 256 == 0, K >= 512, 32-bit extents.minimax_m3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv: N6144 K8192 rows at M = 1536, 2048, 2560, 3072, 3584, 4096, 5120, 6144, 8192, 12288, 16384, 24576, 32768, 49152, 65536 -> 4-wave (the rows at 2048, 4096 and at M >= 8192 replace bmm / 8-wave rows; M <= 1024 rows unchanged).usis the measured public-path time.Results (MI355X, gfx950; public path
gemm_a8w8_blockscale(isBpreshuffled=True), graph of 8 cold weight copies, median us/call, A scale shuffle included)Between the table's rows (M = 1088 ... 3840, 4608) the new path is 0-48% faster than before (e.g. 2304: 176.7 -> 93.1, 2816: 180.7 -> 125.8) and never slower; against amd-kernels it is within +0-9% for M 2048-16384 (the gap is the per-call A-scale shuffle, 3-6 us) and 21-26% faster above 16384 (amd-kernels' own table picks a slower row there). Output is bit-identical to amd-kernels' at every M >= 1280 above (
pub_eq_ak); M = 1024 is a different kernel on both sides (unchanged rows, not bit-identical to ak's split kernel, as before).Correctness
op_tests/test_mxfp8_gemm_4wave_dispatch.py(28 tests, all pass) plus #8582's 20: kernelName round trip, the launch plan (no remainder / 128x128 / 128x256 remainder, with and without XCD dealing), the Triton scale shuffle ==shuffle_scale_a16w4over padded rows (M 1 ... 8192, K 512 / 8192),run_gemm_a8w8_mxfp8_gfx950with the 4-wave name bit-identical to the 8-wave kernel at (300, 512, 1024), (3072 / 4096 / 4100, 6144, 8192) (the three remainder-round plans) and (5120, 2560, 6144), both store modes, and the W-scale cache following an in-place scale update (version bump). The tuner's pipelines list the 4-wave candidates for (4096, 6144, 8192) and refuse N = 6000 / K = 256.Notes for review
aot_factory) for the 4-wave launcher yet: first use JIT-compiles it (a few seconds, cached in the FlyDSL cache). Follow-up.launch_mxfp8_4wave_shuffledand has no cache.gemm_a8w8_mxfp8_bpreshuffle_tune.pynow enumerates the 4-wave kernels)._PLAIN_GRID_MAXwhile two microbatches share the GPU) is not ported:grid_maxis a parameter of the kernel, the policy belongs to the engine.Review
Run by hand through the repo's
review-prtriage (rules A1 A3 A4 B1 B3 B4 B6 B7 C4 C5 D1 D3 D8 D10 D12 D13 D14 E2 P1-P3 P5 P6): siblings / guards / aot-pairing / symbols / ci-coverage / flydsl-bounds checks clean. B4 (new dispatch value): the prefix is handled inrun_gemm_a8w8_mxfp8_gfx950with a documented fallback for non-bf16 out / non-1x32 scales, and the backend raises on a shape it cannot run instead of falling through; D13: the compiled-handle cache keys K, xcd, nt, tiles and grid size, and every launch passes the device as the specialization key; D14: operands are checked for device, contiguity, shape, dtype width and 32-bit extents before the raw-pointer launch, undertorch.cuda.device; D3: no hipblaslt rows; D12: AOT not added (stated above); P6: base vs head measured back to back (tables above). Findings fixed before opening: a bf16-only / 1x32-only fallback for the 4-wave prefix (first version raised for an fp16 out), device check, rows restricted to the verified shape.Technique credit: amd-kernels
gemm/mxfp8_common/gemm.py(_fourwave_plan, scale preparation).🤖 Generated with Claude Code