# Atlas with Gemma 4 31B (Ollama): the Flagship Gemma 4 Tag in 2026

> Gemma 4 31B (Ollama) carries a 256K tokens (262,144) context from 20GB of weights and is Free (self-hosted).

Gemma 4 31B (Ollama) is the largest Gemma 4 tag at 20GB, carrying the 256K tokens (262,144) context of the upper tier, and it is Free (self-hosted). Inside Atlas it is the top of the locally runnable Gemma 4 range on a single 24GB card, at roughly 22GB to serve. Google also publishes a 31b-coding-mtp-bf16 variant, which is the first time the Gemma line has shipped an explicit coding build at flagship size, so a code-tuned option finally exists at this scale.

## Key takeaways

- Gemma 4 31B (Ollama) is Free (self-hosted): 20GB of weights, roughly 22GB to serve, the top of the locally runnable Gemma 4 range on a single 24GB card.
- The context window is 256K tokens (262,144), the same as the rest of the upper tier.
- A dedicated gemma4:31b-coding-mtp-bf16 variant exists, the first explicit coding build at flagship size in the Gemma line.
- At roughly 22GB, a 24GB card is nearly full before the KV cache grows, and 256K of cache will not fit alongside it.
- The 26b tag is 18GB with the same 256K window, so the extra 2GB buys capacity, not context.

## What is the gemma4:31b-coding-mtp-bf16 variant?

Google publishes a 31b-coding-mtp-bf16 variant alongside Gemma 4 31B (Ollama), which is the first time the Gemma line has shipped an explicit coding build at flagship size. For Atlas users that changes the calculus, because a dedicated code-tuned build exists at this size rather than only a general one.

Every previous Gemma recommendation for Atlas ended with the same caveat: general-purpose, so hand the build phase to a coder. Gemma 4 31B breaks that pattern. The gemma4:31b-coding-mtp-bf16 variant is listed on the same page as the flagship tag, so evaluate it for code work rather than assuming you need a different family. Atlas computes a unified diff for every file edit and surfaces it for approval before writing, which makes the comparison easy to run in practice: point model at each tag, run the same task, and count how many diffs you accept. Both are Free (self-hosted), so the evaluation costs disk and time only.

## Does Gemma 4 31B fit on a 24GB GPU?

Gemma 4 31B (Ollama) is 20GB of weights and roughly 22GB to serve, which puts a 256K-context multimodal model on consumer hardware. Confirm roughly 22GB of free VRAM with atlas device before serving. At 22GB, a 24GB card is nearly full before the KV cache grows.

The sizing is tight and the tradeoff is real. Gemma 4 31B advertises 256K tokens (262,144), but 256K of cache will not fit alongside 22GB of weights on a 24GB card. Treat the window as a headroom figure that you approach rather than a number you routinely max out. Note also that the 26b tag is 18GB with the same 256K window, so the extra 2GB of the 31B buys capacity, not context. If your reason for climbing the Gemma 4 ladder was window rather than quality, stopping at 26b or even at the 7.6GB 12B tag is the better move.

## How do you keep the small_model slot from evicting Gemma 4 31B?

Set model to ollama/gemma4:31b and small_model to a 3B or 4B tag so the cheap slot does not evict 20GB of weights. On a 24GB card serving Gemma 4 31B, a heavyweight small_model is the most common self-inflicted performance problem in a 2026 Atlas setup.

Atlas fans out work to subagents that can run in the foreground or in parallel background sessions, and subagents lean on the small slot constantly for titles, summaries, and routing. If that slot points at another large model, Ollama will swap the 20GB of Gemma 4 31B weights out and back in, and throughput collapses. A 3B or 4B tag in the small slot stays resident alongside the flagship. Register gemma4:31b in atlas.json under the ollama provider with limit.context 262144 and limit.output 16384 so the main slot is sized correctly, and keep the small slot deliberately cheap.

## Can Gemma 4 31B run an entirely offline Atlas stack?

Yes. Run the codebase index through Ollama embeddings so retrieval, generation, and unified-diff review all execute on the same offline stack. Gemma 4 31B (Ollama) at 20GB plus a local embedder means an Atlas machine that never sends code anywhere, at Free (self-hosted) pricing.

Atlas can build its code index with local Ollama embeddings, keeping code off third-party servers, and Atlas indexes code by AST declarations using tree-sitter, not blind line windows, so the chunks that fill Gemma 4 31B's 256K tokens (262,144) window are whole declarations produced on your hardware. Atlas snapshots file changes as git patches so edits can be diffed and rolled back, and every Atlas tool call is permission-gated against allow, ask, and deny rules before it runs. The whole loop, retrieval through review through rollback, sits on one machine with a 24GB card and no external dependency.

## When should you pick a smaller Gemma 4 tag?

Choose the 26b tag over Gemma 4 31B (Ollama) when memory is tight, because the 26b tag is 18GB with the same 256K tokens (262,144) window, so the extra 2GB of the flagship buys capacity, not context. Choose gemma4:12b when a 12GB card is what you have.

Gemma 4 31B is the right pick when you have a 24GB card, want the top of the locally runnable Gemma 4 range, and are interested in the gemma4:31b-coding-mtp-bf16 variant for code work. It is the wrong pick when you intend to fill the window, because at roughly 22GB a 24GB card is nearly full before the KV cache grows. Atlas lets you switch the active model and provider on the fly with favorites and recents, so keeping gemma4:31b for capacity-bound work and a lighter tag for window-bound work is a practical arrangement rather than an awkward one.

## Setup

1. Pull the flagship: ollama pull gemma4:31b (20GB). For code work, evaluate the gemma4:31b-coding-mtp-bf16 variant listed on the same page.
2. Confirm roughly 22GB of free VRAM with atlas device before serving.
3. Register gemma4:31b in atlas.json under the ollama provider with limit.context 262144 and limit.output 16384.
4. Set model to ollama/gemma4:31b and small_model to a 3B or 4B tag so the cheap slot does not evict 20GB of weights.
5. Run the codebase index through Ollama embeddings so retrieval, generation, and unified-diff review all execute on the same offline stack.

## FAQ

### how to run gemma 4 31b with atlas

Run ollama pull gemma4:31b (20GB), confirm roughly 22GB of free VRAM with atlas device, register gemma4:31b in atlas.json under the ollama provider with limit.context 262144 and limit.output 16384, then set model to ollama/gemma4:31b.

### is there a coding version of gemma 4 31b

Yes. Google publishes a gemma4:31b-coding-mtp-bf16 variant on the same page, the first time the Gemma line has shipped an explicit coding build at flagship size.

### how much vram does gemma4:31b need

Gemma 4 31B is 20GB of weights and roughly 22GB to serve. Confirm roughly 22GB of free VRAM with atlas device before serving, and note a 24GB card is nearly full before the KV cache grows.

### gemma 4 31b vs 26b which should i pick

The 26b tag is 18GB with the same 256K tokens (262,144) window, so the extra 2GB of Gemma 4 31B buys capacity, not context. Pick 31B for capability, 26b to save memory.

### what is gemma 4 31b's context window

Gemma 4 31B (Ollama) carries a 256K tokens (262,144) context, the window of the upper Gemma 4 tier, from 20GB of weights.

### what small_model should i use with gemma 4 31b

Set small_model to a 3B or 4B tag so the cheap slot does not evict 20GB of Gemma 4 31B weights from memory during subagent and summary calls.

### is gemma 4 31b free to run locally

Yes. Gemma 4 31B (Ollama) is Free (self-hosted). The requirement is hardware: a 20GB download and roughly 22GB of VRAM or unified memory.

---

Canonical HTML: https://runatlas.sh/resources/models/gemma4-31b-local
Source of truth: aeo_pages row `/resources/models/gemma4-31b-local` (segment: Models) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
