Total LLM inference VRAM equals Model Weights + Batched KV-Cache + Framework/Activation Overhead (~12%). Specifically, `VRAM_weights = Params * Bytes_per_Param` (2.0 B for FP16/BF16, 1.0 B for FP8/INT8, 0.55 B for INT4/Q4_K_M, 0.35 B for Q2_K), while `VRAM_KV = 2 * Layers * KV_Heads * Head_Dim * KV_Bytes * Context_Tokens * Batch_Size`. At 32K–128K context and high batch concurrency, the dynamic KV-cache often exceeds static weight memory—making GQA and FP8/INT8 KV-cache quantization critical to avoid CUDA out-of-memory faults.
How to Use LLM VRAM & KV-Cache Estimator
- 1Choose a Model Preset or Custom Parameter Count
Click Llama-3 8B, Llama-3 70B, DeepSeek-V3, Qwen-2.5 32B, or Custom to populate parameter count and transformer GQA/MLA KV-cache geometry.
- 2Select Weight Quantization & KV-Cache Precision
Pick FP16/BF16 (2 bytes/param), FP8/INT8 (1 byte/param), INT4/Q4_K_M (~0.55 bytes/param), or Q2_K (~0.35 bytes/param) alongside FP16, FP8, or INT8 KV-cache storage.
- 3Configure Context Window & Concurrent Batch Size
Select 2K, 4K, 8K, 32K, or 128K tokens (or drag the slider) and set concurrent active sequences from 1 to 64.
- 4Audit the Stacked Memory Breakdown & Hardware Fit
Review Total VRAM Required (GB), the stacked bar ratio of Weights vs KV-Cache vs Activation Overhead, and copy a shareable #state=... permalink.
Core Capabilities & Specifications
- 1-click architecture presets for Llama-3 8B, Llama-3 70B, DeepSeek-V3 (671B MoE), Qwen-2.5 32B, and Custom models
- Weight quantization selector covering FP16/BF16, FP8/INT8, INT4/Q4_K_M, and extreme Q2_K GGUF compression
- Interactive context length controls (2K, 4K, 8K, 32K, 128K presets + continuous slider) and concurrent batch size (1–64)
- Visual stacked bar memory breakdown separating Model Weights, KV-Cache, and Framework/Activation Overhead (~12%)
- Live hardware fit cards for 1x RTX 4090 24GB, 1x A100 80GB, 2x H100 80GB, and 8x H100 80GB with green/amber/red indicators
- Shareable #state=... URL permalink generator to bookmark or share exact GPU sizing configurations with your team
First-Principles Equations for LLM Weight & KV-Cache VRAM
Sizing GPU hardware for production LLM serving requires accounting for three distinct memory allocations in high-bandwidth memory (HBM/GDDR6X): static model weights, dynamic per-request KV-cache tensors, and runtime CUDA context plus prefill activation workspace (~12% overhead).
Static model weights scale linearly with total parameters and quantization bit-width. Adding group-wise quantization scale factors and zero-points means practical 4-bit formats like AWQ or GGUF Q4_K_M consume ~0.55 bytes per parameter rather than a theoretical 0.50 bytes.
def estimate_llm_vram_gb(
params_b: float,
weight_bytes: float, # FP16=2.0, FP8=1.0, INT4/Q4_K_M=0.55, Q2_K=0.35
layers: int,
kv_heads: int,
head_dim: int,
kv_bytes: float, # FP16=2.0, FP8=1.0, INT8=1.0
context_len: int,
batch_size: int,
) -> dict:
weights_gb = (params_b * 1e9 * weight_bytes) / (1024 ** 3)
kv_per_token_bytes = 2 * layers * kv_heads * head_dim * kv_bytes
kv_cache_gb = (kv_per_token_bytes * context_len * batch_size) / (1024 ** 3)
overhead_gb = max(1.2, (weights_gb + kv_cache_gb) * 0.12)
total_gb = weights_gb + kv_cache_gb + overhead_gb
return {
"weights_gb": round(weights_gb, 2),
"kv_cache_gb": round(kv_cache_gb, 2),
"overhead_gb": round(overhead_gb, 2),
"total_vram_gb": round(total_gb, 2),
}Why KV-Cache Dominates Long-Context & High-Batch Serving
During autoregressive token generation, every transformer layer caches the Key (K) and Value (V) projections of all preceding tokens so self-attention does not recompute historical activations. Without Grouped-Query Attention (GQA) or Multi-Head Latent Attention (MLA), KV-cache grows explosively with sequence length and batch concurrency.
For example, Llama-3 70B uses 80 layers with 8 GQA KV heads and a 128-dimensional head size (`320 KB/token` in FP16). A single 32K-token session consumes `10.0 GB` of KV-cache alone; at a batch size of 8 concurrent users, the KV-cache requires `80.0 GB`—more than double the 38.5 GB needed for INT4 model weights!
Choosing Between RTX 4090, A100 80GB, and Multi-GPU H100 Nodes
Consumer GPUs such as the NVIDIA RTX 4090 (24 GB GDDR6X, 1,008 GB/s bandwidth) excel at running 8B models in FP16/FP8 or 32B models in INT4/Q4_K_M for low-concurrency workloads. However, once total VRAM exceeds 85% of physical card capacity, memory fragmentation and prefill scratch buffers can trigger sudden CUDA OOM terminations.
Datacenter accelerators like the A100 80GB (2,039 GB/s HBM2e) and H100 80GB SXM5 (3,350 GB/s HBM3 with native FP8 Tensor Cores and 900 GB/s NVLink) allow tensor-parallel sharding across 2 to 8 GPUs so both weights and KV-cache pages are split evenly across the cluster.
Engineering Comparison Matrix
| Model Preset | FP16 Weights | INT4 / Q4_K_M Weights | KV-Cache @ 32K (Batch=1, FP16) | Recommended GPU Tier |
|---|---|---|---|---|
| Llama-3 8B | 14.9 GB | 4.3 GB | 4.0 GB (128 KB/tok) | 1x RTX 4090 24GB |
| Qwen-2.5 32B | 60.5 GB | 17.3 GB | 8.0 GB (256 KB/tok) | 1x A100 80GB (or 4090 @ INT4 8K) |
| Llama-3 70B | 130.4 GB | 37.2 GB | 10.0 GB (320 KB/tok) | 1x A100 80GB (INT4) / 2x H100 (FP16) |
| DeepSeek-V3 (671B MoE) | 1,249.8 GB | 356.7 GB | 2.1 GB (MLA Compressed) | 8x H100 80GB (640GB Cluster @ INT4/FP8) |
Common Production Pitfalls to Avoid
- •Sizing GPUs for static weights only and forgetting that 32K–128K context windows multiply KV-cache linearly with batch size.
- •Running above 90–95% GPU VRAM utilization without leaving headroom for CUDA kernels, NCCL communication rings, and prefill activations.
- •Leaving KV-cache in FP16 on H100/Ada GPUs when FP8 KV-cache cuts context memory by 50% with near-zero perplexity impact.
- •Sharding models across PCIe GPUs without NVLink for high-concurrency tensor parallelism.
Frequently Asked Questions
How much VRAM do I need to run Llama-3 70B locally or in production?
In 16-bit (FP16/BF16), Llama-3 70B requires ~130.4 GB for weights alone plus KV-cache and overhead (~155+ GB total), fitting on 2x H100 80GB or 2x A100 80GB. Quantized to INT4 / Q4_K_M, weights drop to ~37.2 GB, allowing comfortable single-GPU deployment on 1x A100 80GB with a 32K context window.
Why does DeepSeek-V3 have a smaller KV-cache per token than Llama-3 70B?
DeepSeek-V3 uses Multi-Head Latent Attention (MLA), which compresses Key-Value projections into a low-rank latent vector (~70 KB/token in FP16 vs 320 KB/token on Llama-3 70B), dramatically reducing long-context KV-cache memory.
What do the Green, Amber, and Red hardware fit badges mean?
Green ('Optimal Fit') indicates total required VRAM is <= 80% of physical GPU capacity; Amber ('Tight Fit') indicates 80%–95% utilization where long prefill bursts may require PagedAttention tuning; Red ('Insufficient VRAM / OOM') indicates total memory exceeds 95% of card capacity.
How can I share my custom VRAM calculation with my engineering team?
Click the 'Copy Share Link' button in the calculator toolbar. It encodes all your current parameters, quantization settings, context length, and batch size into a `#state=...` URL hash that restores your exact configuration when opened.