feat(gemm_a8w8_blockscale_bpreshuffle): route decode-M DeepSeek shapes to triton#4202
Merged
Merged
Conversation
…s to triton
Add a `libtype == "triton"` dispatch branch to gemm_a8w8_blockscale_bpreshuffle
so the tuned CSV can route a shape/M to the triton preshuffle kernel. The branch
is handled before the Y output buffer is allocated (triton allocates its own
output), and the backend hint from kernelName is guarded to {triton,gluon}
(anything else -> auto-detect) so a stray kernelName can't crash the kernel.
Install per-shape tuned triton configs (gfx950) for the DeepSeek FP8 blockscale
attention projections and route only the M segments where triton is measurably
faster AND not less accurate than the current asm/ck kernels (steady-state
run_perftest, >=3% margin, err not worse):
wqkv_a N=2048 K=7168 : M=1,2,8,16,32,80 (KSPLIT=4, deep-K split)
wq_b N=65536 K=1536 : M=1,2,4,8 (tp1)
wq_b N=16384 K=1536 : M=1,4,8,16 ~1.4x (tp4, was untuned ck)
wq_b N=8192 K=1536 : M=2,80,96,112,144 (tp8; M=2 1.74x, was asm+memset)
Large-M / compute-bound and the remaining tp8 M stay on asm/ck (triton loses).
N=8192 rows live in the shared dsv3 file (V3/V4 same shape), so V3 benefits too.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
4 tasks
valarLip
added a commit
that referenced
this pull request
Jul 16, 2026
…ing for DeepSeek MLA decode-M (#4264) Re-measure a8w8 blockscale B-preshuffle triton routing cache-rotated (the #4202 tuning used a no-arg lambda that defeated perftest arg-rotation -> hot-cache optimistic + suboptimal configs), and validate end-to-end via the op-test. - op-test: add run_triton + triton columns; drop -m choices allowlist; fail-loud - wqkv_a (N=2048,K=7168): fix #4202 hot-cache regression (BM4/8,KSPLIT4 -> BM16, KSPLIT8,stages3); route M in {1,2,4,8,16,32,48,64,80,128}, all err=0 - wo_b (N=7168): new routing tp1 K=16384 M<=64, tp4 K=4096 M<=32 (+new JSON); tp8 K=2048 unchanged (triton loses on shallow K) - tuned CSVs: unify bw column to TB/s (asm/ck/cktile rows were GB/s) - wq_b unchanged: #4202 routing verified correct cold-cache
Contributor
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.
Summary
Add a
libtype == "triton"dispatch branch togemm_a8w8_blockscale_bpreshuffleso the tuned CSV can route a given
(M, N, K)to the triton preshuffle kernel,and route the decode-M DeepSeek FP8 blockscale attention projections to triton
where it is measurably faster and not less accurate than the current asm/ck
kernels on gfx950 (MI35x).
What changed
Dispatch (
aiter/ops/gemm_op_a8w8.py): newlibtype == "triton"case.Youtput buffer is allocated (triton allocates its ownoutput) — no wasted
m×nalloc on the triton path.backendis taken from the CSVkernelNameonly when it istriton/gluon;anything else falls back to auto-detect instead of tripping triton's internal
assert backend in ('triton','gluon').Tuned configs (
aiter/ops/triton/configs/gemm/*.json): per-shape gfx950triton configs for N=2048/16384/65536/8192, K∈{7168,1536}. The pre-existing
N=2048 file is merged (kept its
M_LEQ_256/anylarge-M buckets).Routing CSVs:
libtype=tritononly on the M segments that win:Large-M / compute-bound and the remaining tp8 M stay on asm/ck. The N=8192 rows
live in the shared dsv3 file (V3/V4 same shape), so V3 benefits too.
How the M segments were chosen
Every M row of these shapes in the CSVs was measured with aiter's
run_perftest(same process, asm/ck vs triton) against a torch fp32 reference. A row is routed
to triton only if triton is valid (
err < 0.05), ≥3% faster in steady state,and not less accurate than asm/ck. No row was faster-but-less-accurate — in
the flipped rows triton's
erris 0 while asm/ck carry fp8 rounding (~0.003–0.01).Verification
(largest: 16384 ~1.4×, 8192 M=2 1.74×).
op_tests/test_gemm_a8w8_blockscale.pyre-run on the V4 shapes: unified APIroutes to triton for the flipped M, all
err == 0, and beats raw asm on everymeasured point.
Test plan
python op_tests/test_gemm_a8w8_blockscale.py -nk 2048,7168 8192,1536 16384,1536 65536,1536 -m 1 2 4 8 16 32 96 128 --ck_preshuffle 1AITER_LOG_TUNED_CONFIG=1.🤖 Generated with Claude Code