Repository navigation
[CK] [FlyDSL] FlyDSL A4W4 decode GEMM for M<=16 on gfx950 - #6218
johannes-graner wants to merge 21 commits into
Conversation
A4W4 (MXFP4, per_1x32 e8m0) dense GEMM for M<=16 with optional stateless split-K reduce kernel. Valid (tile_n, k_waves) pairs are (32,2) and (64,1); requires N % tile_n == 0 and K % 64 == 0.
…e shapes Rows whose kernelName starts with flydsl_decode_ route to the FlyDSL kernel; unsupported shapes and unparsable names fall back to the asm heuristic. Adds 25 rows to the qwen38_27b model config.
… rows in CK gen_instances Split-K candidates are enumerated only with --splitK and encoded as log2(partitions), matching CK and asm.
Reuses OpKind.GEMM; expands every padded M served by a tuned row (80 jobs).
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
…mxfp4-SILOTIGER-1219 # Conflicts: # aiter/aot/flydsl/gemm.py
|
Thanks for the PR, nice speedup for decode! I checked it locally on gfx950: output is bit-identical to asm on all 80 shipped (N, K, M) cases including padded M, and split-K / K-tail edge cases also pass. Kernel logic looks good to me. Main point is the top-level flydsl import in |
Lazy-import flydsl decode helpers in gemm_a4w4 dispatch; fall back to asm on ImportError Add M between CSV rows decode test cases Dedupe tuner num_buffers candidates by effective depth Cache parse_flydsl_decode_name; use get_gfx_runtime for arch check Replace heavy LDS fallback test shape with (16,256,20480) Exclude flydsl_ kernel names from CK path in bench_gemm_mixed_mxfp
# Conflicts: # aiter/aot/flydsl/gemm.py
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
The wrapper accepts buffers beyond the kernel’s supported addressing range, allowing large inputs to pass validation even though trailing-column accesses cannot reach the intended weights.
5 open issues
Reject descriptors exceeding the kernel’s 2 GiB addressing limit · New Align scale-view extents with AOT specialization sizes · New Add coverage to the existing A4W4 GPU test entry point · New Use the shared GPU architecture selection for gfx950 gating · New Register the padded-M parity test in the GPU test shards · New
Review effort: Balanced
The direct gcnArchName probe duplicated device detection; get_gfx_runtime reads the actual device, unlike get_gfx which returns GPU_ARCHS when set.
Descriptors are fixed-base with 32-bit num_records and offsets, and the K-tail B sentinel offset can wrap near 2 GiB. Raising ValueError lets gemm_a4w4 fall back to asm.
…mxfp4-SILOTIGER-1219 # Conflicts: # aiter/aot/flydsl/gemm.py # csrc/ck_gemm_a4w4_blockscale/gemm_a4w4_blockscale_tune.py # csrc/ck_gemm_a4w4_blockscale/gen_instances.py # op_tests/op_benchmarks/hip/bench_gemm_mixed_mxfp.py
Enroll decode rows in the existing A4W4 table caller and prebuild only exact M values that runtime dispatch serves. Adapt parser tests to the replay job contract and cover both split-K launch identities.
| @@ -0,0 +1,45 @@ | |||
| # SPDX-License-Identifier: MIT | |||
There was a problem hiding this comment.
No need to add a separate test file.
There was a problem hiding this comment.
Done in 428f355: the parity check is now test_padded_m_parity in op_tests/test_gemm_host_dispatch_cache.py, which CI already discovers, and the separate file is removed.
| @@ -0,0 +1,91 @@ | |||
| # SPDX-License-Identifier: MIT | |||
There was a problem hiding this comment.
No need to add a separate test file.
There was a problem hiding this comment.
Done in 428f355: the decode AOT parse/replay tests moved into op_tests/test_gemm_group32_interface.py next to the existing aot.parse_csv tests, and aiter/aot/test/test_flydsl_gemm.py is removed.
…mxfp4-SILOTIGER-1219
Addresses review: no separate test files. Parity test moves to test_gemm_host_dispatch_cache.py and the AOT decode-job tests move to test_gemm_group32_interface.py, both already discovered by CI. The parity test's DECODE_MAX_M import was stale; bound M by 512 directly.
|
@solinzby1 The issues you raised are addressed. |


Motivation
Qwen3.8-27B MXFP4 decode on MI355X runs small-M dense GEMMs through the asm
f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128and_64x128kernels viagemm_a4w4. This adds a FlyDSL A4W4 (MXFP4, per_1x32 e8m0) decode GEMM that is 1.7-2.3x faster on the tuned shapes with N<=8192.Technical Details
kernels/decode_gemm_mxfp4.pyplus optional split-K reduce kernelkernels/decode_gemm_mxfp4_reduce.py, with wrapperaiter/ops/flydsl/decode_gemm_mxfp4.py. Targets M<=16 on gfx950.N % tile_n == 0,K % 64 == 0. Valid(tile_n, k_waves)pairs:(32, 2)and(64, 1).gemm_a4w4routeskernelNameprefixflydsl_decode_t16x{tile_n}x{256*k_waves}_kw{k_waves}_nb{num_buffers}_sk{split_k}to the kernel. Unsupported shapes and unparsable names fall back to the asm heuristic.model_configs/qwen38_27b_a4w4_blockscale_tuned_gemm.csv.gemm_a4w4_blockscale_tune.pygains--backends flydsl. Split-K candidates require--splitKandsplitKis stored as log2(partitions), as for CK and asm.gen_instances.pyexcludesflydsl_*rows.gemm_a4w4call through the existing A4W4 table. That keeps the runtime compile args and cache key. Only exact-M rows are enrolled, because main routes padded-M FlyDSL lookups to asm. The shipped CSVs give 25 decode jobs.run_perftestpath reads 2-19% higher on 20 of 25 shapes, most on short K=3072 kernels (+15-19%), because of launch overhead; graph replay reproduces the CSV values. At 3 points it picks a differentnum_buffers(7168x5120 M=16; 8192x5120 M=1 and M=16). Rows were kept because dispatch reads onlykernelName, the cold-ring method better represents decode with non-cache-resident weights, and the tuner still picks FlyDSL over asm at all ten checked points. A plain re-tune therefore yields slightly different rows.Design notes for reviewers:
s_waitcnt). Code comments state the constraint.Test Plan
op_tests/flydsl_tests/test_decode_gemm_mxfp4.py: 29 oracle-based tests; each also checks that the call reached the FlyDSL kernel, so a silent fallback to asm fails the test.op_tests/test_gemm_a4w4.py: now includes the 25 decode shapes.op_tests/test_gemm_group32_interface.py, the padded-M parity test inop_tests/test_gemm_host_dispatch_cache.py, and a runtime-replay AOT prebuild from the shipped CSV.run_perftest, 10 warmup, 101 iters).Test Result
test_gemm_a4w4.pyerr 0 on all 94 rows; AOT run of 3 decode shapes 3/3 success on gfx950.op_tests/test_gemm_a4w4.py -mnk 1,5120,3072 4,8192,5120 16,17408,5120withFLYDSL_RUNTIME_RUN_ONLY=1gave 3 disk-cache hits, error 0, at 3.0/3.7/9.4 us.test_gemm_a4w4.pyon gfx950 and gfx1250 (the test skips other archs).N=8192 K=5120 at M=1,2,4,8 has no asm row at the merge-base; asm there used the default heuristic.
Submission Checklist
flydsl-kernel-code-cleanup: the cleanup pass and two review rounds are addressed.PR Self-Review
Reviewed revision
428f355
Behavior and intent
Qwen3.8-27B MXFP4 decode on gfx950 previously ran small-M dense GEMMs through the asm
f4gemm_bf16_per1x32Fp4_BpreShuffle_32x128and_64x128kernels. This PR adds a FlyDSL A4W4 decode GEMM with optional split-K, dispatched fromgemm_a4w4byflydsl_decode_*kernelName rows. It ships 25 tuned rows for the Qwen3.8-27B shapes, adds tuner and AOT prebuild support, and keeps the asm path as the fallback for everything else.Validation and unverified scope
Validated on gfx950 on 2026-11-18 at head
428f355cca, withENABLE_CK=0 FLYDSL_RUNTIME_ENABLE_CACHE=0:python3 -m pytest op_tests/flydsl_tests/test_decode_gemm_mxfp4.py: 32 passed.python3 -m pytest op_tests/test_gemm_host_dispatch_cache.py: 34 passed (includestest_padded_m_parity).python3 -m pytest op_tests/test_gemm_group32_interface.py: 215 passed, 13 skipped (includes the decode AOT parse/replay tests).python3 op_tests/test_gemm_a4w4.py -mnk 8,5120,3072: err 0, 3.76 us, served by tuned rowflydsl_decode_t16x32x512_kw2_nb4_sk1.python3 -m pytest op_tests/test_config_shape_collision.py: 33 passed.a4c944f8af, the 94-rowtest_gemm_a4w4.pysweep gave err 0 with all 25 tuned shapes dispatched to FlyDSL; that sweep was not repeated at this head.Remaining limitations: gfx942 and other archs are not tested (the path falls back to asm), the CI wheel build result is pending, FlyDSL loses to asm on wide-N K=16384 shapes (no rows ship), and the eager-mode host overhead is not measured here, since decode runs under HIP graph.
PR-specific question
Question: which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
Dispatch requires a
kernelNamerow matchingflydsl_decode_t16x{tile_n}x{256*k_waves}_kw{k_waves}_nb{num_buffers}_sk{split_k}, so only the 25 shipped Qwen3.8-27B rows can select it. The branch also requires gfx950 (checked withget_gfx_runtime()), plain MXFP4 per_1x32 e8m0 arguments, and a kernel LDS footprint within the 163840 byte gfx950 limit. The kernel targets M<=16,N % tile_n == 0andK % 64 == 0, with valid(tile_n, k_waves)pairs(32, 2)and(64, 1). The name parser rejects a t-token that disagrees with kw and rejects the old name format. A parse failure, wrapperValueError, LDS overflow, non-gfx950 device, or missing FlyDSL import falls back to the asm heuristic, covered by the LDS-fallback case(16,256,20480)and the forced-import-failure run. Shapes with no row never reach the kernel.Changed op tests
op_tests/flydsl_tests/test_decode_gemm_mxfp4.py: new oracle test of the kernel (all shipped shapes, M between CSV rows, split-K, LDS fallback, parser). It also asserts that the FlyDSL kernel was actually called, so a silent asm fallback fails. No existing test covers this kernel.op_tests/test_gemm_a4w4.py: adds the 25 decode shapes to the existing a4w4 perf and correctness sweep, so CI exercises realgemm_a4w4dispatch of the tuned rows end to end, which the kernel-level test does not.op_tests/test_gemm_host_dispatch_cache.py: addstest_padded_m_parity[0/1], which checks that the pure-Pythonpadded_m_pymatches the compiledget_padded_m, protecting GPU-free AOT padding. No other test compares the two. It lives in this file because CI already discovers it.op_tests/test_gemm_group32_interface.py: adds five decode AOT parse/replay tests next to the existingaot.parse_csvtests, covering exact-M-only rows and the replayedgemm_a4w4call. No GPU-free test covered decode enrollment before this PR.