In this series / On this page· 16 of 18
- 1. Disaggregated Serving: Dynamo, llm-d, and When Splitting Prefill from Decode Pays
- 2. TTFT, ITL, Goodput: Measuring What Users Feel
- 3. Benchmark an Inference Server Without Lying to Yourself
- 4. Expert Parallelism, and What DeepEP Does for It
- 5. Serving Kimi K3.1 Pro: The State per Request, the Indexer's Cost, and Where 1M Tokens Fit
- 6. Other Users' Data in the KV Cache: What Cloudflare's GLM-5.3 Incident Teaches Operators
- 7. Flow Control in the Serving Stack: What llm-d, Dynamo and AIBrix Do When the Fleet Is Full
- 8. Context Parallelism for Long-Context Serving: PCP and DCP in vLLM and SGLang
- 9. Several Models, One GPU: Time-Slicing, MPS, MIG, and What CUDA 13.4's Memory Caps Change
- 10. Serving Mistral Large 4: What Its Cache Costs and Where It Fits
- 11. Prefix-Aware Routing Across Replicas: Kubernetes Service, Dynamo's KV Router, the llm-d EPP and Kinference
- 12. Serving Ripple-65B: What a Dense Model with 1M Context Costs, and When It Beats an MoE
- 13. Cost per Million Tokens, Computed: GPU-Hours, Utilization, and the Cache
- 14. Kinference at alpha.7: What Buoyant's Inference Control Plane Does, and What It Reuses
- 15. Splitting Off the Vision Encoder: When Encoder Disaggregation Pays in vLLM
- 16. The Cache Hit That Changed the Answer
- 17. Prefix Caches That Collapse Under Bursts, and the Session Cap That Prevents It
- 18. MLPerf Endpoints v1.0: How to Read an Agentic Inference Benchmark
The Cache Hit That Changed the Answer
A prefix-cache hit changes the shape of the prefill, and with 4-bit weights that was enough to change the completion of 11 of 24 greedy requests served alone. What batch-invariant mode fixes, and what it costs per weight format.

Send one GSM8K question to vLLM with greedy decoding, alone on the server, with a system prompt of about 4,250 tokens in front of it, and Qwen3-8B in 4-bit weights begins its answer with "Step 1: Calculate the". Send it again, same server, same everything, once that same request has put its prompt in the prefix cache, and the answer begins "To find out how much Janet". A cache hit is not supposed to change anything but the speed; this one changed the first token, and across 24 questions the cache changed the text of 11.
What a cache hit changes
A cache hit doesn't change the input; it changes how the engine cuts the work. On a miss, vLLM prefills the whole 4,343-token prompt in chunks of at most 2,048 tokens (its default token budget per step on this GPU, source): 2,048, then 2,048, then the last 247, which hold the end of the system prompt and the question. On a hit, the first 4,336 tokens come from the cache and the engine computes only the last 7.

Figure 1: The question's tokens go through every matmul in a block of 247 rows on a miss and of 7 rows on a hit.
So the question's tokens pass through every linear layer as part of a 247-row matrix on a miss and a 7-row matrix on a hit. Mathematically the rows are independent. In floating point they are independent only if the kernel sums each row's dot products in the same order whatever the number of rows, and most fast kernels don't: they pick their tiling, and sometimes a split of the reduction, from the shape. Temperature 0 Is Not Determinism shows the same mechanism with the batch: there the rows that change are other requests; here they are your own earlier tokens, now read from the cache. Attention changes too: on a hit, the question's tokens attend to keys and values computed by the request that filled the cache, in that request's chunks.
None of this needs other traffic. The run above had one request on the server at a time.
Measured: three weight formats
We ran Qwen3-8B on vLLM 0.33.0 on one GB10 (DGX Spark), in three checkpoints of the same model, BF16, FP8 (block-scaled) and W4A16 (4-bit weights, 16-bit activations), each stock and with VLLM_BATCH_INVARIANT=1. Two tests per configuration, greedy, 200 output tokens:
- Batch: 40 GSM8K questions alone, then the same 40 at a concurrency of 32.
- Cache: 24 questions behind the shared 4,240-token few-shot prompt, one at a time, each one cold (a
cache_saltper request forces a miss) and then each one warm (a shared salt, primed once; the server reported 4,240 to 4,336 cached tokens per request).

Figure 2: The cache hit barely moved BF16 and FP8; it changed almost half the 4-bit completions. Batch invariance removed both effects.
| Completions that differ | BF16 | FP8 | W4A16 |
|---|---|---|---|
| Alone vs in a batch of 32 (of 40) | 14 | 29 | 22 |
| Cold vs warm cache, alone (of 24) | 1 | 0 | 11 |
The same, VLLM_BATCH_INVARIANT=1 |
0 and 0 | 0 and 0 | 0 and 0 |
Two controls make the warm runs readable. Two cold runs of the BF16 model gave 24 identical completions out of 24, stock and invariant (we ran this control on BF16 only): with nothing else changing, the engine repeats itself, so we read the warm-run differences as coming from the hit. And the split points are early: the median 4-bit completion parted ways at token 31, one at token 1, and one at token 0, the request that primed the cache, which hit 4,336 tokens and recomputed 7 (the opening example). These are different completions, not end-of-sequence wobbles; in 4 of the 11 the last number written changed too.
The format matters more than the cache, though. Served alone, BF16 and FP8 gave different text for 36 of 40 questions, splitting at a median of 16 tokens; BF16 and W4A16, for all 40. That is expected: they are different numbers. The cache result says something narrower and more annoying: with one checkpoint, one server and one request at a time, whether the answer repeats depends on what the cache held when it arrived.
Why 4-bit moves the most
The 4-bit layers run on Marlin, vLLM's mixed-precision kernel (the log says Using MarlinLinearKernel for CompressedTensorsWNA16), and Marlin's reduction depends on the number of rows. That Marlin depends on M is not our inference: it's the reason vLLM gives for keeping Marlin out of the invariant mode, in a comment that reads "Marlin's reduction depends on M" (source). That it explains most of the 11 is ours: the flag also changes attention, the norms and the output projection, so its 0 of 24 doesn't isolate Marlin. But a 247-row and a 7-row call do take different paths through it.
The FP8 checkpoint, block-scaled, ran on DeepGEMM's FP8 kernel and did not move once in 24 cold-warm pairs, while it moved the most in the batch test (29 of 40). The two tests stress different things: the cache test changes only the prefill (its shape, and which request computed the cached keys and values), with one request decoding; the batch test also changes the decode batch every step, where attention splits its work by the batch size and the other operators see 32 rows instead of one. Our reading, not verified kernel by kernel, is that this FP8 GEMM keeps its order across row counts and something else in the decode step does not. BF16 sat in between: 1 of 24.
The amplification is not specific to vLLM or GPUs. A paper on arXiv (revised 5 November) that measured cache-induced divergence on llama.cpp (agentic multi-turn episodes, prefix reuse on vs off, batch size one) found 37.4% of Qwen2.5-7B episodes diverging at 16 bits and 82.5% at 4 bits, and placed the amplification mainly in the quantized execution path: 4-bit weights served through 16-bit kernels diverged not detectably more than the 16-bit model. With prefix reuse off, every one of their runs reproduced every token.
What the invariant mode does with quantized weights
The invariant mode fixes the order of each operation, and for quantized layers that means choosing, per format, between a kernel that already keeps its order and a fallback that dequantizes to BF16 and runs the invariant matmul. vLLM v0.33.0 decides per format:
| Weights | Stock kernel (on our GPU) | Under VLLM_BATCH_INVARIANT=1 |
|---|---|---|
| BF16 | cuBLAS | the Triton batch-invariant matmul |
| FP8, block-scaled | DeepGEMM block-scaled FP8 | the same FP8 kernel, called directly (source) |
| FP8, per-tensor or per-channel | CUTLASS or Triton scaled matmul | the same kernel if it qualifies (fp8_scaled_mm_is_batch_invariant), else the weights dequantized to BF16 |
| W4A16 (compressed-tensors) | Marlin | weights dequantized to BF16 on every call, then the invariant matmul (source) |
| AWQ | Marlin | not Marlin (source) but a torch.matmul path (source); not tested here |
One line in that code deserves attention even if you never turn the mode on. FP8 with a dynamic per-tensor activation scale computes that scale as the maximum over every token in the batch, so one request's quantized activations depend on the requests next to it; under the flag vLLM switches to a per-token scale for that reason (source). In stock mode, a per-tensor dynamic FP8 checkpoint couples requests by design, not by rounding.
The price, per format
The fallback is what costs. Dequantizing every 4-bit weight to BF16 on every call means reading the 4-bit weights, writing and reading them again in 16 bits, and doing it at every decode step, which throws away the reason for 4-bit weights on a memory-bound GPU.

Figure 3: The mode cost BF16 and FP8 a few percent at 32 requests and nothing alone; it made the 4-bit model 6 times slower, slower than BF16.
| Output tokens/s | Stock, alone | Invariant, alone | Stock, 32 at once | Invariant, 32 at once |
|---|---|---|---|---|
| BF16 | 13.6 | 14.3 | 268.7 | 260.8 (-3%) |
| FP8 | 21.9 | 22.7 | 430.2 | 419.4 (-2.5%) |
| W4A16 | 41.7 | 6.6 (-84%) | 716.0 | 124.1 (-83%) |
These are the test runs themselves (short GSM8K prompts, 200 tokens out), one run per point, so read a few percent either way as noise. A separate vllm bench serve on the FP8 model (1,024 tokens in, 200 out) agreed: 1% to 2% fewer output tokens per second at 1, 8 and 32 concurrent requests, and no later first token. The BF16 figures match what the BF16 measurement found with a longer benchmark.
The research side is working on the gap. Detent (7 November) starts from the observation behind the FP8 row: many fast kernels are invariant already, and what breaks invariance is the engine choosing the kernel and its parameters from the batch. It pins the few values that the selection reads, tuned per workload, and reports 1.04 to 1.17 times stock latency per output token against 1.67 to 10.3 times for the engines' deterministic modes, with rollouts that replay bit for bit "under other batches and cache splits". It is a paper, not an engine flag.
What to do
Decide first whether two runs must agree, then pick the cheapest way for your weight format:
- Chat and most APIs: do nothing. A warm answer is as plausible as a cold one (the paper found no detectable net change in accuracy); nobody is owed the cold one.
- Evals and regression tests, any format: turn prefix caching off for the eval run (
--no-enable-prefix-caching), or give every request its owncache_salt. The cache is then a constant, as in the paper's runs that reproduced every token. Fix the batch too, or run the invariant mode, because batching moved more answers than the cache did. - RL rollouts, replay, audits on BF16 or FP8: run
VLLM_BATCH_INVARIANT=1with the cache on; it held at 0 of 24 and 0 of 40 for both, for a few percent. - The same on 4-bit weights: don't pay the 84%. Serve the FP8 checkpoint in invariant mode instead: it ran 3.4 times faster than invariant W4A16, alone and at 32 requests, for about twice the weight memory.
- A fleet behind a prefix-aware router: the same request lands on replicas with different cache contents, so a cache-sensitive format gives different answers per replica as well as per moment. Prefix-aware routing raises hit rates; it doesn't make them identical.
Test your own stack with two requests: one that must miss, one that must hit. With --enable-prompt-tokens-details, the response says how many tokens came from the cache.
$ BODY='{"model":"<served model name>","temperature":0,"max_tokens":200,"messages":[
{"role":"system","content":"<your long system prompt>"},
{"role":"user","content":"<your question>"}]'
$ for salt in prime cold-$RANDOM prime; do
curl -s localhost:8000/v1/chat/completions -H 'Content-Type: application/json' \
-d "$BODY,\"cache_salt\":\"$salt\"}" \
| jq -c '[.usage.prompt_tokens_details.cached_tokens, .choices[0].message.content[:60]]'
done
The first call fills the cache under the salt prime, the second misses on purpose, the third hits. If the second and third texts differ, your configuration is cache-sensitive. The third call repeats the priming request, the extreme case (see the gotchas); for an ordinary hit, run it once more with another question under the salt prime and compare it with that question sent under a fresh salt. The full test, 24 questions and the comparison, is in det_client.py and det_compare.py, with the prompts from make_prompts.py and our results in det-results.txt.
Gotchas
The priming request is special. The request that fills the cache hits almost all of its own prompt the next time (4,336 of 4,343 tokens here), while other requests hit only the shared part (4,240). It is the most extreme shape change, and in our 4-bit run it split at the first token. Test with the request that primed and with one that didn't.
Hits come in blocks. vLLM caches full 16-token blocks, so what is recomputed on a hit is the tail after the last full shared block, not exactly your new tokens. Two prompts with the same prefix and different questions recompute different amounts, which is one more shape that varies.
The invariant answer is a third answer. As the BF16 piece found, the mode's output differs from stock output even alone; per format: 24, 38 and 18 of 40. Switching it on changes every downstream baseline once.
NVFP4 is untested here. The NVFP4 checkpoint of the same model did not start on our machine with vLLM 0.33.0 (the FlashInfer FP4 GEMM failed to build at startup), so we have no number for 4-bit activations. Its kernels pick their configurations by shape too; test it before you rely on it.
Temperature above 0 adds the draw. Everything here is greedy. With sampling, send a seed; the cache effect stays, on top of it.
Next, Prefix-Aware Routing measures how routers decide which replica's cache a request meets; for checking that a quantized checkpoint gives answers as good as the original, not identical ones, see Measuring the Damage.