Repository navigation
[MiniMax-M3.1] NVFP4 sparse KV cache + fused verify top-k (3/3) - #2746
Closed
zhuyuhua-v wants to merge 1 commit into
Closed
zhuyuhua-v wants to merge 1 commit into
zhuyuhua-v wants to merge 1 commit into
Conversation
…verify top-k ATOM_M3_SPARSE_KV_NVFP4=1 stores the K/V of the sparse (indexed) attention layers as NVFP4 in their own pool: per token and kv head a D/2-byte e2m1 payload and D/16 E4M3 block scales (64 + 8 B for D=128, against 128 + 4 B for FP8). Dense layers, the draft model and --kv_cache_dtype are unchanged. - Pool: KvGeometry gains kv_format; the sparse layers declare "nvfp4" and get a separate MhaKvPool whose k/v and k/v_scale fields are uint8 planes. - Write: the fused qk-norm/rope/cache kernel writes BF16 K/V into a shared token-major staging buffer (asm_layout=False, identity slots) and kv_nvfp4_store quantizes them into the pool at the real slots. - Attention: decode and prefill rows go through SGLang's gfx950 NVFP4 sparse decode kernel (vendored), addressed by top-k block ids and the request block table; a one-launch Triton kernel builds each decode row's (request, causal length) in the graph. - With --index-cache-dtype fp4 and >= 3 requests, decode index score + top-k run in SGLang's fused gfx950 verify kernel (ATOM_M3_FUSED_VERIFY_TOPK, default 1). It emits top-k ids only, which is all the NVFP4 attention reads, so it is tied to this path. - Mono decode refuses the NVFP4 KV configuration. MiniMax-M3.1-Flash TP4, MI355X: KV block bytes 3,179,520 (FP8 KV + FP8 index) -> 1,827,840 (NVFP4 KV + FP4 index), 1.74x the tokens per GiB.
This was referenced Oct 27, 2026
Collaborator
Author
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
ATOM_M3_SPARSE_KV_NVFP4=1stores the K/V of MiniMax-M3's sparse (indexed) attention layers as NVFP4. Per token and kv head that is a 64 B e2m1 payload plus 8 B of E4M3 block scales, against 128 + 4 B for FP8. With--index-cache-dtype fp4from the previous PR, decode index scoring and top-k run in SGLang's fused gfx950 verify kernel.Stacked on #2745 (FP4 index), which is stacked on #2744 (vendored kernels). Review only the top commit.
KvGeometrygainskv_format. The sparse layers declare"nvfp4"and get their ownMhaKvPool, whosek/vandk_scale/v_scalefields are uint8 planes. Dense layers, the draft and--kv_cache_dtypeare unchanged.asm_layout=False, identity slots).kv_nvfp4_store(index_fp4.py's store kernel, per head) then quantizes them into the pool at the real slots.ATOM_M3_FUSED_VERIFY_TOPK, default 1): with an FP4 index and >= 3 requests, decode score + top-k is one fused kernel. It emits top-k ids only, which is all the NVFP4 attention reads, so it is tied to this path.Results
MiniMax-M3.1-Flash-Quark-MXFP4, 4x MI355X TP4, AgentX
semianalysis_cc_traces_weka_062126with prefix cache, fixed 7-draft DSpark with synthetic AL 4.04, gpu-memory-utilization 0.9.KV capacity (from the server log):
c48, 3600 s (on #2686 + draft ptpc):
c32, 3600 s:
On this branch (main 481c2bf + this stack +
ATOM_M3_DSPARK_DRAFT_PTPC=1, imagerocm/atom-dev:nightly_202610261558), c48, 1200 s: 396.7 tok/s/GPU, P90 interactivity 70.5 (SGLang CI 436.1 / 70.9), p50 ITL 9.55 ms, prefix hit 0.905, TTFT p50 375 ms, 0 errors. That run differs from the 3600 s table above in three ways at once: run length, base tree (main without #2686) and image. The 9% lower throughput is not attributed to any one of them.Where this is not the best config. At c16, FP8 KV + FP8 index with mono is faster: 181.6 tok/s/GPU and P90 interactivity 191.2, against 156.4 and 137.9 for this config (1200 s, measured before the on-device decode-row fix, not re-measured). This config is meant for c >= 32, where the FP8 cache runs out.
Accuracy
lm-eval gsm8k as InferenceX CI runs it: 5-shot, chat template, temperature 0, full 1319 samples, real acceptance, NVFP4 KV + FP4 index + fused verify.
Tests (gfx950)
kv_nvfp4_storeover H heads equals the per-head index store.🤖 Generated with Claude Code