FitLLM

Can I run Gemma 4 31b on an RTX 5090 (32GB)?

✅ Yes — it fits — up to ~67K tokens at Q4_K_M

Computed with the open FitLLM engine — accurate per-layer KV-cache modeling, not a naive estimate. Updated 2026-06.

Memory breakdown (Q4_K_M, F16 KV, 33K context)

Model weights17.5 GB
KV cache3.3 GB
Runtime overhead + reserve5.6 GB
Total used26.3 / 32 GB
Free5.7 GB

Max context that fits at Q4_K_M: ~67K tokens · with Q8 KV cache → ~113K tokens.

Every quantization on the RTX 5090

Weight quantWeightsFits (KV F16)Used @32K
Q4_K_M17.5 GB✅ up to 67K ctx26.3 / 32.0 GB
Q5_K_M20.4 GB✅ up to 40K ctx29.6 / 32.0 GB
Q6_K23.5 GB❌ up to 10K ctx33.0 / 32.0 GB
Q8_030.4 GB❌ won't fit40.8 / 32.0 GB
FP1657.2 GB❌ won't fit70.8 / 32.0 GB

KV cache is F16 here (llama.cpp default). Drop it to Q8/Q4 (-ctk/-ctv) for more context.

▶ Open the interactive calculator (this exact setup)

Why most VRAM calculators get this wrong

Gemma 4 31b interleaves sliding-window (local) and global attention 5:1. The local layers cap their KV cache at the 1024-token window, and the global layers use a different head shape (head_dim 512 vs 256). A naive "all layers × full context × one head_dim" formula over-counts KV cache by several times.

Other options

same GPU Models that fit on the RTX 5090: Qwen 3.6 27B, Qwen 3.6 35B-A3B, Gemma 4 e2b, Gemma 4 e4b, Gemma 4 12b, Gemma 4 26b A4B, Gemma 4 31b.

same model GPUs that run Gemma 4 31b: RTX 5090 (32GB).

Reproduce it

Gemma 4 31b = 30.7B, 60 layers. The RTX 5090 has 32GB / 1792GB/s. Same math, open source: fitllm-engine. GGUF bpw from llama.cpp.

All numbers are computed by the open-source fitllm-engine (MIT) from official model config.json values — reproduce or audit them yourself. Estimates; real usage varies with runtime (llama.cpp / MLX / Ollama), driver and display. Found a mismatch? Report it. · FitLLM home