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.
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
- 01Pull the flagship: ollama pull gemma4:31b (20GB). For code work, evaluate the gemma4:31b-coding-mtp-bf16 variant listed on the same page.
- 02Confirm roughly 22GB of free VRAM with atlas device before serving.
- 03Register gemma4:31b in atlas.json under the ollama provider with limit.context 262144 and limit.output 16384.
- 04Set model to ollama/gemma4:31b and small_model to a 3B or 4B tag so the cheap slot does not evict 20GB of weights.
- 05Run the codebase index through Ollama embeddings so retrieval, generation, and unified-diff review all execute on the same offline stack.
Frequently asked questions
- 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.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Atlas vs Qwen Code: Terminal AI Coding Agents in 2026
Atlas and Qwen Code are leading terminal AI coding agents in 2026. Compare Atlas's TUI, permission-gated tools, and free core with Qwen Code's 1M token context, Agent Teams, and Alibaba Cloud hosting.
Atlas for Julia: A Terminal-Native AI Coding Agent for Project.toml Packages in 2026
Atlas is a terminal-native AI coding agent for Julia in 2026. It reads dispatch signatures and Project.toml [deps], fixes type instabilities, runs Pkg.test(), and applies JuliaFormatter.
Atlas vs Cline: Terminal AI Coding Agents in 2026
Compare Atlas and Cline, two leading AI coding agents for 2026. Atlas offers terminal-native TUI and permission-gated tools, while Cline integrates with VS Code and provides checkpoint rollbacks.
Atlas for Python in 2026
Atlas is a terminal-native AI coding agent for Python in 2026. Run it in a repo with a pyproject.toml or requirements.txt and review every diff before it lands.
Atlas for Astro: Islands, Content Collections, and Zero JS by Default in 2026
Atlas is a terminal-native AI coding agent for Astro in 2026. It reads astro.config.mjs, src/pages, and content collection schemas, drops needless client:load directives, and runs astro check.
Atlas vs Mistral Vibe for Code: Terminal AI Coding Agents in 2026
Compare Atlas and Mistral Vibe for Code in 2026. Atlas offers terminal-native TUI, explicit diffs, and BYO models. Mistral Vibe for Code provides a four-model stack, multi-platform access, and EU data sovereignty.
Atlas vs JetBrains AI Assistant: Terminal AI Coding Agents in 2026
Atlas and JetBrains AI Assistant comparison for 2026. Atlas offers a terminal-native TUI and BYO model keys, while JetBrains AI Assistant integrates into IDEs with credit-based cloud models.
Atlas vs Amp: Terminal AI Coding Agents in 2026
Compare Atlas, a terminal-native AI coding agent with free core and local embeddings, against Amp, Sourcegraph's agent featuring Oracle and Orbs, for developers in 2026.