VII. KV Cache & Attention
The KV cache is the central memory object of LLM serving. This section covers storing, moving, compressing, and reusing it, plus attention variants designed to shrink it.
32 entries · 4 subsections
Editor’s pick
VII.1 KV Cache Management & Offloading 8
PagedAttention Paper
Stores the KV cache in fixed-size blocks mapped through a block table, nearly removing fragmentation and allowing copy-on-write sharing between sequences.
LMCache Library
KV cache layer that stores, moves, and reuses KV data across GPU, CPU, disk, and remote tiers, attached to vLLM and SGLang through connectors.
Mooncake Library
Moonshot AI's KV-centric infrastructure, an RDMA transfer engine plus a distributed KV store, used as a backend by vLLM, SGLang, and TensorRT-LLM.
LMCache: An Efficient KV Cache Layer for Enterprise-Scale LLM Inference Paper
Design paper behind LMCache, covering the engine connector interface, batched KV movement between tiers, and support for both prefix reuse and P/D transfer.
vLLM KV Offloading Connector Docs
Configures vLLM's built-in connector that copies finished KV blocks to pinned CPU memory and optional secondary tiers with asynchronous DMA.
SGLang HiCache Docs
Design of SGLang's hierarchical cache, which extends the radix-tree prefix cache from GPU memory to host memory and storage backends like Mooncake and 3FS.
kvcached Library
Elastic KV cache allocator built on GPU virtual memory, so several vLLM or SGLang models can share one GPU and resize their caches with load.
FlexKV Library
Tencent Cloud's tiered KV cache manager for CPU, SSD, and remote storage, integrated with vLLM, SGLang, TensorRT-LLM, and Dynamo.
VII.2 KV Compression & Eviction 9
KVPress Library
Library of pluggable KV cache pruning methods, called presses, for Hugging Face transformers, with benchmarks to compare them on long-context tasks.
KIVI Paper
Tuning-free 2-bit KV quantization that quantizes keys per channel and values per token, keeping a small full-precision window of recent tokens.
StreamingLLM (Attention Sinks) Paper
Shows that the first tokens act as attention sinks; keeping them plus a sliding window lets models stream past their training length without retraining.
H2O (Heavy-Hitter Oracle) Paper
Evicts KV entries except recent tokens and heavy hitters, the tokens with the largest accumulated attention scores, to cap cache size during generation.
SnapKV Paper
Chooses which prompt positions each attention head keeps by looking at attention from a window at the end of the prompt, compressing the cache before decoding.
KVQuant Paper
Sub-4-bit KV quantization using per-channel keys taken before RoPE, non-uniform datatypes, and a sparse side matrix for outliers.
TurboQuant Paper
Data-oblivious online vector quantizer, a random rotation plus scalar quantizers and a 1-bit residual sketch, applied to low-bit KV caches.
CacheGen Paper
Encodes KV caches into compact bitstreams and adapts their quality to available bandwidth, cutting the time to load long contexts over the network.
Explains FP8 KV cache in vLLM, including per-tensor and per-head scales and how to calibrate them with llm-compressor.
VII.3 Prefix & Prompt Caching 5
SGLang: Efficient Execution of Structured Language Model Programs Paper
Introduces RadixAttention, which keeps KV caches in a radix tree for automatic prefix reuse across requests, with LRU eviction and cache-aware scheduling.
vLLM Automatic Prefix Caching Docs
Design notes on vLLM's hash-based prefix cache, where each block's key chains its own tokens with its prefix and free blocks are evicted in LRU order.
CacheBlend Paper
Reuses precomputed KV caches for non-prefix chunks such as RAG documents, recomputing a small set of tokens to restore cross-chunk attention.
Prompt Cache Paper
Precomputes attention states for prompt modules declared in a schema and reuses them across prompts, even when the modules are not a shared prefix.
Marconi Paper
Prefix caching for hybrid attention and state-space models, with admission and eviction policies that weigh recurrent-state reuse against memory cost.
VII.4 Sparse, Linear & Hybrid Attention 10
Grouped-Query Attention (GQA) Paper
Lets groups of query heads share key-value heads, sitting between multi-head and multi-query attention, and uptrains existing checkpoints to use it.
DeepSeek-V2 (Multi-head Latent Attention) Paper
Introduced multi-head latent attention, which caches one compressed latent vector per token instead of separate keys and values for every head.
flash-linear-attention Library
Triton kernels and layers for linear attention, state-space, and sparse attention variants such as Gated DeltaNet, KDA, and Mamba2.
Multi-Query Attention (MQA) Paper
Shares a single key and value head across all query heads, shrinking the KV cache and the memory traffic of incremental decoding.
Native Sparse Attention (NSA) Paper
Trainable sparse attention with compressed, selected, and sliding-window branches whose block layout is designed for efficient GPU kernels.
DeepSeek-V3.2 (DeepSeek Sparse Attention) Paper
Adds DeepSeek Sparse Attention on top of MLA, where a cheap indexer ranks past tokens and attention runs only over the selected subset.
DeepSeek-V4 (Compressed Sparse Attention) Paper
Preview report on interleaving Compressed Sparse Attention and Heavily Compressed Attention layers to make million-token contexts affordable to serve.
Gated DeltaNet Paper
Linear-attention layer combining Mamba2-style gating with the delta rule, used for the linear layers of hybrid models from Qwen3-Next onward.
Kimi Linear Paper
Hybrid architecture that interleaves Kimi Delta Attention, a gated linear attention, with MLA layers to cut KV cache size for long contexts.
Jenga Paper
Two-level allocator, built on vLLM, that sizes pages by the LCM of layer embedding sizes and lets each layer type set its own caching and eviction.