LLM VRAM, KV-Cache & Roofline Calculator
Compute exact GPU weight memory, KV-cache footprint across MHA, GQA, DeepSeek MLA, and Gemma-3 sliding windows, GGUF local Mac/RTX fits, training optimizer states, and decode throughput—or import any public Hugging Face config.json.
1. Model & Workload
2. Target GPU / Mac Silicon
VRAM Allocation vs. Hardware Capacity
Decode Arithmetic Intensity Roofline
Model-Specific VRAM Guides & Specialty Calculators
Pre-computed RTX 4090, Apple M4 Max / M3 Ultra, and H100 hardware compatibility matrices for 14 flagship models.
First-Principles Memory & Roofline Equations
Why naive 2 × Params calculators fail on GQA, Gemma sliding-window layers, and DeepSeek MLA.
Standard MHA stores n_q key/value heads per token. GQA shares n_kv heads across query groups—giving an immediate n_q / n_kv (e.g., 8× on Llama-3.1 70B) memory reduction.
DeepSeek-V3/R1 projects keys and values into a single shared latent vector (d_c = 512) plus a decoupled RoPE key (d_rope = 64)—cutting per-token KV storage to 576 scalars/layer (56.9× smaller than 128-head MHA).
Static weights occupy VRAM proportional to P_total, but each decode step only loads P_active parameters plus cached KV blocks. Compare AI_decode against the GPU ridge point Peak FLOPs / HBM BW.
AdamW maintains FP32 master weights, first moments, and second moments (~12 bytes/trainable param). LoRA/QLoRA shrink this optimizer term by ~100× by freezing base weights.
14 Flagship Model Memory & KV-Cache Reference Specs
Exact architectural figures sourced from official Hugging Face config.json manifests (KV per 1K evaluated at 8K context).
| Model | Params (Total / Active) | Attention | Q4_K_M Weights | KV / 1K tok (FP16) | vs. MHA | Source |
|---|---|---|---|---|---|---|
| Llama-3.1 70B | 70.6B / 70.6B | GQA | 40.1 GiB | 320.0 MiB | 8.0× smaller | meta-llama/Llama-3.1-70B config.json |
| DeepSeek-V3 / R1 | 671B / 37B | MLA | 381.2 GiB | 68.6 MiB | 56.9× smaller | deepseek-ai/DeepSeek-V3 config.json |
| Qwen3-235B MoE | 235B / 22B | GQA | 133.5 GiB | 188.0 MiB | 16.0× smaller | Qwen/Qwen3-235B-A22B config.json |
| Llama-4 Scout | 109B / 17B | GQA | 61.9 GiB | 192.0 MiB | 5.0× smaller | meta-llama/Llama-4-Scout-17B-16E-Instruct config.json |
| Llama-4 Maverick | 400B / 17B | GQA | 227.2 GiB | 192.0 MiB | 5.0× smaller | meta-llama/Llama-4-Maverick-17B-128E-Instruct config.json |
| Qwen3-32B | 32.8B / 32.8B | GQA | 18.6 GiB | 256.0 MiB | 8.0× smaller | Qwen/Qwen3-32B config.json |
| Qwen3-30B-A3B | 30.5B / 3.3B | GQA | 17.3 GiB | 96.0 MiB | 8.0× smaller | Qwen/Qwen3-30B-A3B config.json |
| Gemma-3 27B | 27.4B / 27.4B | GQA (5:1 SW) | 15.6 GiB | 132.0 MiB | 7.5× smaller | google/gemma-3-27b-it config.json |
| R1-Distill-32B | 32.8B / 32.8B | GQA | 18.6 GiB | 256.0 MiB | 5.0× smaller | deepseek-ai/DeepSeek-R1-Distill-Qwen-32B config.json |
| Mistral-Small 24B | 24B / 24B | GQA | 13.6 GiB | 160.0 MiB | 4.0× smaller | mistralai/Mistral-Small-24B-Instruct-2501 config.json |
| Gemma-3 12B | 12.2B / 12.2B | GQA (5:1 SW) | 6.9 GiB | 104.0 MiB | 7.4× smaller | google/gemma-3-12b-it config.json |
| Llama-3.1 8B | 8.03B / 8.03B | GQA | 4.6 GiB | 128.0 MiB | 4.0× smaller | meta-llama/Llama-3.1-8B config.json |
| Qwen3-8B | 8.2B / 8.2B | GQA | 4.7 GiB | 144.0 MiB | 4.0× smaller | Qwen/Qwen3-8B config.json |
| Llama-3.1 405B | 405.9B / 405.9B | GQA | 230.6 GiB | 504.0 MiB | 16.0× smaller | meta-llama/Llama-3.1-405B config.json |
Read the First-Principles Guides Behind These Numbers
All 16 Inference Guides →Frequently Asked Questions
Why do MoE models like DeepSeek-V3 (671B) or Llama-4 Maverick (400B) still need huge VRAM if few parameters are active?
All expert weights must remain resident in GPU or Unified RAM so any routed token can dispatch without PCIe swapping. However, during single-token decode, each step only streams the active weights (37B for DeepSeek-V3, 17B for Llama-4) from memory—making decode dramatically faster than an equally sized dense model.
How does DeepSeek MLA shrink KV-Cache compared to GQA and MHA?
Multi-Head Latent Attention projects keys and values into a single shared compressed latent vector (kv_lora_rank = 512) plus a 64-dim decoupled RoPE key per layer. For DeepSeek-V3 (61 layers), FP16 KV-cache drops to 68.6 KiB (70.3 KB) per token—56.9× smaller than 128-head MHA.
How does Gemma-3 5:1 sliding-window attention reduce long-context KV memory?
Gemma-3 27B interleaves 52 local sliding-window layers (capped at a 1,024-token cache per request) with only 10 global layers that store full context. At 32K context and batch 8 in FP16, KV-cache drops from 124.0 GiB to 23.25 GiB—fitting comfortably inside one 79.6 GiB usable H100.
How accurately are Apple Silicon Unified Memory and GGUF Q4_K_M modeled?
All VRAM capacities in Educatum are computed in exact bytes and displayed strictly in binary GiB (1 GiB = 2³⁰ B), separating usable GPU memory (e.g., 79.6 GiB usable on H100, 96.0 GiB wired on M4 Max 128 GiB) from decimal GB/s HBM bandwidth. GGUF weights reflect real file overhead (~0.61 B/param for Q4_K_M, ~0.82 B/param for Q6_K).