中文版

If you serve LLMs with vLLM 0.33 on H100s or H200s and turned on one of its two 4-bit KV caches (nvfp4, decoded by FlashInfer, or ultraquant_4bit, decoded by Triton) to fit more tokens, you probably paid for it in decode speed. Hopper has no FP4 hardware, so every 4-bit value has to be unpacked and scaled in software inside the attention kernel, and on an H200 there is very little room for that. This post explains where the time goes and what a kernel that fixes it looks like. Code (Apache-2.0) and the full report are linked at the end.

The problem in one table

Here is one call of each decode kernel on an H200 at batch 32 and 16K context. One call computes one attention layer for one decode step of all 32 sequences: each of the 32 new tokens attends to its own 16,384 earlier tokens, with Llama-3.1-8B’s layer shape (8 KV heads, head dimension 128). The byte count is what the kernel must read from the KV cache; dividing it by the H200’s 4.8 TB/s gives the fastest the call could possibly be.

Kernel KV bytes read per call Time at full bandwidth Measured Share of bandwidth used
BF16 (FlashInfer) 32 × 8 × 16,384 × 2 × 256 B ≈ 2.15 GB 0.447 ms 0.495 ms about 90%
FP8 (XQA, the kernel vLLM uses) ≈ 1.07 GB 0.224 ms 0.255 ms about 88%
NVFP4 (FlashInfer, vLLM’s 4-bit path) 72 B per row, ≈ 0.60 GB 0.126 ms 0.669 ms about 19%

(The factor 2 is K and V. BF16 and NVFP4 were timed in one job, XQA in another.)

NVFP4 reads less than a third of BF16’s bytes, so it should be more than three times faster. It is slower. BF16 and FP8 both run close to the memory limit; NVFP4 uses less than a fifth of it. The rest of this post is about where that time goes.

A full decode step multiplies this by the number of layers (32 on Llama-3.1-8B) and adds the weight read and the other matrix multiplies. In vLLM, the same 32 × 16K shape takes 12.66 ms per step with FP8, of which attention is roughly 32 × 0.255 ≈ 8 ms. That is also why our kernel, 1.37× faster than XQA at this shape, makes the whole step only 1.16× faster (10.94 ms): attention is only part of the step, and the recipe adds a query rotation and a sink merge.

Three things to check first

These come from measurements on H200 with vLLM 0.33 and Llama-3.1-8B unless noted.

  1. vLLM’s NVFP4 KV cache is slower than FP8 on Hopper. --kv-cache-dtype nvfp4 saves memory but decodes 1.4–2.3× slower than FP8 at batch 8 and above, and about 1.1× slower at batch 1. vLLM’s other 4-bit option, UltraQuant, falls back to Triton decode kernels on NVIDIA GPUs and is 1.8–4.4× slower than FP8 per step.
  2. Your FP8 baseline may not be the fast one. With FlashInfer and an FP8 KV cache, vLLM uses TensorRT-LLM’s XQA decode kernel only if a network check to NVIDIA’s artifact server succeeds. Behind a proxy that check can fail, and vLLM falls back to FlashInfer’s own decode kernel without an error. Look for decode_backend=xqa in the log.
  3. Qwen2-family reasoning models can collapse under FP8 KV, silently. Keeping layer 0 in BF16 (--kv-cache-dtype-skip-layers 0, 1/28 more KV memory on a 28-layer model) restored them in our runs. The reason is specific: layer 0’s key vectors carry a large mean, which is the key projection’s bias seen through RoPE, and a per-tensor FP8 scale cannot represent it well. Not every model with a key bias collapses (R1-Distill-Qwen-14B and Qwen2.5-14B did not), and the layer-0 statistics we computed from the weights do not predict which ones do, so test your own model with and without layer 0 in BF16.

Why software 4-bit decoding is slow on Hopper

Decode attention is supposed to be memory-bound: read the KV cache once, do a little math per byte. A 4-bit cache reads about half the bytes of FP8, so it should be almost twice as fast. The catch is the instruction issue rate.

An H200 issues at most about 33 trillion thread instructions per second (132 SMs × 4 schedulers × 32 lanes × 1.98 GHz) and reads 4.8 TB/s. So a kernel that runs at full bandwidth can afford only about 7 instructions per byte it reads. H100 and A100 have about 10, an L40S about 53. Software 4-bit decoding that pays off on an A100 or L40S can therefore be issue-bound on an H200, whose bandwidth grew faster than its compute.

We counted executed instructions with NVBit (batch 32, 16K context):

Instructions per byte against the H200 budget

Two problems show up, and fast kernels need both fixed:

  • Too many instructions. vLLM’s UltraQuant Triton kernel executes about 42 instructions per byte, six times the budget, mostly integer, bit and select operations plus byte-wide loads. FlashInfer’s NVFP4 decode and our own first Triton kernel execute two to three times the budget (extra integer and bit operations, conversions, and in Triton, round trips of decoded values through shared memory).
  • Waiting. Even so, those kernels use only 40–52% of the issue rate: they also stall on serialized loading, decoding and matrix multiplies. BitDecoding’s INT4 Hopper kernel stays within the budget but spends 38% of its instructions spin-waiting on barriers and pads 4 real query heads to the tensor core’s 64 rows. Timed at 11 shapes in one job, it reaches 22–26% of bandwidth at batch 4 and above and is 1.12–1.83× slower than the faster FP8 kernel (XQA or FlashAttention-4) at every shape.

What the fix looks like

Our decode kernel for NVFP4, MXFP4 and INT4 caches makes three choices plus a cheap bit-level decode:

  1. Overlap loading with compute. One producer warp copies the cache with TMA (Hopper’s bulk-copy engine) into shared-memory slots; two compute warpgroups decode and multiply while the next pages arrive.
  2. Lay the cache out at write time. We control the cache format, so the cache-write kernel permutes each K row and V block so that every thread’s tensor-core fragment sits in contiguous 16-byte chunks: one 128-bit shared-memory load per thread per row, no bank conflicts, no shuffles.
  3. Swap the matrix operands. Computing S^T = K q^T and O^T = V^T P^T with wgmma.m64n8k16 puts the decoded K and V^T in the register operand, so decoded values never go back to shared memory, and the small query group (4 or 8 heads) takes the 8-wide dimension instead of being padded to 64 rows.
  4. Decode with bit placement. Placing E2M1’s exponent and mantissa bits at FP16 bits 9–11 and the sign at bit 15 gives the value times 2^-14 exactly, subnormal included; the per-16 scales are applied with paired half-precision multiplies.

Each step matters. On one H200 at batch 32 and 16K context, the pipeline alone reaches 24% of peak bandwidth; adding the write-time layout gives 35%, decoded operands from registers 45%, and the bit-level decode 67%, at about 6.4 instructions per byte, inside the budget.

Why not 100%, if the count is within budget? Being under the budget is necessary, not sufficient. At batch 8 and above the paged kernel reaches 68–74% of peak bandwidth, against 93–95% for a kernel that only reads the cache, so the remaining gap is in the decode work, not in the loads. Neither the bytes read nor the throughput of any one pipe is near its limit there, and 57% of the kernel’s instructions reconstruct and scale 4-bit values, each through a short chain of dependent integer and half-precision operations before the tensor core can use it. Instruction latency and these dependency chains are the likely remaining limit; we could not confirm it, because GPU stall counters were not available on our cluster, and we have not reduced it further. Moving K and V onto FP8 tensor cores after a cheap bit placement (described in the report) raises it to 79–89%.

What you get in vLLM

Through a vLLM 0.33 plugin, with an accuracy recipe (K mean removal, K rotation, four BF16 sink tokens, layer 0 in BF16), against vLLM’s FP8 KV cache on FlashInfer with XQA decode: (none of the recipe’s parts is new: K mean removal follows SageAttention’s “smooth K”, the Hadamard rotation QuaRot, the BF16 sink tokens StreamingLLM and IntactKV, and keeping a sensitive layer in higher precision is common practice; the kernel is the new part)

  Ours
Tokens the KV cache holds 1.63× as many
Decode step, Llama-3.1-8B, batch 8 and above 1.12–1.64× faster
Decode step, batch 1 level
Decode step, Qwen3-32B and Qwen2.5-72B 1.04–1.18× faster (the weight read dominates the step)
Time to first token 1.5–6% longer
Accuracy against BF16 KV (five models, repeated runs) the 95% intervals exclude losses larger than about 3.5 points
Accuracy at 120K tokens (Llama-3.1-8B, multi-key retrieval) 15 points below BF16 KV (vLLM’s default FP8 path: 13 below)
Decode kernel alone, 11 shapes 1.10–1.48× faster than the faster of XQA and FlashAttention-4’s native FP8

Serving under load: two different numbers. The larger cache helps most when traffic spikes. Starting from an empty cache, one H200 absorbed a 600-second burst of a reasoning-like stream (1K input, 8K output tokens) at 1.23–1.32× FP8’s request rate on Llama-3.1-8B, 1.45–1.80× on Qwen3-32B and 1.67–2.20× on Qwen2.5-72B; at the higher rates FP8’s cache filled and requests were preempted while ours stayed at or below 81% cache use on Llama-3.1-8B. These rest on one seed at most points. Whether a GPU also sustains a higher rate is a different question, and we did not settle it. A steady-state test with rules fixed in advance showed no gain at its planned rates on any of the three models; the planned rates, taken from the burst results, turned out to be too high for our configuration. Rates we added after those results put the sustained gain at no less than about 1.31× on Qwen3-32B and 1.14× on Qwen2.5-72B, and include no gain on Llama-3.1-8B; because they were chosen after seeing data and mostly have one seed, the report does not claim a sustained gain. If your traffic is bursty, the first number is the relevant one; for steady traffic, measure on your own workload.

Where it does not help: batch-1 latency, and streams with long inputs and short outputs, where prefill rather than the cache is the limit. And very long contexts cost accuracy on models not trained for them: at 120K tokens on Llama-3.1-8B our cache loses 15 points against BF16 KV. Offline, FP8 storage alone loses only 3 points on the same trials and our cache 10, so at that length the 4-bit cache costs accuracy that FP8 storage does not; on Llama-3-8B-ProLong-512k, trained for long context, it stays within 1.5 points of BF16.

Try it

In a vLLM 0.33.0 environment on H100 or H200:

git clone https://github.com/thomaszhang2661/kv4-hopper && cd kv4-hopper
pip install --no-deps -e integrations/vllm_plugin
export PYTHONPATH=$PWD:$PWD/integrations/vllm_plugin TORCH_CUDA_ARCH_LIST=9.0a
export KV4_VLLM=1 KV4_CALIB=results/calib/Llama-3.1-8B.pt KV4_FORMAT=nvfp4 KV4_KMEAN=1 KV4_SINKS=1 KV4_BOUNDARY=0
vllm serve meta-llama/Llama-3.1-8B --kv-cache-dtype ultraquant_4bit --block-size 64

Calibration files for the ten models in the report are in results/calib/; bench/calib_kv.py makes one for another model. To compare against FP8 on your own GPU, bench/vllm_forward_matrix.py times the pure decode step of both configurations in one process.

Code: github.com/thomaszhang2661/kv4-hopper · Report: arXiv:2611.30027v2

Upstream: the decode kernel is proposed to FlashInfer in #10152, and the vLLM wiring in RFC #70766.

Limits

Long contexts on models not trained for them lose accuracy (above). Head dimension 128 and up to 8 query heads per KV head; no MLA models, sliding-window layers or speculative decoding; the vLLM plugin is tied to vLLM 0.33. Kernel and vLLM numbers are from H200; the kernels also run on H100. On Blackwell, which converts FP4 in hardware, we expect the decode gap between software unpacking and native FP4 to be small at small batch and the native path to win at large batch and in prefill, but we have not measured it.