Context window VRAM calculator

Long context windows eat GPU memory fast. Enter your model, context length, batch size, and total cluster VRAM to see exact KV cache growth from 4K to 1M tokens and the maximum OOM-safe context length for your hardware.

Interactive calculator

Context LengthKV / SequenceKV (Batch)Total VRAMFits Pool?

Frequently asked questions

Why does a 128K context window cause OOM even when model weights easily fit?

KV cache grows linearly with context length and concurrent batch size. For Llama 3.3 70B in FP16 KV precision (320 KiB/token), a single 128K sequence consumes 40 GiB of VRAM on top of model weights — and 8 concurrent 128K requests require 320 GiB of KV cache alone.

How does Multi-head Latent Attention (MLA) in DeepSeek-V3 shrink context VRAM?

Instead of caching full K and V heads per layer, DeepSeek-V3 compresses KV into a shared 512-dim latent vector plus a 64-dim RoPE key (576 dims total per layer). That drops FP16 KV cache to just ~70.2 KB/token across 61 layers — roughly 4.5x smaller than Llama 3.3 70B.

How much extra context does FP8 KV cache unlock?

Switching KV cache from FP16/BF16 (2 bytes/element) to FP8 E4M3 (1 byte/element) cuts KV memory in half, effectively doubling your maximum context length or maximum concurrent batch size with minimal quality impact.

Does sliding-window attention reduce context VRAM?

Yes. Models with hybrid local/global attention (such as Gemma 3 or Llama 4 Scout) cap KV cache on local-attention layers at the sliding window size, so only global attention layers grow linearly with full context length.

How do I compute per-token KV cache for a custom GQA model?

Multiply 2 × num_layers × num_kv_heads × head_dim × bytes_per_element. For example, 80 layers × 8 KV heads × 128 head_dim × 2 × 2 bytes = 327,680 bytes (320 KiB) per token in FP16.

All calculations run locally in your browser. Usable VRAM reserves 8% for CUDA graphs, PagedAttention block tables, and runtime activations.