Skip to content
E
Educatum
Interactive Engineering Tool14 Flagship Presets + Live HF Import · GGUF / FP8 / Apple Silicon · MHA / GQA / MLA

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

GQA · 70.6B Dense

80 layers · GQA (64Q / 8KV = 8× KV savings)

Execution Mode
Weight Precision (Datacenter & GGUF)
KV:
8,192 tok
8 reqs

2. Target GPU / Mac Silicon

159.2 GiB Usable · 5.90 TB/s eff.
GPU Count (Tensor Parallel)
FITS IN VRAM (+3.3 GiB headroom)
155.9 / 159.2 GiB usable (98%)

Switch KV-Cache to FP8 to save 10.0 GiB VRAM.

Total VRAM
155.9 GiB
Weights 131.5 GiB (FP16)
KV-Cache
20.0 GiB
8.0× vs MHA
Decode / User
~26.1 tok/s
HBM Bound
Cluster Output
~209 tok/s
AI 6.9 FLOP/B

VRAM Allocation vs. Hardware Capacity

Binary GiB (1 GiB = 2³⁰ B) · Usable VRAM excludes ECC/OS & per-GPU CUDA/NCCL buffers

Dashed line = Usable VRAM
Used: 155.9 GiB · Usable: 159.2 GiB (98%) 159.2 GiB Usable Weights: 131.5 GiBKV-Cache: 20.0 GiBAct + CUDA: 4.4 GiB educatum.com/kv-cache

Decode Arithmetic Intensity Roofline

AI 6.9 vs Ridge 295 FLOPs/B
1416642561024 Ridge: 295 FLOPs/B · 1741 TFLOPS Memory-Bandwidth Bound (6.9 FLOP/B) Arithmetic Intensity (FLOPs / Byte, log scale) educatum.com/kv-cache
Canonical URL stays clean; click Copy Shareable Link to share your exact slider config.
Llama-3.1 70B Instruct · KV_tok = 2 × 80L × 8 KV heads × 128d × 2B = 320.0 KiB/tok (8.0× vs MHA)
Decode Step Read: 131.5 GiB active weights + 20.00 GiB KV-cache → AI = 6.94 FLOPs/Byte (Memory-Bandwidth Bound; BW in decimal GB/s)

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.

MHA vs. GQA KV-Cache Size
KVGQA=2⋅L⋅nkv⋅dhead⋅S⋅B⋅bkv\text{KV}_{\text{GQA}} = 2 \cdot L \cdot n_{\text{kv}} \cdot d_{\text{head}} \cdot S \cdot B \cdot b_{\text{kv}}

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 MLA Latent Compression
KVMLA=L⋅(dc+drope)⋅S⋅B⋅bkv\text{KV}_{\text{MLA}} = L \cdot \bigl(d_c + d_{\text{rope}}\bigr) \cdot S \cdot B \cdot b_{\text{kv}}

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).

MoE vs. Dense Decode Roofline
AIdecode=2⋅Pactive⋅BPactive⋅bw+KVtok⋅S⋅B\text{AI}_{\text{decode}} = \frac{2 \cdot P_{\text{active}} \cdot B}{P_{\text{active}} \cdot b_w + \text{KV}_{\text{tok}} \cdot S \cdot B}

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.

Mixed-Precision Training Memory
MFull-FT≈Ptotal⋅(2⏟BF16+2⏟Grad+4+8⏟FP32 AdamW)+MactM_{\text{Full-FT}} \approx P_{\text{total}} \cdot \bigl(\underbrace{2}_{\text{BF16}} + \underbrace{2}_{\text{Grad}} + \underbrace{4 + 8}_{\text{FP32 AdamW}}\bigr) + M_{\text{act}}

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).

ModelParams (Total / Active)AttentionQ4_K_M WeightsKV / 1K tok (FP16)vs. MHASource
Llama-3.1 70B70.6B / 70.6BGQA40.1 GiB320.0 MiB8.0× smallermeta-llama/Llama-3.1-70B config.json
DeepSeek-V3 / R1671B / 37BMLA381.2 GiB68.6 MiB56.9× smallerdeepseek-ai/DeepSeek-V3 config.json
Qwen3-235B MoE235B / 22BGQA133.5 GiB188.0 MiB16.0× smallerQwen/Qwen3-235B-A22B config.json
Llama-4 Scout109B / 17BGQA61.9 GiB192.0 MiB5.0× smallermeta-llama/Llama-4-Scout-17B-16E-Instruct config.json
Llama-4 Maverick400B / 17BGQA227.2 GiB192.0 MiB5.0× smallermeta-llama/Llama-4-Maverick-17B-128E-Instruct config.json
Qwen3-32B32.8B / 32.8BGQA18.6 GiB256.0 MiB8.0× smallerQwen/Qwen3-32B config.json
Qwen3-30B-A3B30.5B / 3.3BGQA17.3 GiB96.0 MiB8.0× smallerQwen/Qwen3-30B-A3B config.json
Gemma-3 27B27.4B / 27.4BGQA (5:1 SW)15.6 GiB132.0 MiB7.5× smallergoogle/gemma-3-27b-it config.json
R1-Distill-32B32.8B / 32.8BGQA18.6 GiB256.0 MiB5.0× smallerdeepseek-ai/DeepSeek-R1-Distill-Qwen-32B config.json
Mistral-Small 24B24B / 24BGQA13.6 GiB160.0 MiB4.0× smallermistralai/Mistral-Small-24B-Instruct-2501 config.json
Gemma-3 12B12.2B / 12.2BGQA (5:1 SW)6.9 GiB104.0 MiB7.4× smallergoogle/gemma-3-12b-it config.json
Llama-3.1 8B8.03B / 8.03BGQA4.6 GiB128.0 MiB4.0× smallermeta-llama/Llama-3.1-8B config.json
Qwen3-8B8.2B / 8.2BGQA4.7 GiB144.0 MiB4.0× smallerQwen/Qwen3-8B config.json
Llama-3.1 405B405.9B / 405.9BGQA230.6 GiB504.0 MiB16.0× smallermeta-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).

Try keywords like RoPE, FlashAttention, DPO, or Blind 75.