8 Ways to Reduce KV Cache Memory: What Each Actually Saves
Compare MQA, GQA, MLA, windows, attention sinks, paging, prefix reuse and KV quantization with worked memory examples and a practical decision diagram.
BY RUIQI ZHOU · AIINFRAINTERVIEWS EDITORIAL · UPDATED NOVEMBER 24, 2026 · 4 MIN READ
PRACTICE THIS:Calculate KV payload ·Practice the attention comparison ·Study Inference Engineering
Eight familiar KV-cache techniques solve different problems. MQA, GQA and MLA change the state representation; sliding windows and attention sinks limit retained history; quantization reduces element width; paging reduces allocation waste; prefix caching avoids repeated state and prompt computation. Choose the technique from the memory term that is actually limiting your service.
This guide connects those choices with one worked example. It is a decision map for existing checkpoints and new model designs, not a claim that every method can be enabled on every model. The underlying mechanisms are developed in Attention Variants and KV Cache Sizing.
Start with the bytes you retain
For a uniform decoder with separate keys and values:
KV payload = 2 × layers × KV heads × head dimension × bytes/element × retained tokens
Use a hypothetical 32-layer model with 32 query heads, 8 KV heads, head dimension 128 and two-byte cache elements. At 8,192 retained tokens, one sequence uses 2×32×8×128×2×8,192 = 1,073,741,824 bytes = 1 GiB. Its payload rate is 128 KiB per retained token. This excludes weights, scales, allocator metadata, workspaces and other model state.
The formula assumes every layer retains the same positions. For mixed local and full attention, sum each layer's retained state instead. A compressed latent cache needs its own layout formula; substituting a fictional “fractional KV head” obscures what the engine stores.
| Method | What changes | Condition or cost |
|---|---|---|
| MQA | One KV head serves all query heads | Architecture choice; evaluate learned quality |
| GQA | Several query heads share each KV head | Checkpoint must implement the grouping |
| MLA | Retain a compressed latent and required positional state | Needs compatible architecture and cache kernels |
| Sliding window | Keep a bounded recent history in local layers | Earlier state is unavailable to those layers |
| Attention sinks | Keep selected initial positions plus recent state | Streaming stability does not restore discarded facts |
| PagedAttention | Allocate fixed blocks as a sequence grows | Block tails and metadata still occupy memory |
| Prefix caching | Share compatible leading state across requests | Requires a matching prefix and resident reusable blocks |
| KV quantization | Use fewer bits per stored element | Scales, kernels and quality must be checked |
1–3. Change representation at the model boundary
Multi-query attention (MQA) shares one KV head across the query heads. Grouped-query attention (GQA) uses an intermediate number. In the hypothetical geometry, MHA with 32 KV heads would require 4 GiB; GQA with eight needs 1 GiB; MQA with one needs 128 MiB. Those ratios hold because the other inputs remain fixed.
The GQA paper describes converting and uptraining multi-head checkpoints. That is a training intervention. Editing a released checkpoint's head-count field is not an equivalent conversion, and the paper's quality result does not guarantee parity for an arbitrary model or task.
Multi-head latent attention (MLA) retains a compressed representation rather than ordinary full K/V tensors in a supported implementation. The DeepSeek-V2 report explains this architecture. Include the positional component and check whether the runtime actually keeps the compressed form. An engine that expands and retains full state can erase the expected memory advantage. MLA and Sparse Indexers separates storage compression from selecting positions for attention.
4–5. Reduce retained history deliberately
A sliding window keeps recent positions for local-attention layers. If every layer in our toy layout truly retained only 2,048 positions, the payload would be 256 MiB. A mixed stack still has a growing full-attention component. A mask that hides old positions also does not prove their backing memory was reclaimed.
Attention sinks retain a small initial set plus a recent window. The StreamingLLM research motivates preserving initial positions to stabilize windowed generation. Those positions need not summarize the discarded middle. A stable long-running conversation can still fail a question about a fact removed from its cache.
Choose a bounded-history policy when the application tolerates that context restriction and evaluation confirms it. Keep accessible history, or retrieve relevant information again, when the task requires precise earlier evidence. Test a fact placed just outside the retention boundary; smooth generation is too weak a correctness check.
6. Recover allocation waste with paging
PagedAttention maps logical positions to separate physical blocks. The original paper targets fragmentation and redundant duplication. Paging does not, by itself, reduce the K/V values needed for one token.
Suppose blocks contain 16 positions. A 33-token sequence needs three blocks, reserving 48 positions. With our 128 KiB payload per position, useful state is 4.125 MiB and reserved block payload is 6 MiB. Tail waste is 1.875 MiB. This still beats reserving an entire 8,192-position slab for that short request, but it is not zero waste. Smaller blocks can reduce tails while increasing block-table and management costs.
7. Share a compatible prefix once
Imagine eight simultaneous 8,192-token requests whose first 6,144 tokens are identical and reusable. With ideal sharing and aligned full blocks:
without sharing = 8 × 8,192 = 65,536 physical token positions = 8 GiB
with sharing = 6,144 + 8 × 2,048 = 22,528 positions = 2.75 GiB
saving = 5.25 GiB, or 65.625% of this payload
That is a physical sharing model, not a promise derived from text similarity. Token IDs, model/adapters, position handling and other cache-key inputs must be compatible. The blocks must still be resident or worth reloading. Prefix Caching and KV Reuse explains those boundaries. The versioned vLLM documentation describes prompt-computation reuse; generated tokens still need their own decoding work.
8. Quantize the cache separately from weights
Changing two-byte KV elements to one-byte elements halves the raw payload: the original sequence becomes 512 MiB before scales and overhead. That does not establish a twofold reduction in total device memory, because weights and workspaces remain. Nor does a four-bit weight file prove the cache uses four bits.
The vLLM 0.11.0 FP8 cache documentation discusses supported formats and scaling. Use documentation for your installed release and backend. Inspect the executed cache dtype, calibration/scales and long-context quality rather than inferring support from the GPU name.
Step 1 of 4: Measure the pool
- Measure the pool
Separate useful retained payload, shared blocks, tail waste and inactive cached state.
- Identify the available change
For a fixed checkpoint, begin with compatible runtime allocation, reuse and precision options.
- Run one controlled comparison
Keep prompts, arrival times, output policy and hardware fixed. Check quality and completion failures.
- Admit more work only after measuring
Record peak memory, preemptions, queue wait and useful completions within the latency target.
Prefer the lowest-risk compatible change that addresses measured pressure. Reverse it when quantization harms the task, prefix retention displaces more valuable active work, or a local window removes needed evidence. The useful result is additional correct requests within their latency budget, not the largest theoretical compression ratio.
Turn it into offers. Work the real questions and concepts this maps to:
FAQ
Paging changes allocation and allows flexible sharing. It reduces wasted reservation and fragmentation but does not inherently reduce the values required per retained token. Representation and precision changes address that payload.
No. GQA is part of the model architecture. Converting a multi-head checkpoint requires a supported transformation and training or adaptation with quality evaluation, not only changing a serving flag.
Prefix caching saves repeated computation for compatible prompt tokens. Subsequent generated tokens still require decoding and attention to the retained history. Benefits depend on prefix hits, residency and workload.
No. Keeping initial positions and recent history can stabilize streaming generation, but discarded middle positions are no longer directly available. Evaluate retrieval and factual recall separately.
Discussion (3)
Report active references and retained idle prefixes separately. A cache full of reusable state may be healthy, while a smaller pool that repeatedly evicts useful prefixes can cause more work.
The block-tail example assumes one independent sequence. Shared partial blocks and copy-on-write policies change the reservation accounting; state the allocator policy before comparing totals.
Put the answer-bearing fact immediately outside the window in one test. A fluent response to an easy recent question cannot qualify the retention policy.
