Repository navigation
[Triton/Gluon] [Config] a4w4: dispatch triton_preshuffle tuned rows, tune Qwen3.8-27B decode GEMMs on gfx950 - #7117
Draft
vorapolsiloai wants to merge 5 commits into
Conversation
This was referenced Nov 2, 2026
This was referenced Nov 2, 2026
Closed
4 tasks done
15 tuned rows for M in 32..128 that run the Triton split-K GEMM: (5120,3072) M32/64, (5120,6144) M32/48/64, (5120,8704) M32, (5120,17408) M32..128 step 16, (7168,5120) M32, (8192,5120) M32. They replace the asm rows at the same keys. M=17..31 pads onto the M=32 row, which is now a Triton row the route does not take below M=32, so the 90 exact rows for M=17..31 of these six shapes carry the asm kernel that was tuned at M=32 (same kernelName, splitK, us). tflops/bw of the 105 rows are recomputed from us with the tuner's formula.
…56 CUs) 41 tuned rows: - flydsl_ decode rows for M 1/2/4/8/16 at (N,K) (5120,6144), (5120,17408), (14336,5120), (34816,5120) and (16384,5120) M16, replacing asm rows (CK rows at N=34816), plus new keys (16384,5120) M1/2/4/8; - shapes of the packed linear-attention in_proj (in_proj_qkvz and in_proj_ba as one GEMM): (8448,5120) and (16640,5120), flydsl_ for M 1..16 and asm for M 32/48/64. Those N only occur when the serving framework packs the two projections. The flydsl_ rows added by the FlyDSL decode change are kept as they are.
The packed linear-attention in_proj shapes, (8448, 5120) at TP2 and (16640, 5120) at TP1, had tuned rows only up to M = 64. CUDA-graph decode runs the packed GEMM up to M = 256, so larger batches fell back to the default asm heuristic. 48 rows at M = 72..256, step 8 (every captured graph batch size), all asm f4gemm: - (8448, 5120): 32x128, 96x128 and 64x128 tiles; - (16640, 5120): 96x128, 128x128, 160x128, 64x256 and 96x256 tiles. Each row is the fastest candidate whose output is identical to the current dispatch, out of 40 preshuffled asm tile/splitK combinations and 240 Triton preshuffle configs, timed on MI350X as HIP-graph-captured back-to-back calls over weight copies rotated through >= 640 MB. Against the default heuristic: (8448, 5120) 16.6-20.5 us -> 11.2-16.1 us, (16640, 5120) 19.9-47.2 us -> 16.5-24.5 us. (32, 5120, 8704), the TP2 down_proj at M = 32, goes back to the asm row it had before the Triton rows commit, so this series leaves that pick unchanged. In the same MI350X sweep the Triton config there takes 16.13 us against 17.11 us for the asm tile; it can come back once a TP2 serving run shows the gain.
Covers the 14 triton_preshuffle rows of qwen38_27b_a4w4_blockscale_tuned_gemm.csv, an odd M that pads onto one of them (33 -> 48), and M = 17..31 shapes that must stay on asm.
…6 CUs) The packed GDN in_proj GEMM (N = 16384 + 256 padded in_proj_ba rows = 16640, K = 5120) had rows only up to M = 256, so at prefill sizes gemm_a4w4 fell back to its default kernel: 1596 us at M = 16384 on MI355X vs 646 us for the 256x256 tile, 726 vs 318 us at M = 8192. Each new row sits at a getPaddedM gl=1 bucket and serves every M in it, so it holds the tile that is best across the bucket, from cold-weight timings of every BpreShuffle tile at 21 batch sizes from 272 to 16384: 160x384 for 512 ... 4096 (one wave up to M = 800, within 1.3% of the best at 2048 and 4096), 256x256 for 8192 and 16384 (also reached by every M above 8192).
vorapolsiloai
force-pushed
the
perf/qwen35-a4w4-decode-gemm-rows
branch
from
November 24, 2026 08:37
b81750d to
37a6260
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #6419 (closed).
Summary
gemm_a4w4dispatches tunedtriton_preshuffle_*rows to the Triton split-K GEMM, and the Qwen3.8-27B MXFP4 table gains decode rows (914 to 1072) including packedin_projrows for M 72..256.MI355X, Qwen3.8-27B MXFP4 TP1, SGLang, 8k/1k, vs #6218 alone: c16 median TPOT -15.0%, output tok/s +15.3%; c64 -1.7% / +0.8%; c256 -2.1% / +1.4%. Not claimed: the packed
in_projrows only apply when the framework packs the two projections; bandwidth and roofline are not measured.Full description and stack note
Supersedes #6419: the same routing change and Qwen3.8-27B rows, rebased onto #6218, plus 48 packed
in_projrows for M 72..256. #6419 can be closed once this is reviewed.Stacked on #6218 (FlyDSL A4W4 decode GEMM). The base branch is #6218's branch, so the diff shows only this PR's 5 commits (
bd0c36d3..1e7a1038). Once #6218 merges, this PR retargets to main. Theact_mul_and_mxfp4_quantscaling_modefix that was in earlier revisions of this PR now lives in its own PR (#7116).Motivation
At M 32..128 the Triton split-K preshuffle GEMM beats every asm tile on several shapes, and the packed in_proj had no tuned rows (about 2x slower than the best tile at M = 256).
Details
Qwen3.8-27B MXFP4 decode on gfx950 (256 CUs) runs its GEMMs at M <= 256. The a4w4 path has two gaps there:
gemm_a4w4cannot use it, because it only dispatches asm, CK andflydsl_rows.Changes
Triton route in
gemm_a4w4(gfx950, M >= 32, K % 256 == 0, falls back to asm), CKgen_instances.pyskipstriton_rows, and rows added toqwen38_27b_a4w4_blockscale_tuned_gemm.csv(914 to 1072).Route restrictions, row list
gemm_a4w4dispatches rows namedtriton_preshuffle_bm{BM}_bn{BN}_bk{BK}_ks{KSPLIT}_w{WARPS}_wpe{WPE}togemm_afp4wfp4_preshuffle.flydsl_route does.gen_instances.pyskipstriton_rows, as it already does for_ZNandflydsl_rows, sobuild_tune_dictdoes not reject them.qwen38_27b_a4w4_blockscale_tuned_gemm.csv(gfx950, 256 CUs) goes from 914 to 1072 rows:triton_preshuffle_*rows at M 32..128 for (5120, 3072), (5120, 6144), (5120, 17408), (7168, 5120) and (8192, 5120).flydsl_decode rows for M <= 16 on (5120, 6144), (5120, 17408), (14336, 5120), (16384, 5120) and (34816, 5120). The rows added by [CK] [FlyDSL] FlyDSL A4W4 decode GEMM for M<=16 on gfx950 #6218 are unchanged.flydsl_rows for M <= 16, and asm rows for M 32..256 at every CUDA-graph batch size (step 8 above 64). Each asm row is the fastest candidate whose output is bit-identical to the current dispatch.gemm_a4w4_blockscale_tune.py, which has no Triton libtype. Re-running that tuner on these shapes would replace them.Performance (if applicable)
Kernel times, decode traces, end-to-end tables, setup
Kernel times on gfx950, measured as HIP-graph-captured back-to-back calls over rotated weight copies:
MI355X, Qwen3.8-27B MXFP4, TP1, 8k input / 1k output, from decode traces:
End-to-end decode, SGLang, Qwen3.8-27B MXFP4, TP1 on MI355X, 8k input / 1k output tokens. With vs without this PR (#6218 in both):
Without this PR, #6218 alone does not change these numbers (within 1%): its FlyDSL decode GEMM is selected for the Qwen3.8-27B shapes by the rows added here. The default merged table goes from 20 to 30 FlyDSL rows for the Qwen3.8-27B decode shapes at M ≤ 16, plus 14 Triton rows for M 32-128 and the packed in_proj rows for M 72-256.
Test configuration: MI355X (gfx950, 256 CUs), Qwen3.8-27B MXFP4, SGLang TP1 with
--attention-backend aiter, FP8 KV cache,--enable-amd-monokerneland chunked prefill 16384. "With vs without" is the full stack (SGLang and AITER with this PR and the PRs it builds on) vs the same build without this PR, on the same GPU, averaged over 2 GPUs. Decode is bench_serving random, 64 / 128 / 256 prompts at 16 / 64 / 256 concurrent requests. Repeat noise of the full stack on one GPU: TTFT 0.1-0.8%; TPOT 0.1-0.8%, except 2.4% at 16 concurrent requests on one GPU TPOT (2.4% at 16 requests on one GPU).The packed in_proj rows only take effect when the serving framework packs the two projections into one GEMM.
Testing
test_a4w4_triton_route.py+test_csv_validation.py: 22 passed on MI355X;test_decode_gemm_mxfp4.py: 32 passed.Test details
op_tests/tuning_tests/test_a4w4_triton_route.py(new, CPU only) checks three things:triton_name parses with the dispatcher's own regex;It passes, and so does
test_csv_validation.py. The merged default table has no duplicate keys.op_tests/test_gemm_a4w4.pygains the routed shapes, an odd M that pads onto a Triton row (33 -> 48), and M 17..31 shapes that must stay on asm.Results on MI355X:
op_tests/test_gemm_a4w4.pyon the 24 Qwen3.8-27B shapes this PR tunes (M 1-256; N 3,072-17,408, including the packed GDN input projection N 8,448 / 16,640): all passcheckAllclose(atol/rtol 0.01), error 0.op_tests/tuning_tests/test_a4w4_triton_route.py+test_csv_validation.py: 22 passed.op_tests/flydsl_tests/test_decode_gemm_mxfp4.py: 32 passed.Documentation
Dispatch route and tuned rows only.
Dependencies
Depends on #6218 (open), see the banner.
Breaking Changes
None.
PR Self-Review
Self-review
Not written yet for the current head; to be completed (reviewed revision, behavior and intent, validation and unverified scope, changed op tests) before this PR is marked ready for review.