For a long time, picking an open language model for your own hardware felt like walking a tightrope. Small 7B–8B models answered fast, but stumbled over multi-step logic and mangled JSON syntax. Meanwhile, 70B giants demanded expensive server GPUs and crawled on consumer cards.
Google DeepMind solved that dilemma with the Gemma 4 open-weight family. Leading the lineup is Gemma 4 31B, a dense 30.7-billion-parameter model released under a clean Apache 2.0 commercial license, complete with a 256,000-token context window and native function calling.
Let's check its benchmark scores and walk through building llama.cpp to run it on your own PC.
Benchmark Records: Jumping from 6% to 86%
The big surprise here is how well a compact dense model competes against much larger networks:
- On the AIME 2026 math competition, it scored 89.2%, edging out Llama 4 (88.3%).
- On the academic GPQA Diamond test, it hit 84.3%.
- The sharpest leap came in agent automation: where Gemma 3 scored a modest 6.6%, Gemma 4 31B surged to 86.4%.
- On Chatbot Arena, it reached an ELO of 1452, closing in on closed commercial APIs.
Earlier, we explored local coding models and inference optimization along with context compression and quantization. Gemma 4 shows that a dense 31B model in 4-bit GGUF quantization hits the sweet spot for a home workstation.
Building llama.cpp with Hardware Acceleration
For top inference speed, compile llama.cpp from source with CUDA enabled for NVIDIA cards or Metal for macOS:
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
# Build with CUDA hardware acceleration for NVIDIA GPUs
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j$(nproc)
If you are running on an Apple Silicon Mac, swap the CUDA flag for -DGGML_METAL=ON.
Downloading Weights and Running in Console
Download the balanced Q4_K_M quantized file (roughly 18–19 GB of VRAM) and launch an interactive session:
# Download quantized weights via huggingface-cli
huggingface-cli download bartowski/gemma-4-31b-it-GGUF --include "*Q4_K_M*" --local-dir ./models
# Interactive launch offloading all layers to GPU
./build/bin/llama-cli -m ./models/gemma-4-31b-it-Q4_K_M.gguf --chat-template gemma -ngl 99 -c 32768 --temp 0.2 -p "You are an expert systems engineer. Analyze this architecture specification and suggest refactoring steps."
Gemma 4 relies on specific control tokens to structure dialogue and hidden reasoning chains (<|channel>thought ... <channel|>). If you omit --chat-template gemma, llama-cli falls back to a generic template and the model outputs garbled text.
A 256K context window eats up substantial VRAM for the KV cache. To stop the cache from pushing model weights off your GPU, add 8-bit cache quantization flags to your launch command: -ctk q8_0 -ctv q8_0.
Bottom Line
Gemma 4 31B is a major win for developers who value independence and privacy. Its Apache 2.0 license allows unrestricted commercial deployment, while modest hardware requirements let you run a capable agent loop on a single consumer GPU.



