9io.ai / Blog

KV cache memory: how much GPU memory long context needs

KV cache memory per token for GQA, MLA and hybrid models, worked from seven real configs, and how FP8, tensor parallelism and DCP change GPU sizing.

Key takeaways

  • GQA models cache 2 × layers × KV heads × head_dim values per token.
  • Across seven open models, one 128K session needs 1.3 GB to 34 GB of BF16 KV cache.
  • MLA caches 576 values per layer, but tensor parallelism keeps the whole cache on every GPU.
  • Decode context parallelism took Mistral Large 4 from 2.38M to 18.88M cached tokens on eight GB300s.
  • Size for concurrent sessions times real context length, in the KV dtype your engine really uses.

KV cache memory is bytes per token × tokens per session × concurrent sessions, and the bytes per token come from a model’s config.json. For a grouped-query attention (GQA) model it is 2 × layers × KV heads × head dimension × bytes per value. Across seven open models, one 128K-token session needs between 1.3 GB (DeepSeek-V4-Pro) and 34 GB (Qwen3-32B) in BF16. Parameter count is a poor guide. The 1-trillion-parameter Mistral Large 4 needs less cache per token than the 32-billion-parameter Qwen3-32B.

The serving engine changes the total. It picks the cache’s data type, rounds sequences up to whole blocks, can share identical prefixes, and under tensor parallelism may copy the whole cache to every GPU, which hurts multi-head latent attention (MLA) models most.

Below are the formulas, a seven-model table, a Python calculator, the engine settings that move the total and a sizing checklist. We haven’t run these models. Per-token figures are our arithmetic from configs read on 5 November 2026, and capacity measurements are vLLM’s and SGLang’s.

The KV cache memory formula for MHA and GQA

A decoder generates one token at a time, and every layer’s attention needs the keys and values of all earlier tokens. Engines keep those vectors in GPU memory instead of recomputing them. Each layer stores one key and one value per KV head, each head_dim values long.

bytes per token = 2 × layers × KV heads × head_dim × bytes per value
total bytes     = bytes per token × tokens per session × concurrent sessions

In multi-head attention (MHA) every query head has its own KV head. The PagedAttention paper’s example, OPT-13B, needs 2 × 5,120 × 40 layers × 2 bytes, or 800 KB per token.1 Grouped-query attention lets each group of query heads share one KV head, which shrinks the cache by the group size, and multi-query attention (MQA) uses a single KV head per layer.2

Qwen3-32B has 64 query heads and 8 KV heads of 128 dimensions. It needs 2 × 64 layers × 8 × 128 × 2 bytes = 262,144 bytes per token in BF16, an eighth of the MHA figure.3 Take head_dim from the config. Qwen3-32B’s hidden size divided by its query heads gives 80, which would understate the cache by 37.5%.

MLA vs GQA: one latent per layer instead of heads

Multi-head latent attention, introduced with DeepSeek-V2, caches one compressed latent vector per token per layer. The projections that expand it into keys and values fold into the query and output weights, so attention runs on the latent directly.4 Rotary position embeddings don’t survive that folding, so MLA also caches a small RoPE key that all heads share. The paper puts the cache at (d_c + d_h^R) × layers values per token, equal to GQA with 2.25 groups at its settings, and reports 93.3% less KV cache than DeepSeek’s earlier 67B dense model.

In config.json the two sizes are kv_lora_rank (d_c) and qk_rope_head_dim (d_h^R). DeepSeek-V3.2 and Mistral Large 4 both use 512 and 64, so each MLA layer stores 576 values, or 1,152 bytes in BF16, against 1,024 values for a Qwen3-235B-A22B layer.56 vLLM’s FP8 layout takes 656 bytes per layer, because it adds four FP32 scale factors and keeps the 64 RoPE values in BF16 for accuracy.7

Ignore num_key_value_heads for MLA models. DeepSeek-V3.2’s config says 128, but nothing per head is cached, and feeding that into the GQA formula overstates the cache 20 to 50 times. Under tensor parallelism the comparison shifts, because a single latent can’t be split across GPUs the way GQA heads can.

Sparse indexers, shared layers and compressed layers

Sparse attention adds a cache of its own. DeepSeek-V3.2’s lightning indexer scores earlier tokens and keeps the top 2,048 for each query, and it needs its own 128-value key per token in every layer.7 vLLM stores each one as FP8 values plus a 4-byte scale, 132 bytes, whatever the main cache’s dtype.8 Across DeepSeek-V3.2’s 61 layers that adds 8,052 bytes per token, about a sixth of its FP8 total.

Mistral Large 4’s config lists 72 layers, but kv_source_layers points nine of them at layer 35’s latent, and indexer_types gives only 44 layers an indexer.6 Counting from those fields gives 63 × 656 + 44 × 132 = 47,136 bytes per token in FP8 and 78,384 in BF16, the two figures vLLM publishes.8

DeepSeek V4 also compresses along the sequence. In DeepSeek-V4-Pro, compress_ratios gives 30 layers one entry per 4 tokens, with a sparse indexer, and 31 layers one entry per 128 tokens.9 Every layer also keeps a 128-token window of raw tokens, and one 512-value vector serves as both key and value.10 vLLM puts the BF16 cache at 9.62 GiB for a 1M-token sequence, 8.7 times smaller than a 61-layer DeepSeek-V3.2-style stack, and about half that with FP8 attention and an FP4 indexer cache.

Layers that keep only a window or a fixed state

A sliding-window layer attends only to the last W tokens, so its cache stops growing at W tokens. vLLM’s hybrid KV cache manager reserves only the window for such layers.11 gpt-oss-120b alternates 18 window layers of 128 tokens with 18 full-attention layers, all with 8 KV heads of 64 dimensions.12 Only the full layers grow, so a token costs 36,864 bytes in BF16, plus about 4.7 MB per sequence for the windows.

Muse Spark Open keeps a 2,048-token window in 46 of its 62 layers, which vLLM says brings its 1M-token cache to just over a quarter of full attention.13 With the model card’s 16 KV heads of dimension 64, that is about 69 GB per 1M-token session in BF16.14 Our Muse Spark Open post gave 266 GB as an upper bound before the layer split was published.

Linear-attention hybrids swap most attention layers for recurrent ones with a fixed-size state. Qwen3.5-397B-A17B has 45 Gated DeltaNet layers and 15 full-attention layers with 2 KV heads of 256, so its growing cache is 30,720 bytes per token in BF16.15 Each DeltaNet layer keeps a 64 × 128 × 128 state per sequence, in FP32 as the config’s mamba_ssm_dtype asks, plus a small convolution buffer.16 By our arithmetic that is about 192 MB per sequence at any length, under 5% of a 128K session’s total but about 43% at 8K tokens.

Long-context GPU memory for seven open models

Model Attention Values read from config.json Layers that keep every token Context limit
Qwen3-32B Dense, GQA 64 layers, 8 KV heads, head_dim 128 64 40,960 in config; 131,072 with YaRN
Qwen3-235B-A22B-Instruct-2507 MoE, GQA 94 layers, 4 KV heads, head_dim 128 94 262,144; 1,010,000 with Qwen’s 1M config
gpt-oss-120b MoE, GQA with a 1:1 sliding window 36 layers (18 sliding, 18 full), 8 KV heads, head_dim 64, window 128 18 131,072
Qwen3.5-397B-A17B MoE, Gated DeltaNet and GQA, 3:1 60 layers (45 linear, 15 full), 2 KV heads, head_dim 256 15 262,144; extensible to 1,010,000
DeepSeek-V3.2 MoE, MLA with a DSA indexer 61 layers, latent 512, RoPE 64, indexer 128 61 163,840
Mistral Large 4 MoE, MLA with DSA and cross-layer KV sharing 72 layers, 9 reuse layer 35, 44 own an indexer, latent 512, RoPE 64, indexer 128 63 1,048,576
DeepSeek-V4-Pro MoE, compressed sparse attention with a 128-token window 61 layers (30 at 1/4, 31 at 1/128), 512-value shared key and value, indexer 128 61, compressed 1,048,576

Values from the config.json files, with context limits from the model cards, read 5 November 2026.3171215569

Model Bytes per token, BF16 Bytes per token, FP8 One 128K session, BF16 One 128K session, FP8 One session at the 1M limit, BF16 / FP8
Qwen3-32B 262,144 131,072 34.4 GB 17.2 GB Not supported
Qwen3-235B-A22B-2507 192,512 96,256 25.2 GB 12.6 GB 194 GB / 97 GB
gpt-oss-120b 36,864, plus 4.7 MB per sequence 18,432, plus 4.7 MB 4.8 GB 2.4 GB Not supported
Qwen3.5-397B-A17B 30,720, plus 192 MB per sequence 15,360, plus 192 MB 4.2 GB 2.2 GB 31 GB / 16 GB
DeepSeek-V3.2 78,324 48,068 10.3 GB 6.3 GB Not supported
Mistral Large 4 78,384 47,136 10.3 GB 6.2 GB 82 GB / 49 GB
DeepSeek-V4-Pro About 9,850, averaged About half 1.3 GB About 0.65 GB 10.3 GB / about 5 GB

Our arithmetic. 128K is 131,072 tokens, the 1M column uses each model’s limit (1,010,000 tokens for the Qwen models) and GB is 10^9 bytes. FP8 means 1 byte per value for GQA and vLLM’s 656-byte layout for MLA, with indexer keys at 132 bytes in both columns. Session figures include fixed per-sequence costs, and DeepSeek-V4-Pro’s FP8 figures are vLLM’s “roughly half”. Where vLLM publishes a figure for these models, ours matches it.

Per layer, a cache entry in these models holds 512 to 2,048 values. The 26-fold spread at 128K comes from how many layers keep every token, whether they use MLA, and for DeepSeek V4 how many tokens share an entry. Qwen’s model card estimates about 1,000 GB of total GPU memory for Qwen3-235B-A22B at 1M tokens, of which our arithmetic puts 194 GB in the BF16 KV cache.17

A KV cache size calculator in Python

The first function returns bytes per token from a config.json, and the second converts that to gigabytes per GPU.

import json

def kv_bytes_per_token(cfg, bytes_per_value=2):
    """KV cache bytes one token adds, counting only layers that keep every token."""
    c = cfg.get("text_config", cfg)
    n = c["num_hidden_layers"]
    kinds = c.get("layer_types") or ["full_attention"] * n
    layers = sum(k in ("full_attention", "indexed_attention") for k in kinds)
    layers -= sum(s != i for i, s in enumerate(c.get("kv_source_layers", [])))  # shared KV
    if "kv_lora_rank" in c:  # MLA: one latent vector plus one shared RoPE key
        per_layer = c["kv_lora_rank"] + c["qk_rope_head_dim"]
    else:                    # MHA/GQA: a key and a value for each KV head
        head_dim = c.get("head_dim") or c["hidden_size"] // c["num_attention_heads"]
        per_layer = 2 * c["num_key_value_heads"] * head_dim
    total = layers * per_layer * bytes_per_value
    if "index_head_dim" in c:  # DSA indexer keys: FP8 values plus a 4-byte scale
        indexers = c.get("indexer_types", ["full"] * n).count("full")
        total += indexers * (c["index_head_dim"] + 4)
    return total

def kv_gb_per_gpu(cfg, tokens, sessions, tp=1, dcp=1, bytes_per_value=2):
    c = cfg.get("text_config", cfg)
    heads = 1 if "kv_lora_rank" in c else c["num_key_value_heads"]
    total = kv_bytes_per_token(cfg, bytes_per_value) * tokens * sessions
    return total / (min(tp, heads) * dcp) / 1e9  # TP splits heads, DCP splits tokens

cfg = json.load(open("config.json"))
print(kv_bytes_per_token(cfg), kv_gb_per_gpu(cfg, 131_072, sessions=16, tp=8))

It handles four config details that trip up simpler calculators.

  • Qwen3 and gpt-oss set head_dim explicitly, and it doesn’t equal hidden size divided by heads.
  • MLA’s num_key_value_heads counts heads after the up-projection, which aren’t cached.
  • layer_types marks window and linear-attention layers, which don’t grow.
  • Multimodal checkpoints such as Qwen3.5 and Mistral Large 4 nest the fields under text_config.

It also subtracts shared layers and adds DSA indexer keys, which reproduces vLLM’s 78,384-byte BF16 figure for Mistral Large 4. It leaves out fixed per-sequence costs and gets DeepSeek V4 wrong, since it knows nothing about sequence compression. Setting bytes_per_value=1 gives plain FP8 without scale overhead.

FP8 KV cache and the defaults engines pick

FP8 halves the bytes per value, and vLLM and SGLang both offer E4M3 and E5M2 through --kv-cache-dtype.1819 Layouts that keep scales or the RoPE part in higher precision gain a little under 2×. SGLang’s Mistral Large 4 cookbook gives about 2.49M tokens of FP8 cache on eight B300s at --mem-fraction-static 0.85, against 1.34M in BF16.20

Defaults vary by engine, model and GPU, as of 5 November 2026. vLLM’s auto uses the model’s dtype, usually BF16, though DeepSeek-V3.2 and Mistral Large 4 default to an FP8 latent cache.218 SGLang’s Mistral Large 4 recipe defaults to FP8 on Blackwell and Vera Rubin and to BF16 on Hopper, so a Hopper deployment that copies a Blackwell plan can get about half the tokens it expected.20 vLLM logs the pool size in tokens at startup.22

In vLLM’s April 2026 tests, uncalibrated FP8 KV cache with FP8 attention recovered 97% to 98% of the baseline long-context score at 128K on Llama-3.3-70B and matched the baseline at 1M tokens on Qwen3.5-27B.23 The same post describes a Hopper kernel problem that had dropped FP8 accuracy on a 128K needle-in-a-haystack test to 13%, against 91% in BF16, until a fix brought it back to 89%. Run a recent engine version. The post also recommends keeping small sliding-window layers in BF16 with --kv-cache-dtype-skip-layers sliding_window. It warns that head_dim 256 models such as Qwen3.5 still prefill more slowly in FP8 on Hopper, and suggests calibrated scales when a model drifts down steadily, as Kimi-K2.5 did.

Block size and prefix caching

PagedAttention stores each sequence’s cache in fixed-size blocks allocated on demand, so a sequence wastes at most part of its last block. Earlier systems reserved the maximum length up front and used only 20.4% to 38.2% of their KV memory for real tokens.1 The paper used 16-token blocks. vLLM’s DeepSeek-V3.2 support launched with 64-token blocks only, and its DeepSeek V4 support uses 256-token logical blocks.710 Under DCP4 a 16-token block covers 64 tokens, and hybrids with large recurrent states can push attention blocks past 400 tokens.2411 Even 64-token blocks waste at most about 3 MB per Mistral Large 4 session, so block size matters only for many short sessions or very large blocks.

Prefix caching matters more. vLLM hashes each full block with all the tokens before it, so requests that start with identical tokens share the same reference-counted blocks, and a shared system prompt is stored once while its sessions are live.25 Sixty-four agent sessions of 100K tokens sharing a 20K-token prefix need 5.14M tokens of cache instead of 6.4M. Finished requests’ blocks stay cached until space runs short and then go least recently used first, so caching costs no capacity.

A match has to start at the first token, so a timestamp at the top of a system prompt defeats it. For multi-tenant serving, vLLM’s per-request cache_salt keeps tenants from sharing blocks.25 SGLang’s session-aware radix cache evicts KV that no active session references before KV that one does.26

Tensor parallelism, MLA and decode context parallelism

Tensor parallelism splits the KV cache by attention head. For GQA that works until TP passes the number of KV heads, after which each head is stored on TP ÷ heads GPUs. MLA has a single latent per layer, so every GPU keeps a full copy, and DeepSeek-R1 at TP8 stores its cache eight times over.24

One 128K session at TP8 Copies of each cache entry Per GPU, BF16 Per GPU, FP8 Largest DCP size Per GPU, FP8, with that DCP
Qwen3-32B, 8 KV heads 1 4.3 GB 2.1 GB 1 2.1 GB
Qwen3-235B-A22B, 4 KV heads 2 6.3 GB 3.2 GB 2 1.6 GB
DeepSeek-V3.2, MLA 8 10.3 GB 6.3 GB 8 0.8 GB
Mistral Large 4, MLA 8 10.3 GB 6.2 GB 8 0.8 GB

Our arithmetic. The DCP column assumes the whole cache shards, as in vLLM’s Mistral Large 4 measurement.

At TP8 without DCP, Mistral Large 4 in FP8 needs about as much memory per GPU for a 128K session as Qwen3-235B-A22B in BF16, although its total cache is a quarter of the size.

Decode context parallelism shards the cache by token position instead. Each of c ranks keeps every c-th token, and the ranks merge their partial attention results.27 It reuses the TP ranks, and its size can reach the TP size for MLA or TP ÷ KV heads for GQA.24

On eight GB300s at TP8, vLLM measured DCP8 raising Mistral Large 4’s KV pool from 2.38M to 18.88M tokens in FP8, and from 3.60M to 28.76M with the NVFP4 checkpoint.8 By our arithmetic, the FP8 setup goes from 18 full 128K sessions to 144, or from 2 full 1M sessions to 18. With NVFP4, DCP8 decoded 16% to 28% slower per output token, and at up to 128 concurrent requests of 8K to 60K tokens TP8’s pool never filled, so plain TP8 had more throughput. With agentic sessions of about 100K tokens, a TP4 decode node ran out of KV cache at 32 sessions and its time to first token rose to 15 s, while TP4 with DCP4 held 0.7 s. vLLM’s DCP post saw the same with Kimi K2.6 on eight B200s, where DCP reached 6,091 tokens per second per GPU at 512 requests against a plateau near 1,863 for plain TP.28

Some caches stay replicated. SGLang keeps the speculative draft model’s cache on every rank, along with the DSA indexer keys, which take about 6% of each rank’s KV budget at DCP2 and 17% at DCP4 on GLM-5.3.27 Beyond DCP, vLLM’s HiSparse keeps the full latent cache in host memory and copies in the rows the indexer selects. With a 440 GiB host pool it took one GB300 node at TP4 from 1.97M tokens to between 8.77M and 11.25M.8 Our Mistral Large 4 post covers its hardware and cost.

A sizing checklist

  1. Compute bytes per token from config.json for the layers that keep every token, plus any indexer keys. Add fixed per-sequence costs for windows, recurrent state and draft models.
  2. Use the KV dtype your engine will really use on your GPU, and confirm it in the startup log.
  3. Measure real context length per session and plan on a high percentile, since agent sessions grow every turn. The agentic trace in vLLM’s DCP post had a median input near 67K tokens and about 8% of requests above 128K.28
  4. Multiply concurrent sessions by those lengths and by bytes per token. Count a shared prefix once if prefix caching is on and the prefix is identical token for token.
  5. Divide by the sharding, which is min(TP, KV heads) × DCP for GQA and the DCP size alone for MLA.
  6. Work out free memory per GPU as memory × the engine’s utilisation setting, minus weights per GPU, activations, CUDA graphs and runtime buffers. Trust the pool size the engine reports over your estimate.
  7. Leave headroom. When the pool runs out, vLLM preempts requests and recomputes them later, which shows up as latency spikes.29
  8. If it doesn’t fit, try an FP8 KV cache first, then DCP, then host offload, then a shorter maximum context or more GPUs.

Steps 1 to 5 take an hour with the calculator above. Step 6 needs the model loaded once on the target hardware.


  1. Kwon et al., “Efficient Memory Management for Large Language Model Serving with PagedAttention”, SOSP 2023, https://arxiv.org/abs/2309.06180 ↩↩

  2. Ainslie et al., “GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints”, 2023, https://arxiv.org/abs/2305.13245 ↩

  3. Qwen, Qwen3-32B config.json and model card, Hugging Face, read 5 November 2026, https://huggingface.co/Qwen/Qwen3-32B/raw/main/config.json and https://huggingface.co/Qwen/Qwen3-32B ↩↩

  4. DeepSeek-AI, “DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model”, 2024, https://arxiv.org/abs/2405.04434 ↩

  5. DeepSeek, DeepSeek-V3.2 config.json, Hugging Face, read 5 November 2026, https://huggingface.co/deepseek-ai/DeepSeek-V3.2/raw/main/config.json ↩↩

  6. Mistral AI, Mistral-Large-4-1T-A52B config.json, Hugging Face, read 5 November 2026, https://huggingface.co/mistralai/Mistral-Large-4-1T-A52B/raw/main/config.json ↩↩↩

  7. vLLM, “DeepSeek-V3.2-Exp in vLLM: Fine-Grained Sparse Attention in Action”, 29 September 2025, https://vllm.ai/blog/2025-09-29-deepseek-v3-2 ↩↩↩

  8. vLLM, “Day 0 support for Mistral Large 4 on vLLM”, 29 October 2026, https://vllm.ai/blog/2026-10-29-mistral-large-4 ↩↩↩↩↩

  9. DeepSeek, DeepSeek-V4-Pro config.json, Hugging Face, read 5 November 2026, https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro/raw/main/config.json ↩↩

  10. vLLM, “DeepSeek V4 in vLLM: Efficient Long-context Attention”, 24 April 2026, https://vllm.ai/blog/2026-04-24-deepseek-v4 ↩↩

  11. vLLM docs, “Hybrid KV Cache Manager”, read 5 November 2026, https://docs.vllm.ai/en/latest/design/hybrid_kv_cache_manager.html ↩↩

  12. OpenAI, gpt-oss-120b config.json, Hugging Face, read 5 November 2026, https://huggingface.co/openai/gpt-oss-120b/raw/main/config.json ↩↩

  13. vLLM, “Day 0 support for Muse Spark Open on vLLM”, 15 October 2026, https://vllm.ai/blog/2026-10-15-muse-spark-open ↩

  14. Meta, Muse-Spark-Open-816B-A42B model card, Hugging Face, read 5 November 2026, https://huggingface.co/meta-models/Muse-Spark-Open-816B-A42B ↩

  15. Qwen, Qwen3.5-397B-A17B config.json and model card, Hugging Face, read 5 November 2026, https://huggingface.co/Qwen/Qwen3.5-397B-A17B/raw/main/config.json and https://huggingface.co/Qwen/Qwen3.5-397B-A17B ↩↩

  16. vLLM source, mamba_utils.py (Gated DeltaNet state shape), read 5 November 2026, https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/layers/mamba/mamba_utils.py, and models/config.py (Qwen3.5 state dtype), https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/config.py ↩

  17. Qwen, Qwen3-235B-A22B-Instruct-2507 config.json and model card, Hugging Face, read 5 November 2026, https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507/raw/main/config.json and https://huggingface.co/Qwen/Qwen3-235B-A22B-Instruct-2507 ↩↩

  18. vLLM docs, “Quantized KV Cache”, read 5 November 2026, https://docs.vllm.ai/en/latest/features/quantization/quantized_kvcache.html ↩

  19. SGLang docs, “Quantized KV Cache”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/quantized_kv_cache.md ↩

  20. SGLang, Mistral Large 4 cookbook, read 5 November 2026, https://docs.sglang.io/cookbook/autoregressive/Mistral/Mistral-Large-4.md ↩↩

  21. vLLM docs, “Engine Arguments”, read 5 November 2026, https://docs.vllm.ai/en/latest/configuration/engine_args.html ↩

  22. vLLM source, kv_cache_utils.py, read 5 November 2026, https://github.com/vllm-project/vllm/blob/main/vllm/v1/core/kv_cache_utils.py ↩

  23. vLLM, “The State of FP8 KV-Cache and Attention Quantization in vLLM”, 22 April 2026, https://vllm.ai/blog/2026-04-22-fp8-kvcache ↩

  24. vLLM docs, “Context Parallel Deployment”, read 5 November 2026, https://docs.vllm.ai/en/latest/serving/context_parallel_deployment.html ↩↩↩

  25. vLLM docs, “Automatic Prefix Caching” design notes, read 5 November 2026, https://docs.vllm.ai/en/latest/design/prefix_caching.html ↩↩

  26. SGLang docs, “Session-Aware Radix Cache”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/session_radix_cache.md ↩

  27. SGLang docs, “Decode Context Parallelism”, read 5 November 2026, https://docs.sglang.io/docs/advanced_features/dcp.md ↩↩

  28. vLLM, “Efficient Decode Context Parallelism with vLLM for Long Context Workloads”, 7 August 2026, https://vllm.ai/blog/2026-08-07-decode-context-parallelism ↩↩

  29. vLLM docs, “Optimization and Tuning”, read 5 November 2026, https://docs.vllm.ai/en/latest/configuration/optimization.html ↩

Frequently asked questions

How much GPU memory does the KV cache need for 128K context?

It depends on the attention design more than the model size. For the seven open models we worked through, one 131,072-token session needs between 1.3 GB (DeepSeek-V4-Pro) and 34 GB (Qwen3-32B) of KV cache in BF16, and roughly half that with an FP8 KV cache.

How do you calculate KV cache size?

For a GQA model, bytes per token are 2 × full-attention layers × KV heads × head_dim × bytes per value. Multiply by tokens per session and by concurrent sessions. MLA models cache kv_lora_rank + qk_rope_head_dim values per layer instead, plus any sparse-indexer keys.

MLA vs GQA: which uses less KV cache?

MLA uses less per token. DeepSeek-style models store 576 values per layer, against 1,024 or more for typical GQA layers. Under tensor parallelism every GPU keeps a full copy of the MLA cache while GQA heads are split, so per GPU the gap can reverse unless you use decode context parallelism.

Does FP8 KV cache reduce accuracy?

Usually only slightly. In vLLM’s April 2026 tests, uncalibrated FP8 KV cache recovered 97% to 98% of the baseline long-context score at 128K on Llama-3.3-70B and matched the baseline at 1M tokens on Qwen3.5-27B. Kimi-K2.5 showed a steady small drop, and vLLM recommends calibrated scales in cases like that.

Why doesn’t tensor parallelism reduce the KV cache for DeepSeek models?

MLA stores one latent vector per layer that all attention heads share, so there are no heads to split. Every GPU in the tensor-parallel group keeps the whole cache. Decode context parallelism fixes this by giving each GPU every Nth token of each sequence.

How many concurrent long-context sessions can one GPU node serve?

Divide the free KV memory by the per-GPU size of one session at its real length. vLLM’s measured KV pool for Mistral Large 4 on eight GB300s holds about 18 full 128K sessions in FP8 at TP8 by our arithmetic, and about 144 with decode context parallelism.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO. We work by the hour, and plans start at $5,000. Send us a note about your product. The reply comes from the person who'd do the work.