int8 per-(token,head) KV cache for the Qwen3.8-Flash-Next QSA path - #1
Open
rmagur1203 wants to merge 2 commits into
Open
rmagur1203 wants to merge 2 commits into
rmagur1203 wants to merge 2 commits into
Conversation
Runtime patches + measurements for --kv-cache-dtype int8_per_token_head on the sparse QSA attention path, GB10 / sm_121. Key finding: vLLM's inline per-token-head scale layout makes the slot 260B, which breaks 128B alignment and costs 6.3x in a gather-based kernel (9.6ms -> 60.2ms). Keeping the scales in a side tensor restores alignment; int8 then beats fp8 on TTFT (-7.9%), decode (+5.2%) and MTP acceptance (+1.9pts) at an identical KV pool. Reported upstream: vllm-project#56081, and as corroboration on vllm-project#54426. Not upstreamable as-is: targets the pre-rename module and stacks on unmerged vllm-project#55557.
The "vllm-project#54426 (comment)" link pointed at the issue body; point it at the actual corroboration comment (issuecomment-5602282777).
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.
Tracking PR inside my own fork — not intended for vllm-project/vllm as-is.
Why this is not an upstream PR yet
vllm/vllm-openai:qwen38-flash-next-arm64-cu130(0.1.dev20073+g8e685d198), whose moduleis
vllm/models/qwen3_8_flash_next/. Upstream renamed it tovllm/models/qwen4_exp/.mainhas no KV quantization plumbing in that module at all —_cast_kv_tile,KV_QUANT_MODE,k_scale_ptrall return 0 occurrences. The fp8groundwork this builds on is still in review as [Model] Qwen4Exp: fp8_e4m3 main KV cache on the QSA path vllm-project/vllm#55557, so an int8 PR
would have to duplicate an active review.
mainon this hardware: PLE CPU offload(
VLLM_PLE_CPU_OFFLOAD,vllm/v1/ple_offload/) is not upstream, and without it the 125Bcheckpoint does not load on a single 121 GiB GB10.
Opened so the code behind vllm-project#56081 and my comment on
vllm-project#54426 is inspectable, and so the work has a stable URL.
What is in here
qsa-kv-int8/— patches, tools, and the measurement grids. See the README for the fullwrite-up.
Headline result
int8 per-
(token,head)KV on the QSA sparse-attention path, 9-cell grid, matchedbackground load, KV pool pinned to 13.75 GiB:
The finding worth upstreaming (vllm-project#56081)
vLLM stores per-
(token,head)scales inline after each head's data, making the slot260 B. That is not a multiple of 128. Contiguous-access kernels tolerate it; QSA gathers
scattered tokens and pays 6.3× (9.6 ms → 60.2 ms at 2048 rows / topk 1024). Moving the
scales to a side tensor restores alignment at identical memory cost.
I nearly abandoned int8 over this — the first end-to-end run showed a 40 % prefill
regression, and it took four wrong hypotheses before isolating the kernel showed int8 was
in fact faster than both fp8 and bf16 and the whole regression was the layout.
Attribution
patches/apply_qsa_fp8_kv.sh/qsa_fp8_kv_sm121.patchare not mine — the patchattached to vllm-project#54426 by @Nanetnounou, included because the int8 work builds
on it.
fix_ple_mixed_precision.pyandfix_mtp_block_fp8.pyare ports of upstreamd4d703caand vllm-project#55513 to the pre-rename module name.