Repository navigation
[Triton/Gluon] [gfx942] Read the fp8_dsv32_mla cache in fnuz on gfx942 - #7510
Conversation
sparse_mla_fwd rejected every fp8 cache on gfx942, because the kernel reads fp8 bytes as OCP e4m3 and gfx942's native fp8 is e4m3 fnuz. Producers on gfx942 write the fp8_dsv32_mla cache (vLLM's fp8_ds_mla: 512 fp8 | 4 f32 per-128 scales | 64 bf16 rope) in fnuz, so DeepSeek-V3.2-style models such as Kimi-K3.1 could only run there on a bf16 cache. The fp8_dsv32_mla path already dequantizes each tile in f32 and runs bf16 dots, so the decode was the only gap: a byte read as OCP comes out 2x too large, and NaN where the fnuz quantizer saturated at 240. _fp8_to_f32, which only the scaled caches use, now bitcasts to float8e4b8 on CDNA3. fp8 q, the fp8_scalar cache and fp8 dots keep the OCP reading and stay gfx950-only. FNUZ_DSV32_ARCHS names the archs that take the cache this way, so a caller such as vLLM can tell an aiter with this change from one without it. Tests on MI325X (gfx942): test_sparse_mla.py has 47 passed and 97 skipped (the gfx950-only fp8 cases). test_ds_mla_format now runs on gfx942 and covers decode, 12 heads (Kimi-K3.1's 96 at TP8) with LSE, and a prefill shape with LSE. With the decode change reverted, all three fail on NaN output. The gate tests now expect gfx942 to take bf16 q with fp8_dsv32_mla and still reject fp8 q with it. End to end, with the same change on the aiter of a Kimi-K3.1 vLLM image, Kimi-K3.1-Pro at TP8 on 8x MI325X with the fp8_ds_mla cache scores 0.984 on GSM8K (250 questions, zero-shot) against 0.980 on a bf16 cache, retrieves 12/12 passkeys up to 131k tokens on both, and holds 1.62x the KV tokens. Signed-off-by: Xavier Aguilar <[email protected]> Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT 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.
🔵 Needs a closer look
Runtime validation is still needed for the new gfx942 FNUZ path and gfx950 regressions, since gfx942 results are author-reported and gfx950 was not rerun.
No open issues 🎉
What changed in this PR
This PR enables sparse_mla_fwd to read fp8_dsv32_mla KV caches on gfx942 using native fnuz decoding, with bf16 queries and dot products. Other fp8 inputs remain gfx950-only.
Changes:
- Add compile-time fnuz decoding for scaled cache bytes on gfx942.
- Update architecture checks, capability metadata, error messages, and docstrings.
- Extend cache correctness tests to cover gfx942, 12-head decoding, prefill, and LSE output.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_sparse_mla.py |
Enable gfx942 cache tests and expand correctness and architecture-gate coverage. |
aiter/ops/triton/attention/sparse_mla.py |
Allow the fnuz cache on gfx942 and document its restrictions. |
aiter/ops/triton/_gluon_kernels/gfx950/attention/sparse_mla.py |
Select native fnuz decoding on CDNA3 while preserving OCP decoding elsewhere. |
Review effort: Balanced
|
CI now covers both points. Triton Tests (MI35X) ran the selected tests on gfx950, and Triton Tests (MI300X) ran them on gfx942 ( As a further gfx950 check, I compiled every |
|
@azaidy we need this to have Kimi-K3.1 enabled on gfx942, so it would be good if we can have it ready by the next Aiter cut. |
Keep ROCm#7510's gfx942 fp8_dsv32_mla path with this branch's fp8_scalar cache and fp8 dots. Scaled-cache dequant already follows FP8_FNUZ.
Accept fp8_ds_mla on gfx942 and gfx950 unconditionally, assuming an AITER that includes ROCm/aiter#7510. Replace the probe's unit tests with fp8_ds_mla cases in the ROCm sparse backend correctness test, which run ROCMAiterMLASparseImpl end to end against an SDPA reference. Signed-off-by: Xavier Aguilar <[email protected]> Co-authored-by: Cursor <[email protected]>
Summary
sparse_mla_fwdcan now read thefp8_dsv32_mlaKV cache (vLLM'sfp8_ds_mla) on gfx942. gfx942 decodes it as its native e4m3 fnuz with bf16 q and bf16 dots. Every other fp8 input stays gfx950-only.Motivation
On gfx942 the wrapper rejects every fp8 cache, because the kernel reads fp8 bytes as OCP e4m3 and gfx942's native fp8 is e4m3 fnuz. Producers on gfx942, vLLM's
concat_and_cache_ds_mlaincluded, write thefp8_dsv32_mlacache in fnuz. The layout is 512 fp8 | 4 f32 per-128 scales | 64 bf16 rope. As a result, DeepSeek-V3.2-style models such as Kimi-K3.1 can only use a bf16 cache on MI300X/MI325X, and vLLM refuses to start Kimi-K3.1 there unless the user passes--kv-cache-dtype bfloat16. The fp8 cache holds 1.62x as many tokens.The
fp8_dsv32_mlapath already dequantizes each tile in f32 and runs bf16 dots, so only the decode was missing. A fnuz byte read as OCP comes out 2x too large, and as NaN where the quantizer saturated at 240.Changes
aiter/ops/triton/_gluon_kernels/gfx950/attention/sparse_mla.py:_fp8_to_f32, which only the scaled caches use, bitcasts tofloat8e4b8(fnuz) on CDNA3 and tofloat8e4nv(OCP) elsewhere. The branch is resolved at compile time withis_hip_cdna3(), so gfx950 code is unchanged. Of the scaled caches onlyfp8_dsv32_mlareaches this kernel on gfx942, sincefp8_g64is packed and gfx950-only.aiter/ops/triton/attention/sparse_mla.py: the newFNUZ_DSV32_ARCHS = ("gfx942",)lists the archs that takefp8_dsv32_mlain their native fnuz._check_fp8_archlets that cache through on those archs, with bf16 q only._check_packed_arch's message and thesparse_mla_fwddocstrings now name the formats gfx942 takes.fp8_scalarcache anddot_precision="fp8"still read OCP e4m3 and are still rejected on gfx942, with the samefnuzerrors.op_tests/triton_tests/attention/test_sparse_mla.py: thefp8_dsv32_mlacorrectness test now runs on gfx942, and the gate tests expect the new behavior (see Changed op tests).FNUZ_DSV32_ARCHSalso lets callers check for the capability. vLLM can allowfp8_ds_mlaon gfx942 only when the installed aiter lists the arch, so that change can merge before vLLM bumps aiter.Performance (if applicable)
Before this change gfx942 rejected
fp8_dsv32_mla, so the baseline is the bf16 cache it had to fall back to. Both use bf16 q, top-k 2048, d_qk 576 and a 131,072-token pool. The times are the mean oftriton.testing.do_benchon 3 GPUs.fp8_dsv32_mla)sparse_mla_fwddecode, 8 queries, 12 headssparse_mla_fwddecode, 64 queries, 12 headssparse_mla_fwddecode, 64 queries, 16 headssparse_mla_fwdprefill, 4096 queries, 12 headsThe kernel takes the same time within 7% on either cache, and the fp8 cache holds 1.62x the tokens in vLLM. gfx950 is not affected: there
_fp8_to_f32compiles to the same OCP convert as before.Testing
Documentation
Dependencies
Breaking Changes
None. gfx942 accepts one input it used to reject, and every other input behaves as before on every arch.
PR Self-Review
Reviewed revision
98c734c
Behavior and intent
On gfx942,
sparse_mla_fwdused to raiseValueErrorfor thefp8_dsv32_mlacache. It now dequantizes that cache in its native fnuz and runs bf16 dots. fp8 q,fp8_scalarand fp8 dots are still rejected on gfx942, and nothing changes on gfx950. Before, gfx942 users of this layout could only fall back to a bf16 cache at 1.62x the memory, even though the dequant path needed only the arch's fp8 decode.Validation and unverified scope
On 8x MI325X (gfx942), ROCm 10.0, Triton 3.8.0:
ruff0.16.0 andblackare clean._fp8_to_f32change reverted, all threetest_ds_mla_formatcases fail with NaN output.fp8_ds_mlacache against bf16. Passkey retrieval inserts one key into filler text and asks for it back, at depths of 10%, 50% and 90%.Both caches gave the same GSM8K answer on 249 of 250 questions.
With the
fp8_ds_mlacache and a production serving config (--max-model-len 135168, full and piecewise CUDA graphs), lm-eval 0.4.13 through the completions API gives:Unverified:
ci:triton-300x) ran the selected tests,test_sparse_mla.pyincluded, and passed. On gfx950 that covers the fp8 cases that skip on gfx942._sparse_mlaand_sparse_mla_fp8variant thattest_sparse_mla.py,test_pa_decode_sparse.pyandtest_mla_v4_triton.pybuild for gfx950 (TRITON_OVERRIDE_ARCH=gfx950), on this PR's base and head. The AMDGCN is identical for all 186 variants compiled in both runs.SUPPORTED_ARCHS._fp8_to_f32decode and_check_fp8_archgate applied. The unit tests and the benchmark ran this branch'saiter/ops/tritontree.PR-specific question
Before this PR, gfx942 can fail to read
fp8_dsv32_mlain two ways. The wrapper's_check_fp8_archraises aValueErrorthat namesfnuz. If only that gate is relaxed, the kernel still decodes the bytes as OCP and returns NaN.test_ds_mla_format[topk2048],[h12_lse],[prefill_lse]:fnuzValueError._fp8_to_f32still reading OCP, all three fail on NaN output (the negative control above).fp8_dsv32_mla.test_sparse_mla,test_sparse_mla_rope_free,test_return_lseandtest_global_load_pathparametrize overbf16andtensoronly, andtest_sparse_mla_dsv4_train.pyuses a bf16 cache.test_ds_mla_formatran a single decode shape and skipped on gfx942.[h12_lse]and[prefill_lse]add checks that no existing test makes for this cache: the LSE output, a 12-head launch (the only non-power-of-two head count in the file) and the prefill launch config.test_fp8_arch_gate: the bf16-qfp8_dsv32_mlacase now expects gfx942 to accept the input. It fails on the old code, where_check_fp8_arch("gfx942", "fp8_dsv32_mla", torch.bfloat16)raises. The new fp8-qfp8_dsv32_mlacase passes both before and after. It guards against relaxing the gate too far, since gfx942 must still reject fp8 q with this cache.test_native_fp8_cache_rejected[dsmla]: it asserted the old rejection, so on the new code it would fail. It now skips on gfx942.[tensor]still checks that the per-tensor fp8 cache is rejected there.Changed op tests
op_tests/triton_tests/attention/test_sparse_mla.py:test_ds_mla_formatused to skip on gfx942 and now runs there. It is parametrized over decode at top-k 2048, 12 heads with LSE (Kimi-K3.1's 96 heads at TP8, a non-power-of-two head count), and a 2048-query prefill shape with LSE, which runs gfx942's prefill launch config. The cache is packed and decoded in the arch-native fp8 (get_fp8_e4m3_dtype()), as a gfx942 producer writes it. No other test readsfp8_dsv32_mlaon gfx942.test_fp8_arch_gatenow expects gfx942 to accept bf16 q withfp8_dsv32_mla, and has a new case for fp8 q withfp8_dsv32_mla, which must still be rejected there. Thefp8_scalarand fp8-q cases keep thefnuzerror.test_native_fp8_cache_rejected[dsmla]skips on gfx942, which now reads that cache.[tensor]still checks the rejection.