Gemma 4 31B VRAM requirements

Gemma 4 31B needs about 21.9 GB of VRAM at Q4_K_M with 8K context, so it fits a 24 GB card such as the RTX 3090 or the RTX 4090. Gemma 4 31B has 31.3B parameters. With the same 8K context and one request it needs 34.5 GB at FP8 and 66.6 GB at FP16/BF16. The published weights take 58.3 GB (BF16). The smallest setup here that holds it at Q4_K_M with an 8K context is the RTX 3090 (24 GB), which runs it with up to 26K tokens of context.

21.9 GB at Q4_K_M, 8K context, one request

FP8
34.5 GB
FP16 / BF16
66.6 GB
Published weights
58.3 GB
Smallest setup, Q4_K_M
RTX 3090 (24 GB)
Open Gemma 4 31B in the calculator

Worked example: Gemma 4 31B with 32K tokens

Inputs: Gemma 4 31B · Q4_K_M weights · 32,768 tokens of context · one request · FP16 KV cache

Weights (31.3B at Q4_K_M)
17.6 GB
KV cache (80 KB per token)
3.67 GB
Buffers and runtime (0.5 GB + 10%)
2.63 GB
Total
23.9 GB

The smallest setup here that holds it is the RTX 3090 (24 GB), with about 80 MB to spare. Change the inputs in the calculator

Can I run Gemma 4 31B on…

What makes Gemma 4 31B's memory use different

Its 50 sliding-window layers keep only the last 1,024 tokens (llama.cpp gives them 1,536 cells: the window plus a 512-token batch, rounded up to 256): at its 256K limit they hold 1.17 GB of cache instead of the 200 GB they would need with full attention.

Per token of context it adds 80 KB of FP16 cache; Granite 4.2 30B (29.3B), the nearest-sized model here with plain full attention, adds 256 KB, so Gemma 4 31B needs 31% as much.

How much VRAM does Gemma 4 31B need?

Gemma 4 31B needs 21.9 GB at Q4_K_M, 36.5 GB at Q8_0 and 66.6 GB at FP16 with 8,192 tokens of context and one request. Each total below is the weights plus the FP16 KV cache and the runtime overhead (0.5 GB plus 10%), and each row opens the calculator with that setting. What the GGUF names mean.

PrecisionWeightsTotalSmallest setup
As published (BF16) 58.3 GB 66.6 GB A100 80GB
FP16 / BF16 58.3 GB 66.6 GB A100 80GB
FP8 / INT8 29.1 GB 34.5 GB M4 Pro Mac (64 GB, 48 GB usable)
INT4 (AWQ / GPTQ) 15.5 GB 19.5 GB RTX 3090 (24 GB)
GGUF Q8_0 30.9 GB 36.5 GB M4 Pro Mac (64 GB, 48 GB usable)
GGUF Q6_K 23.9 GB 28.7 GB RTX 5090 (32 GB)
GGUF Q5_K_M 20.6 GB 25.2 GB RTX 5090 (32 GB)
GGUF Q4_K_M 17.6 GB 21.9 GB RTX 3090 (24 GB)
GGUF IQ4_XS 15.8 GB 19.9 GB RTX 3090 (24 GB)
GGUF Q3_K_M 14.2 GB 18.1 GB RTX 3090 (24 GB)
GGUF IQ3_XXS 12.0 GB 15.7 GB RTX 4060 Ti 16GB
GGUF Q2_K 12.2 GB 15.9 GB RTX 4060 Ti 16GB

Fine-tuning Gemma 4 31B? Gemma 4 31B VRAM for LoRA, QLoRA and full training.

Gemma 4 31B GGUF files on Hugging Face

The 8 GGUF files llama.cpp picks for Gemma 4 31B with -hf <repo>:<QUANT>, with the bytes the Hugging Face file list reported on 2026-09-29. Each total is that file plus the FP16 KV cache and 0.5 GB + 10%, one request. "vs estimate" compares the file with the bits-per-weight size the table above uses.

QuantFileSizevs estimate 8K32K128K
Q2_K bartowski/google_gemma-4-31B-it-GGUF 11.8 GB12,631,624,032 bytes −4% 15.4 GB17.5 GB25.7 GB
Q3_K_M unsloth/gemma-4-31B-it-GGUF 13.7 GB14,736,608,192 bytes −4% 17.6 GB19.6 GB27.9 GB
IQ4_XS unsloth/gemma-4-31B-it-GGUF 15.2 GB16,372,460,480 bytes −4% 19.2 GB21.3 GB29.6 GB
Q4_K_M unsloth/gemma-4-31B-it-GGUF 17.1 GB18,323,733,440 bytes −3% 21.2 GB23.3 GB31.6 GB
Q5_K_M unsloth/gemma-4-31B-it-GGUF 20.2 GB21,658,401,728 bytes −2% 24.7 GB26.7 GB35.0 GB
Q6_K unsloth/gemma-4-31B-it-GGUF 23.5 GB25,201,486,784 bytes −2% 28.3 GB30.4 GB38.6 GB
Q8_0 ggml-org/gemma-4-31B-it-GGUF 30.4 GB32,635,676,896 bytes −2% 35.9 GB38.0 GB46.2 GB
BF16 ggml-org/gemma-4-31B-it-GGUF 57.2 GB61,413,189,856 bytes −2% 65.4 GB67.5 GB75.7 GB

GB here is GiB (1024³ bytes), as everywhere on this site; Hugging Face shows the Q4_K_M file as 18.3 GB, in 10⁹ bytes.

Which Gemma 4 31B GGUF fits a 16, 24, 32, 48 or 80 GB GPU or a Mac

From the file sizes above: the largest file that fits each machine with an 8K context and 0.5 GB left free, the longest context it then has room for, and the longest context for Q4_K_M (17.1 GB). One request, FP16 KV cache, -np 1. The Q4_K_M file is 569 MB under its bits-per-weight estimate; the estimate tables and the llama-server command on this page count the estimate, so they show less context.

HardwareLargest GGUF, 8KIts longest contextQ4_K_M, longest context
RTX 5060 Ti 16GB Q2_K, 11.8 GB 8K No
RTX 4090 (24 GB) Q4_K_M, 17.1 GB 34K 34K
RTX 5090 (32 GB) Q6_K, 23.5 GB 45K 127K
L40S (48 GB) Q8_0, 30.4 GB 142K 256K (full)
H100 SXM (80 GB) BF16, 57.2 GB 172K 256K (full)
M4 Pro Mac (64 GB, 48 GB usable) Q8_0, 30.4 GB 142K 256K (full)
M4 Max Mac (128 GB, 96 GB usable) BF16, 57.2 GB 256K (full) 256K (full)

Run Gemma 4 31B with llama.cpp or Ollama

llama-server -hf unsloth/gemma-4-31B-it-GGUF:Q4_K_M -c 26624 -np 1

gemma-4-31B-it-Q4_K_M.gguf, 18.3 GB, from unsloth/gemma-4-31B-it-GGUF (checked 2026-09-29). On a 24 GB RTX 3090 / 4090, Q4_K_M with -c 26624 takes 23.4 GB and leaves 608 MB. -np 1: one slot, so one 1,024-token window.

ollama run gemma4:31b

Ollama library tag gemma4:31b; its quant is Ollama's choice. Same context: /set parameter num_ctx 26624.

Gemma 4 31B at 8K, 32K, 128K and 256K (full) tokens of context

10 of its 60 layers use full attention and 50 keep a sliding window of 1,024 tokens. Each extra token of context adds 80 KB of FP16 cache per request once the sliding windows are full. The last column is the smallest setup here, one card or a group, that holds it at Q4_K_M. How the KV cache works.

ContextKV cache, FP16Total at Q4_K_MTotal at Q8_0Smallest setup, Q4_K_M
8K tokens 1.80 GB 21.9 GB 36.5 GB RTX 3090 (24 GB)
32K tokens 3.67 GB 23.9 GB 38.6 GB RTX 3090 (24 GB)
128K tokens 11.2 GB 32.2 GB 46.8 GB M4 Pro Mac (64 GB, 48 GB usable)
256K tokens 21.2 GB 43.2 GB 57.8 GB M4 Pro Mac (64 GB, 48 GB usable)

Speculative decoding with Gemma 4 31B

Extra memory a draft model or MTP head adds to the Unsloth Q4_K_M GGUF (21.7 GB alone with 32K tokens), from the measured files. Open the speculative decoding calculator.

DraftExtra VRAMTotal
Unsloth MTP assistant Q8_0 603–748 MB 22.3–22.5 GB
Unsloth MTP assistant F16 1.00–1.14 GB 22.7–22.9 GB
DFlash Q4_K_M (Anbeeld) 1.12–1.27 GB 22.9–23.0 GB
DFlash Q8_0 (Anbeeld) 1.81–1.95 GB 23.5–23.7 GB

How fast Gemma 4 31B writes

Tokens per second for one request with 8,192 tokens of context, estimated from memory bandwidth. A dash means it does not fit on one card. Try other settings in the speed calculator.

HardwareBandwidthQ4_K_MFP8
RTX 3060 12GB 360 GB/s ——
RTX 4090 1,008 GB/s 26–36—
RTX 5090 1,792 GB/s 44–62—
M4 Max Mac (128 GB) 546 GB/s 14–198.9–12
M3 Ultra Mac Studio (512 GB) 819 GB/s 21–2913–18
H100 SXM 3,350 GB/s 78–11451–73
H200 4,800 GB/s 106–15971–103

Longest context on one GPU

How many tokens of context Gemma 4 31B fits on a single card with one request, an FP16 KV cache and 0.5 GB left free. "Full" means the model's whole context window fits.

GPUMemoryQ4_K_MQ8_0FP8
RTX 3060 12 GB NoNoNo
RTX 4060 Ti 16GB 16 GB NoNoNo
RTX 3090 / 4090 24 GB 26KNoNo
RTX 5090 32 GB 120KNoNo
A100 40GB 40 GB 213K42K65K
Mac, 64 GB unified memory 48 GB 256K (full)135K158K
L40S / RTX 6000 Ada 48 GB 256K (full)135K158K
A100 / H100 80GB 80 GB 256K (full)256K (full)256K (full)
Mac, 128 GB unified memory 96 GB 256K (full)256K (full)256K (full)
H200 141 GB 256K (full)256K (full)256K (full)
B200 180 GB 256K (full)256K (full)256K (full)

Model details

Parameters
31.3B (31,273,088,876)
Layers
10 of its 60 layers use full attention and 50 keep a sliding window of 1,024 tokens
Attention cache
4 KV heads × 512 (values come from the key projection but are cached separately)
Sliding-window layers
16 KV heads × 256
Context length
262,144 tokens
Published weights
58.3 GB (BF16)
On Hugging Face
google/gemma-4-31B-it
Reported benchmarks
GPQA Diamond 84.3 · MMLU-Pro 85.2 · LiveCodeBench v6 80.0. Vendor-reported: from the maker’s own model card, not rerun here; read 2026-09-30.

Why this estimate looks this way

At Q4_K_M and an 8K-token context, Gemma 4 31B uses 17.6 GB for weights, 1.80 GB for its FP16 KV cache and 2.44 GB for estimated runtime overhead, totaling 21.9 GB. The overhead is a 0.5 GB base plus 10% of weights and cache.

Its attention layout matters for long context: 10 of its 60 layers use full attention and 50 keep a sliding window of 1,024 tokens. The FP16 cache grows by about 80 KB per additional token per request once the sliding windows are full.

The architecture and published checkpoint size come from the model's config.json and weight files. These are estimates rather than measured peak memory; inference engines can reserve extra buffers or preallocate the full configured cache.

Gemma 4 31B next to similar-sized models

The three models here closest to it in parameter count, at Q4_K_M with 8,192 tokens of context.

ModelParametersTotalKV per tokenSmallest setup
Gemma 4 31B 31.3B 21.9 GB 80 KB RTX 3090 (24 GB)
GLM-4.7 Flash 31.2B, 3B active 20.3 GB 53 KB RTX 3090 (24 GB)
Xing 4.0 29B-A4B 31.2B, 4B active 20.2 GB 45 KB RTX 3090 (24 GB)
Nemotron 3 Nano 30B-A3B 31.6B, 3.5B active 20.1 GB 6 KB RTX 3090 (24 GB)

Gemma 4 31B VRAM questions

How much VRAM do I need to run Gemma 4 31B locally?

About 21.9 GB at Q4_K_M with an 8K context and one request, by the bits-per-weight estimate, and 66.6 GB at BF16. The Q4_K_M GGUF gemma-4-31B-it-Q4_K_M.gguf in unsloth/gemma-4-31B-it-GGUF is 18,323,733,440 bytes (17.1 GB); with an 8K context it needs 21.2 GB. The smallest setup listed here that holds Q4_K_M is the RTX 3090 (24 GB).

Can I run Gemma 4 31B on a 24 GB GPU?

Yes. On the RTX 4090 (24 GB), the largest listed GGUF that fits with an 8K context and 0.5 GB free is Q4_K_M (17.1 GB), with up to 34K tokens of context.

Which quantization of Gemma 4 31B fits in 16 GB of VRAM?

On the RTX 5060 Ti 16GB, the largest listed GGUF that fits with an 8K context and 0.5 GB free is Q2_K (11.8 GB), with up to 8K tokens of context.

Can I run Gemma 4 31B on a Mac?

On the M4 Pro Mac (64 GB, 48 GB usable), the largest listed GGUF that fits with an 8K context and 0.5 GB free is Q8_0 (30.4 GB), with up to 142K tokens of context. Q4_K_M (17.1 GB) runs with its full 256K-token context. On the M4 Max Mac (128 GB, 96 GB usable), the largest listed GGUF that fits with an 8K context and 0.5 GB free is BF16 (57.2 GB), with its full 256K-token context. By default macOS lets the GPU use about 75% of unified memory.

How much more VRAM does Gemma 4 31B need for 32K or 128K tokens of context?

Its FP16 KV cache is 1.80 GB at 8K, 3.67 GB at 32K, 11.2 GB at 128K for one request, so 128K adds 9.38 GB over 8K, plus 10% overhead. A q8_0 cache (-ctk q8_0 -ctv q8_0) takes 5.94 GB at 128K. Its 50 sliding-window layers stop growing at 1,024 tokens, so only 10 layers keep adding cache.

Why does Gemma 4 31B use more VRAM than its GGUF file size?

The file holds only the weights. At Q4_K_M with an 8K context: 17.1 GB of weights (the file's 18,323,733,440 bytes) + 1.80 GB of FP16 KV cache + 2.39 GB of compute buffers and runtime (0.5 GB + 10%) = 21.2 GB.

Badge for your model card

Paste it into a Hugging Face or GitHub README; it shows the Q4_K_M total above and links to this page. Q8_0 and FP16 badges.

Gemma 4 31B VRAM: 21.9 GB at Q4_K_M, 8K context

Numbers read from the model files on Hugging Face on . Compare it with other models in the reproducible model and GPU report.