Repository navigation
Conversation
jin-amd
force-pushed
the
gfx942-sparse-mla
branch
from
September 16, 2026 08:47
7c1c89d to
62ea84a
Compare
sparse_mla_fwd was gated to gfx950. The Gluon kernel itself needs no change to run on gfx942 -- the gl.amd.cdna4 intrinsics it uses lower fine there -- so the gate was the only thing in the way, plus a tile size chosen against gfx950's LDS budget. gfx942 has 64 KB of LDS per workgroup against gfx950's 160 KB, so BLOCK_K=64 asks for 68608 B and fails to launch: OutOfResources: shared memory, Required: 68608, Hardware limit: 65536 BLOCK_K=32 is the largest tile that fits. num_warps is pinned at 4 rather than following block_k // 16, so the LDS cap does not halve it as a side effect rather than as a tuning decision; that is worth 1.19x -> 1.55x on the prefill shapes. dot_precision="fp8" is rejected on gfx942. It feeds the cache's own code points to the matrix core, which needs OCP e4m3 MFMA; CDNA3 has fp8 MFMA in the fnuz encoding only, so those code points come out wrong. It was silently wrong (rel-err 7.5e-1) rather than faulting, so this is now an explicit error naming the alternative. dot_precision="bf16" dequantizes the tile into LDS and works on every arch and every cache format, fp8 caches included. The bench's fp8-dot series is built from FP8_DOT_ARCHS for the same reason: with the arch gate widened it would otherwise reach that series on gfx942 and raise on its first point, and triton's perf_report does not catch it, so the run died before printing a table. The test's cache builders go back to an explicit OCP e4m3 rather than the arch-native fp8 dtype. These records are OCP by definition of the format, and the kernel's dequant reads OCP code points; on gfx942 the native dtype is float8_e4m3fnuz, so building with it decoded to garbage (rel-err 1.0) on every fp8-cache case. _classify_flat already rejects fnuz when a uint8 view is not hiding the dtype. gfx950 is unchanged: _arch_block_k -> 64, _arch_num_warps -> 4, lds_limited False, FP8_DOT_ARCHS contains gfx950, and FP8_DTYPE is OCP e4m3 there either way, so every value and branch resolves exactly as before. Validated on MI325X (gfx942), TP4, GLM-5.3-Flash at 131k context, where this path serves the rope-free NoPE MLA that has no AITER kernel today: op_tests test_sparse_mla 32 passed, 12 skipped (fp8 dots) bench_sparse_mla runs clean, bf16 series only sparse-MLA decode bucket 3.099 -> 0.400 ms/step 7.74x sparse-MLA prefill 10988 -> 10330 us/call 1.06x end-to-end sweep +7.14% mean output tok/s, 7/7 rows won gsm8k 0.9719 vs 0.9712 strict-match (neutral) Co-authored-by: Cursor <[email protected]>
jin-amd
force-pushed
the
gfx942-sparse-mla
branch
from
September 16, 2026 08:52
62ea84a to
ced68ed
Compare
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.
Enables
sparse_mla_fwdon gfx942, on top of #4919.The Gluon kernel needs no change to run there — the
gl.amd.cdna4intrinsics ituses (
async_copy,mfma,buffer_load/buffer_store) all lower fine ongfx942 under Triton 3.7.1. The arch gate was the only thing in the way, plus two
launch-config values sized against gfx950's LDS budget.
Why the tile has to change
gfx942 (CDNA3) has 64 KB of LDS per workgroup against gfx950's 160 KB. The
bf16 KV tile alone is
BLOCK_K * (kv_lora_rank + LDS_PAD) * 2 B, so the gfx950tile of 64 asks for 68 608 B and will not launch:
BLOCK_K=32is the largest that fits.num_warpsis decoupled fromBLOCK_Kin the same change. It was derived asBLOCK_K // 16, so capping the tile for LDS would have dropped num_warps from 4to 2 as a side effect rather than as a tuning decision. Keeping it at 4 is
worth 1.19× → 1.55× on the prefill shapes, so it is worth making explicit.
dot_precision="fp8"is rejected on gfx942This one is a genuine hardware limit and was the only real surprise. The fp8 dot
path feeds the cache's own code points to the matrix core, which needs OCP
e4m3 MFMA — that arrives with CDNA4. CDNA3 has fp8 MFMA in the fnuz encoding
only, so OCP code points read back wrong.
It was silently wrong (rel-err 7.5e-1) rather than faulting, which is why
this raises now, naming the alternative.
dot_precision="bf16"dequantizes thetile on its way into LDS and works on every arch and every cache format —
including the fp8 caches, which is what production uses here.
gfx950 is unchanged
_arch_block_k→ 64,_arch_num_warps→ 4,lds_limitedFalse, andFP8_DOT_ARCHScontains gfx950, so every value and branch resolves exactly asbefore. I do not have gfx950 hardware, so that claim is by construction rather
than by test — worth a second pair of eyes.
Validation
On MI325X (gfx942), TP4, GLM-5.3-Flash at 131 k context. This matters on that
model because its NoPE MLA has
qk_rope_head_dim = 0, which has no AITER pathtoday, so vLLM falls back to a vendored Triton gather+dot — the single largest
kernel in the model in both phases.
op_tests/triton_tests/attention/test_sparse_mla.py:Kernel bucket, from a real torch profile at concurrency 12 (rank 0):
End-to-end, 131 k in / 1024 out, same image both arms with only the dispatch
switched:
Won 7/7 rows, mean +7.14% output throughput, zero failed requests. gsm8k
(5-shot, full 1319 questions) is neutral: 0.9719 vs 0.9712 strict-match, against
a ±0.0046 standard error.
The gain being largest at low concurrency is the signature of this kernel rather
than noise: the operator is batch-independent, so replacing it takes a roughly
constant ~2.7 ms off every decode step, which is 16.6% of TPOT at concurrency 2
but 4.9% by concurrency 16.
Note on prefill
The 1.06× prefill figure is the honest one, measured in a profile. A
microbenchmark using
randpermtop-k indices reports 1.55× for the same shape,but that flatters it — random indices give the Triton gather far worse locality
than production does (11.0 ms real vs 15.7 ms synthetic for the same shape),
while this kernel gathers whole 512 B rows and is locality-insensitive. Prefill
microbenchmarks on this operator should not be trusted without a profile.