KV Cache
Core Facts
When generating each token, a Transformer model needs to compute the Key and Value vectors of all previous tokens, and these tensors are collectively called the KV cache.
In the KV Cache mechanism, reusing cached KV values is a cache hit, while context changes that invalidate the cache and require recomputation are a cache miss.
Timeline (last 90 days)
Most companies keep prompt caches for only five minutes, whereas DeepSeek extends cache duration to several days: three days for agent traffic and seven days for chat.
According to DeepSeek's data, 96% of all input tokens hit the cache.
TTFT (time to first token) is mainly determined by the prefill stage, with computation roughly proportional to context length; prefix caching can reuse already-computed KV states and only prefill the newly added portion.
Model weights are only part of VRAM usage; during inference, space must also be reserved for activations, KV cache, context window, and so on.
Running the same Q8_0 file twice, the second time with q8_0 K/V cache, gives KL 0.0038, a larger effect than quantizing weights from BF16 to Q8_0 (KL 0.0022).
Because expert pruning preserves the attention architecture and KV cache format, the KV cache handoff requires no cache conversion, and the runtime only needs to switch weight masks between the two stages.
The order in which prompts are organized directly affects the cache hit rate, and thus the actual bill.
When generating each token, a Transformer model needs to compute the Key and Value vectors of all previous tokens, and these tensors are collectively called the KV cache.
For multi-turn conversations or long-document question answering, if the KV of the entire context is recomputed on every request, the compute overhead grows quadratically with context length.
vLLM implements a bidirectional KV transfer mechanism in which decode nodes send computed KV blocks back to prefill nodes, eliminating repeated prefill computation of common prefixes in multi-turn conversations.
4 more timeline events
All Facts (14)
When generating each token, a Transformer model needs to compute the Key and Value vectors of all previous tokens, and these tensors are collectively called the KV cache.
75%VerifiedIn the KV Cache mechanism, reusing cached KV values is a cache hit, while context changes that invalidate the cache and require recomputation are a cache miss.
75%UnverifiedAccording to DeepSeek's data, 96% of all input tokens hit the cache.
50%UnverifiedMost companies keep prompt caches for only five minutes, whereas DeepSeek extends cache duration to several days: three days for agent traffic and seven days for chat.
50%UnverifiedTTFT (time to first token) is mainly determined by the prefill stage, with computation roughly proportional to context length; prefix caching can reuse already-computed KV states and only prefill the newly added portion.
50%UnverifiedModel weights are only part of VRAM usage; during inference, space must also be reserved for activations, KV cache, context window, and so on.
50%UnverifiedRunning the same Q8_0 file twice, the second time with q8_0 K/V cache, gives KL 0.0038, a larger effect than quantizing weights from BF16 to Q8_0 (KL 0.0022).
50%UnverifiedBecause expert pruning preserves the attention architecture and KV cache format, the KV cache handoff requires no cache conversion, and the runtime only needs to switch weight masks between the two stages.
50%UnverifiedFor multi-turn conversations or long-document question answering, if the KV of the entire context is recomputed on every request, the compute overhead grows quadratically with context length.
50%UnverifiedThe order in which prompts are organized directly affects the cache hit rate, and thus the actual bill.
50%UnverifiedActual token generation speed usually reaches only 50%–70% of the theoretical value, affected by factors such as compute unit scheduling, KV cache reads and writes, and quantization-dequantization overhead.
50%UnverifiedThe prefill phase processes the complete input context, computes attention for all input tokens, and generates the KV cache; it is a compute-intensive operation whose time consumption is strongly correlated with input length.
50%UnverifiedvLLM implements a bidirectional KV transfer mechanism in which decode nodes send computed KV blocks back to prefill nodes, eliminating repeated prefill computation of common prefixes in multi-turn conversations.
50%UnverifiedIn an Agent session, multiple rounds of calls share the same context prefix, so in theory there are a large number of reusable KV cache blocks.
50%