Gemma 4 31B's Q4_K_M file is 18.3 GB (the file size this article cites); on the RTX 4090, the weights and a usable context window both fit. SpecPicks tracks 6 community runs of that size on this card, median 34.3 tok/s. RTX 4090 carries 24 GB of VRAM. The weights column is the range of real Q4_K_M
files on Hugging Face for the models in each size class (about 0.6 GB per billion parameters),
and the runtime plus a usable context window wants about 2 GB on top; every tokens-per-second figure is a
median over community-reported Q4 runs SpecPicks tracks for this card, with the run count and
the source beside it.
Showing the model sizes this article covers and the band either side. Every size from 3B to 70B+, for every card SpecPicks tracks, is in the local-LLM GPU table.
Model size
Weights at Q4
Fits in 24 GB?
Measured
Left for context
Source
20-27B (Gemma 3 27B, Mistral Small)A 27B Q4_K_M file (about 16.7 GB) is more than a 16 GB card holds, so 16 GB means a Q3 quant or partial CPU offload; a 24B loads with a short context. 20 GB holds the class with a usable context window, 24 GB with a long one.
This page is for owners of a single 24GB card, and buyers about to get one, who want to run Google's dense Gemma 4 31B rather than the slightly smaller Qwen 3.6 27B. At 24GB this model's 4-bit and 5-bit quants fit entirely in VRAM. That is the line the cheaper tiers cannot cross. The 16GB Gemma 4 31B quant table tops out at Q3_K_M with a quantized KV cache. The RTX 3060 12GB Gemma 4 31B guide is about choosing which layers spill to system RAM. On 24GB the question changes. You are no longer asking whether the model fits, but which quant to run and how much context it leaves you.
Three 24GB cards matter in 2026. The RTX 3090 (Ampere, 2020) is the used-market workhorse. The RTX 4090 (Ada, 2022) is the faster consumer card with the same memory size. The RX 7900 XTX (RDNA3, 2022) is AMD's 24GB option and runs through ROCm or Vulkan rather than CUDA. All three carry 24GB and have memory bandwidth within 8% of each other. For a dense 31B model that bandwidth figure predicts most of the generation speed, so the differences between the cards come from prefill compute, software maturity and power draw.
Every VRAM figure below is either a published file size or calculated from the model's own config.json on Hugging Face, and each one says which. Throughput figures are public third-party measurements. Where no public run exists, the table says so rather than filling the gap.
Key Takeaways
Q4_K_M is 18.3 GB and fits any 24GB card with room for 32K context. File sizes are from the unsloth/gemma-4-31B-it-GGUF listing. Q5_K_M (21.7 GB) fits at short context. Q6_K (25.2 GB) does not fit.
The RTX 3090 holds 31–35 tok/s across 4K–32K context: 34.7 tok/s at 4K, 33.5 at 16K and 31.4 at 32K, per Hardware Corner.
The 32GB RTX 5090 is the ceiling for a single consumer card at 61.1 tok/s (Q4_K, 4K, llama.cpp build 8189, Hardware Corner RTX 5090). That is 1.76× the 3090's generation speed on 1.9× the bandwidth.
On a comparable dense 32B model the RTX 4090 generates only about 11% faster than the 3090 (38.89 vs 35.1 tok/s), but it prefills about 2.2× faster (2,393 vs 1,087.9 tok/s), per Hardware Corner's RTX 4090 page and its 3090 page.
Gemma 4's sliding-window design keeps long context cheap. 50 of the 60 layers attend to only 1,024 tokens (config.json), so only 10 global layers grow with context. That works out to about 80 KiB of f16 KV cache per token.
Step 0: Does Gemma 4 31B fit your 24GB card at your context length?
Answer three questions before you change anything.
Which quant file? Read its size off the GGUF listing. That is your weight footprint, and it does not change with context.
How long a context do you actually use? Chat rarely needs more than 8K. Pasting a codebase or a long PDF pushes you to 32K–128K.
What precision is the KV cache? llama.cpp defaults to f16. --cache-type-k q8_0 --cache-type-v q8_0 roughly halves it, and q4_0 cuts it to about a quarter.
The KV-cache math comes straight from the Gemma 4 31B config. The 50 sliding-window layers each have 16 KV heads of dimension 256 and see only a 1,024-token window. llama.cpp sizes that cache to the window plus one micro-batch, so it is a fixed cost of about 1.2 GiB at f16 whatever the context length. The 10 global layers each have 4 KV heads of dimension 512, which comes to about 80 KiB per token at f16 when K and V are stored separately.
Context
Global-layer KV (f16)
Total KV at f16
Total KV at q8_0
Total KV at q4_0
8K
0.6 GiB
1.8 GiB
1.0 GiB
0.5 GiB
32K
2.5 GiB
3.7 GiB
2.0 GiB
1.0 GiB
128K
10.0 GiB
11.2 GiB
5.9 GiB
3.1 GiB
256K
20.0 GiB
21.2 GiB
11.2 GiB
5.9 GiB
Source: calculated from google/gemma-4-31B-it config.json (60 layers, 50 sliding at window 1,024, 10 global). The config's attention_k_eq_v flag means a runtime that shares K and V on the global layers could halve the global column. Treat these figures as the conservative case.
The fit rule used throughout this page is weights + KV + about 0.5 GiB of compute buffer, set against about 23.5 GiB usable on a 24GB card that is not driving a display. That budget is an assumption. If the same card runs your desktop, subtract a few hundred MB more.
Gemma 4 31B VRAM and quantization requirements
File sizes are from the unsloth/gemma-4-31B-it-GGUF listing. Unsloth does not publish a plain Q2_K, so the 2-bit row uses its UD-Q2_K_XL. The VRAM column is calculated with the method above at 8K context and an f16 KV cache. The 16GB column uses about 15.5 GiB usable and the 12GB column about 11.5 GiB, the same budgets as the sibling pages.
Quant
GGUF file size
Est. VRAM at 8K, f16 KV
Fits 24GB?
Fits 16GB?
Fits 12GB?
Quality note
UD-Q2_K_XL
11.8 GB
13.3 GiB
Yes, to 128K+
Yes
No (offload)
Visible reasoning loss; last resort
Q3_K_M
14.7 GB
16.0 GiB
Yes, to 128K with q8_0 KV
Only with q4_0/q8_0 KV
No
Usable; the 16GB ceiling
Q4_K_S
17.4 GB
18.5 GiB
Yes
No
No
Slightly smaller 4-bit
Q4_K_M
18.3 GB
19.3 GiB
Yes, to 32K at f16 KV
No
No
The default most runs use
UD-Q4_K_XL
18.8 GB
19.8 GiB
Yes
No
No
Unsloth's dynamic 4-bit
Q5_K_M
21.7 GB
22.5 GiB
Yes at 8K; 32K needs q8_0 KV
No
No
Best quality that fits 24GB
Q6_K
25.2 GB
25.8 GiB
No
No
No
32GB tier (RTX 5090)
Q8_0
32.6 GB
32.7 GiB
No
No
No
48GB tier or two cards
BF16
61.4 GB
59.5 GiB
No
No
No
Reference weights
Sources: file sizes from unsloth/gemma-4-31B-it-GGUF. VRAM is calculated, not measured. For quality, the quantization formats KLD comparison collects the measured divergence figures. On the closest published 27B-class ladder, akopytko's Qwen3.8-27B GGUF card puts Unsloth's Q4_0 at a mean KLD of 0.0283 and its Q6_K at 0.0029 against BF16. That is a different model, so read it as the shape of the curve, not a Gemma figure.
Loading the vision projector for image input adds roughly another GiB to every row. If you use Gemma 4's multimodal input, Q5_K_M stops being a comfortable fit and Q4_K_M becomes the practical top.
The 4090 and 7900 XTX gaps are real. Some sites list single-digit Gemma 4 31B figures for those cards, around 7.8 tok/s. They come either from calculators that assume the Q4_K_M build needs about 36 GB, which contradicts the 18.3 GB file, or from one-off reports where the model spilled into system RAM. Neither is an in-VRAM measurement, so neither is in the table.
The closest same-source proxy for the 4090 is a dense 32B model. Hardware Corner measured Qwen3 32B at Q4_K on the 3090 at 35.1 tok/s generation and 1,087.9 tok/s prefill at 4K. Its 4090 page records a 32B Q4_K_XL (18.64 GiB) at 38.89 tok/s generation and 2,393 tok/s prefill at 4K. The quants differ slightly and the pages were updated at different times, so read the roughly 11% generation gap and 2.2× prefill gap as a direction, not a Gemma result.
The table explains the result. The three 24GB cards span only 936 to 1,008 GB/s, a 7.7% range. The 4090's advantage is compute, not memory: it has 16,384 CUDA cores to the 3090's 10,496.
Prefill vs generation: where each card wins
Generating a token on a dense model means streaming every weight through the memory bus once. For an 18.3 GB Q4_K_M file the theoretical ceiling is bandwidth divided by file size:
RTX 3090: 936 ÷ 18.3 ≈ 51 tok/s ceiling. The measured 34.7 tok/s is about 68% of it.
RTX 4090: 1,008 ÷ 18.3 ≈ 55 tok/s ceiling.
RX 7900 XTX: 960 ÷ 18.3 ≈ 52 tok/s ceiling.
RTX 5090: 1,792 ÷ 18.3 ≈ 98 tok/s ceiling. The measured 61.1 tok/s is about 62% of it.
These are calculations, not measurements. They show why the 4090 cannot pull far ahead in generation: its ceiling is only about 8% above the 3090's.
Prefill, the processing of your prompt before the first token appears, is limited by compute instead. The 5090-to-3090 comparison shows it clearly in the same harness: 2.9× the prefill (3,395 vs 1,155.8 tok/s) but only 1.76× the generation. The 4090 should land between them. On the 32B proxy it prefilled 2.2× faster than the 3090. For a 20,000-token prompt that is the difference between waiting about 25 seconds for the first token on the 3090 at its 16K–32K prefill rates and about 11 on the 4090, if the proxy ratio holds. For short chat turns the gap disappears.
How does context length change the picture?
The 3090 row in Hardware Corner's data shows how little Gemma 4 31B slows down as context grows: generation drops only 9.5% from 4K to 32K (34.7 to 31.4 tok/s), while prefill drops 37% (1,155.8 to 723.7 tok/s). The sliding-window layers are the reason. Most of the attention cost does not grow with context.
Memory is the binding constraint at long context. Combining the KV table with the quant table gives these practical breakpoints on 24GB:
Quant
8K
32K
128K
256K
Q3_K_M
f16 KV
f16 KV
q8_0 KV
q4_0 KV
Q4_K_M
f16 KV
f16 KV
q4_0 KV (q8_0 is on the edge)
On the edge with q4_0 KV
Q5_K_M
f16 KV
q8_0 KV
Does not fit
Does not fit
Source: calculated from the config and file sizes above against a 23.5 GiB budget.
Use q8_0 KV first, because its quality cost is generally small. Drop to q4_0 KV only when you need the extra context. If neither gets you there, step down a quant rather than letting llama.cpp offload layers. On a 24GB card a smaller quant that stays entirely in VRAM almost always beats a larger quant that spills.
CUDA vs ROCm for Gemma 4 31B on the RX 7900 XTX
The RX 7900 XTX is a supported ROCm target. AMD's ROCm system requirements list it as RDNA3, LLVM target gfx1100, on Ubuntu 24.04 and 22.04 and RHEL 10 and 9 for the current production release. On Windows, or on any other distro, plan on llama.cpp's Vulkan back end instead.
Vulkan is not a downgrade for generation. In llama.cpp's ROCm performance discussion (#15021), an October 2026 run of Gemma 4 12B on an RDNA4 RX 9060 XT measured 39.0 tok/s generation on Vulkan against 37.6 on HIP/ROCm, with Vulkan also slightly ahead on prefill. Results vary by model and driver, so benchmark both back ends on your own card with llama-bench before settling.
Three caveats specific to the 7900 XTX:
No public Gemma 4 31B run exists yet, so its row in the benchmark table stays empty. Its 960 GB/s bandwidth puts its theoretical ceiling level with the 3090's.
New model architectures reach CUDA first. Gemma 4's chat template and attention layout needed llama.cpp updates in 2026. Use a current build on either back end.
Fewer tools support AMD. vLLM, ExLlamaV3 and most fine-tuning stacks assume CUDA. If you want more than llama.cpp or Ollama inference, factor that in.
What about 12GB? The RTX 3060 offload counter-case
On an MSI Gaming GeForce RTX 3060 12GB, no 3-bit or larger Gemma 4 31B quant fits. Q3_K_M alone is 14.7 GB. Every 4-bit run spills roughly a third of its weights into system RAM, and once layers offload, speed collapses rather than tapering. In llama.cpp issue #26674 a 16GB RTX 5060 Ti running Q6_K with offload measured 0.62 tok/s. On a 12GB card the spill is proportionally larger.
The better 12GB play is a different Gemma 4 model. The 26B-A4B mixture-of-experts variant activates only about 4B parameters per token. On a 12GB RTX 4070 Ti it ran UD-Q4_K_XL at 13.7 tok/s with partial offload, per Alfonso Fortunato's Gemma 4 benchmarks. On a 24GB 3090 the same MoE model reaches 119.4 tok/s at 4K, per Hardware Corner. The best local LLMs for 12GB VRAM guide covers the full 12GB shortlist, and the 3060 Gemma 4 31B guide covers the 2-bit route.
Perf-per-dollar and perf-per-watt
All dollar figures use launch MSRP, if you can find it at that. Used and current street prices move weekly; the live price buttons on each product page carry them.
GPU
Measured gen tok/s (Q4_K, 4K)
Bandwidth ceiling (tok/s)
Measured tok/s per $1,000 MSRP
Measured tok/s per 100 W
RTX 3090
34.7
51
23.1
9.9
RTX 4090
No public run
55
n/a (ceiling: 34.5)
n/a
RX 7900 XTX
No public run
52
n/a (ceiling: 52.6)
n/a
RTX 5090 32GB
61.1
98
30.6
10.6
Sources: throughput from Hardware Corner RTX 3090 and RTX 5090; MSRP and board power from the TechPowerUp pages above. The ceiling column is calculated.
At MSRP, the 7900 XTX has the most bandwidth per dollar by a wide margin. Whether it turns that into tok/s depends on the back end, and no one has published that run yet. Neither the 3090 nor the 4090 is sold new at MSRP in 2026, so compare the live used prices on the RTX 3090 vs RTX 4090 page before deciding.
Gemma 4 31B vs Qwen 3.6 27B on 24GB
Both fit. Qwen 3.6 27B's Q4_K_M is 16.8 GB, per unsloth/Qwen3.6-27B-GGUF, against Gemma's 18.3 GB. That 1.5 GB difference buys Qwen more context, or room for its Q5_K_M (19.5 GB) at longer windows. On speed, Hardware Corner's 3090 page records the previous-generation Qwen3.5 27B at 33.5 tok/s at 4K, close to Gemma 4 31B's 34.7, so the choice is mainly about the model, not tok/s.
Trusting fit calculators that double-count weights. Several "can I run it" sites claim Gemma 4 31B Q4_K_M needs about 36 GB. The actual file is 18.3 GB. Check the GGUF listing before you buy.
Leaving the KV cache at f16 and then blaming offload. At 128K context an f16 cache adds about 11 GiB. Set q8_0 KV before you drop a quant.
Running an old llama.cpp build. Builds from before Gemma 4 support load the weights but produce broken output. Build from ggml-org/llama.cpp main.
Loading the vision projector by accident. Front ends that auto-attach mmproj add about a GiB. Leave it off for text-only work on Q5_K_M.
Driving your monitor from the inference card. The desktop compositor can take several hundred MB. Q5_K_M at 8K has only about 1 GiB of headroom.
Verdict matrix
Get the RTX 3090 if you chat with one model at a time, want Q4_K_M or Q5_K_M fully on the card, and want the cheapest 24GB card with a published Gemma 4 31B result (31–35 tok/s).
Get the RTX 4090 if you paste long documents, run agents that re-read large contexts, or serve several users. Prefill is where its extra compute shows up, about 2.2× the 3090 on a 32B proxy.
Get the RX 7900 XTX if you run Linux on a supported ROCm distro or are happy with Vulkan, use llama.cpp or Ollama only, and accept that there is no published Gemma 4 31B run yet.
Stay on 12GB if you can switch to Gemma 4 26B-A4B or a 12B model. Dense 31B on 12GB is an offload exercise, not a daily driver.
Recommended pick
For most readers the RTX 3090 is the card. It is the only 24GB card here with a published Gemma 4 31B measurement, 34.7 tok/s at 4K and 31.4 at 32K. Its bandwidth sits within 8% of the 4090's, and it fits Q5_K_M at short context. The counter-case is the RTX 4090, for anyone whose workload is prompt-heavy rather than generation-heavy. If you feed 20K-token prompts all day, the faster prefill is worth paying for.
At 24GB, Gemma 4 31B stops being an offload problem. Q4_K_M at 18.3 GB fits all three cards with 32K context at an f16 KV cache, and Q5_K_M fits at 8K. Generation speed tracks memory bandwidth, and the three cards are within 8% of each other on bandwidth. That makes a used RTX 3090 at 34.7 tok/s the value pick, and leaves the RTX 4090's advantage mainly in prompt processing. The RX 7900 XTX has the bandwidth to match the 3090, but it still needs a public Gemma 4 31B run to prove it.
This piece is editorial synthesis based on publicly available information. No independent first-party benchmarking is reported. VRAM totals and throughput ceilings are calculated from the cited model config and file sizes and are labelled as calculations. Where no public run exists, the tables say so.
Small-model (7–9B) reference throughput
These figures are for 7–9B models, not the 30–35B models this article covers. The table holds model size fixed so the cards can be compared with each other; for the size in the title, use the article's own figures.
Median generation throughput at 7–9B models (Llama 3.1 8B, Qwen 3 8B), Q4 quantization, from community-reported runs SpecPicks tracks. Each row pools runs from different sources, runtimes and models in that class, so the rows are not a matched head-to-head; where the article compares cards on the same rig, its own figures are the like-for-like result. Street price is the second-lowest listing priced within the last 24 hours at 0.5–2× launch MSRP, so no single listing sets it, and a street figure well above MSRP says so in its cell; where too few listings pass that check the cell shows a dash and the launch MSRP, which is not comparable with the street figures. Rows marked for comparison are not the cards this article is about — they are included so the throughput column has something to be read against.
As an Amazon Associate, SpecPicks earns from qualifying purchases; we also earn on qualifying eBay purchases via the eBay Partner Network. Prices shown were last tracked at crawl time and may vary — check the listing for the current price.
📹 Watch a review
Asus ROG Strix Gaming RTX 3090 Review, Thermals, Overclocking & Gaming Benchmarks — Hardware Unboxed on YouTube
Frequently asked questions
Can Gemma 4 31B run fully on a single 24GB GPU?
Yes, at Q4_K_M and Q5_K_M. Q4_K_M is an 18.3 GB file and leaves room for about 32K of context with a full-precision KV cache, or 128K with a q4_0 cache. Q5_K_M at 21.7 GB fits at 8K and reaches 32K with a q8_0 cache. Q6_K (25.2 GB) does not fit on 24GB at all, and BF16 needs about 60 GB. The quant table in the article lists the sizes and the method behind each estimate.
Is the RTX 4090 worth the premium over a used RTX 3090 for Gemma 4 31B?
For single-user chat, usually not. Token generation on a dense 31B model is limited mostly by memory bandwidth, and the RTX 4090's 1,008 GB/s is only about 8% above the RTX 3090's 936 GB/s. On a comparable dense 32B model, Hardware Corner's data shows about 11% faster generation but roughly 2.2x faster prompt processing on the 4090. If you paste long documents or serve several users, the 4090 earns its premium.
Does the RX 7900 XTX work well for Gemma 4 31B?
It has the same 24GB and works through llama.cpp's ROCm or Vulkan back ends, but there are fewer published Gemma 4 31B runs on it than on NVIDIA cards, and runtime support moves more slowly. Check that your distro and ROCm version support the card before buying. The article only shows a 7900 XTX throughput row where a public source has measured one, and labels the gap where none exists.
What context length can I use with Gemma 4 31B on 24GB?
It depends on the quant and the KV-cache precision. At Q4_K_M with a full-precision KV cache, mid-range contexts fit comfortably. Pushing toward 128K usually means quantizing the KV cache to q8_0 or accepting partial CPU offload, which drops tok/s sharply. The context section of the article shows the breakpoints, so you can choose between a bigger quant and a longer context.
Should I run Gemma 4 31B or Qwen 3.6 27B on a 24GB card?
Both fit on 24GB at Q4-class quants. Qwen 3.6 27B's Q4_K_M file is 16.8 GB against Gemma 4 31B's 18.3 GB, so Qwen leaves more room for context or a higher quant. Generation speed is close, so the choice comes down to the model itself. Pick Gemma 4 31B for image input or its writing style. Pick Qwen for agentic coding and long-context work. The linked comparison article covers the benchmark trade-offs in detail.