The Physics of LLM Serving: Why Naive VRAM Calculators Cause OOM Crashes
Most developers estimate GPU memory simply by multiplying model parameter count by precision bytes: for instance, a 70B parameter model in FP16 weighs approximately 140 GiB. However, deploying that model on two 80GB A100 GPUs (160 GiB total VRAM) will immediately crash with an Out-of-Memory (OOM) error the moment real user traffic arrives.
In production LLM inference engines like vLLM, TGI, and TensorRT-LLM, VRAM is divided into three distinct arenas:
1. Static Weight Memory
Fixed memory footprint determined by parameter count and quantization format (16-bit = 2.0 B/param, 8-bit = 1.0 B/param, 4-bit = ~0.55 B/param).
2. Dynamic KV Cache
The Key-Value tensor cache grows linearly with context length and concurrent streams:2 × Layers × KV_Heads × Head_Dim × Precision × Context × Concurrency.
3. CUDA Runtime & PagedAttention
PyTorch runtime, CUDA kernels, scratchpad intermediate activations, and KV block allocation tables reserve 1.5 to 2.5 GiB per GPU device.
Production Architectural Guidelines
- Llama 3.3 70B (AWQ 4-Bit) on 2x L40S (96 GB):Fits model weights (~40 GB) + leaves over 48 GB dedicated entirely to KV cache, supporting up to 32 concurrent 16k context streams.
- DeepSeek R1 671B MoE on 8x H100 (640 GB):Requires FP8 quantization and Tensor Parallelism = 8. Uses DeepSeek MLA (Multi-head Latent Attention) to drastically compress KV cache dimensions.
- High-Concurrency API Servers:Always enable
--kv-cache-dtype fp8in vLLM to double the concurrent request capacity without degrading generation perplexity.