KV Cache
Core Facts
Timeline (last 90 days)
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.
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.
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.
The order in which prompts are organized directly affects the cache hit rate, and thus the actual bill.
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.
Actual 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.
The 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.
1 more timeline events
All Facts (11)
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%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%