Original title: Fast 4-bit KV-Cache Decoding on Hopper GPUs Without FP4 Hardware
Hopper GPUs lack FP4 hardware. After using NVBit to profile instructions, the author found that vLLM's existing 4-bit KV path kernels exceed the H200 budget of approximately 7 instructions per byte by a factor of 2–6, and that loading, decoding, and matrix multiplication are serialized. He wrote an sm_90a decode attention kernel that stays within the budget and overlaps decoding with loading, packaged it as a vLLM 0.33 plugin, and paired it with a precision scheme: K mean subtraction, K rotation, 4 BF16 sink tokens, and keeping layer 0 in BF16.
Why It Matters Existing 4-bit KV caches on Hopper save memory but are slower than FP8; the author claims the bottleneck lies in kernel implementation, and after rewriting it, high-concurrency, long-output services can achieve both speed and efficiency
Likes 3 · Code Stars 7
Reasons
- The paper claims that in vLLM, for Llama-3.1-8B with batch sizes of 8 or greater, per-step decoding is 1.12–1.64 times faster than FlashInfer FP8, while at batch size 1 it is comparable; for 32B and 72B models, it is 1.04–1.18 times faster; the KV cache can hold 1.63 times more tokens
- Precision: Across five models, the relative loss compared to BF16 KV falls within the 95% interval, excluding cases with losses greater than approximately 3.5 points; however, for Llama-3.1-8B in 120K long-context scenarios, it is 15 points lower than BF16, comparable to vLLM's default FP8 path
- The README includes a reminder for Hopper users: Qwen2 series models may silently degrade under FP8 KV; skipping quantization for layer 0 recovers most of the precision; all result files are available on the Hugging Face dataset, allowing verification without a GPU
- Apache-2.0; Hugging Face likes 3 and code stars 7 only reflect attention levels
Usage
- In an environment with vLLM 0.33.0, run pip install --no-deps -e integrations/vllm_plugin, and set PYTHONPATH and TORCH_CUDA_ARCH_LIST=9.0a
- For each model, first generate calibration constants using bench/calib_kv.py; ready-made files for the ten models in the report are located in results/calib/ and on Hugging Face at ThomasZhangNEU/kv4-hopper-calib
- After setting environment variables such as KV4_VLLM=1 and KV4_CALIB, run vllm serve <model> --kv-cache-dtype ultraquant_4bit --block-size 64; setting KV4_VLLM=0 disables the feature
Risks
- Supports only Hopper (sm_90a) and head dimension 128; does not support MLA models, sliding window layers, or speculative decoding; tensor parallelism has only been verified for correctness at TP=2
- First-token latency increases by 1.5%–6%; performance is comparable or slightly worse in scenarios with long inputs and short outputs; the second version of the report could not confirm steady-state service throughput improvements
- This is a single-author report, and all numbers were measured on the author's own cluster