Gemma 4 launched in April 2026 with a significant leap in capability over previous generations — and the Antigravity community picked up on this quickly. For many users, it's the first local model that genuinely competes with cloud APIs for practical daily tasks.
But Gemma 4's architectural changes — an expanded context window, multimodal support, new inference characteristics — mean that settings that worked perfectly for earlier models don't necessarily carry over. This guide systematically covers the five most common Gemma 4 on Antigravity issues, with causes and step-by-step fixes for each.
Gemma 4 Variants and VRAM Requirements
First, clarify which Gemma 4 variant you're running — the requirements differ significantly.
| Model | Full Precision VRAM | Q4 Quantized VRAM | Best for |
|---|---|---|---|
| Gemma 4 2B | ~4 GB | ~1.5 GB | Fast responses, low VRAM |
| Gemma 4 9B | ~18 GB | ~6 GB | Balanced — best for most use cases |
| Gemma 4 27B | ~54 GB | ~16 GB | High-quality output, demanding tasks |
| Gemma 4 27B IT (Instruct) | ~54 GB | ~16 GB | Chat and instruction following |
For comfortable use in Antigravity, the 27B Q4 needs 16 GB+ VRAM. With a 12 GB VRAM GPU, the 9B Q4 is the practical sweet spot.
Issue 1: Gemma 4 Fails to Load
Symptoms
Running ollama run gemma4 stalls partway through, with errors like:
Error: model requires more system memory than is available
Error: Post "...": CUDA error: out of memory
Cause
Gemma 4 — especially 27B — has high memory requirements. Ollama tries to load the full model into VRAM, then falls back to system RAM if VRAM is insufficient. If both are too small, it crashes.
Fix
Step 1: Check available VRAM
# NVIDIA GPU
nvidia-smi --query-gpu=memory.total,memory.free --format=csv
# Apple Silicon — uses unified memory; check in Activity Monitor or iStatsStep 2: Choose the right quantization level
ollama pull gemma4:9b-instruct-q4_K_M # Recommended — best quality/VRAM ratio
ollama pull gemma4:9b-instruct-q8_0 # Better quality if VRAM allows
ollama pull gemma4:2b-instruct-q4_K_M # For systems with under 4 GB VRAMStep 3: Tune GPU/CPU layer distribution
If you can only partially fit the model in VRAM, split it across GPU and CPU:
# Load 24 layers onto GPU, rest stays in CPU RAM
OLLAMA_NUM_GPU=24 ollama serveThe 9B model has around 42 layers; the 27B has 62. Increase this number toward the maximum to maximize GPU usage. Find the highest value that loads without OOM errors.
Issue 2: Inference Speed Is Extremely Slow (Under 1 Token/s)
Symptoms
Output trickles out character by character — practically unusable speed.
Diagnosis and fix
Cause A: Model is running entirely on CPU
When GPU acceleration isn't working, speed drops to 1/10th or worse. Check:
# Watch GPU utilization while inference runs
nvidia-smi dmon -s u
# Check Ollama logs for GPU layer assignment
cat ~/.ollama/logs/server.log | grep "layers"
# "using 0 layers on GPU" = full CPU modeIf GPU layers are at 0, adjust OLLAMA_NUM_GPU as described in Issue 1, Step 3.
Cause B: Context window is unnecessarily large
Gemma 4 supports up to 128K tokens of context, but allocating the full KV cache for this size is expensive. If you're not doing long-context work, cap it:
In Antigravity's model settings, set the context length to 8,192 or 16,384 tokens. This alone can provide a significant speed improvement on hardware that's marginally capable of running the model.
Cause C: Flash Attention not active
Gemma 4 supports Flash Attention, which speeds up long-context processing. Some older Ollama versions have it disabled:
# Update to the latest Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Confirm Flash Attention status
cat ~/.ollama/logs/server.log | grep -i "flash"Issue 3: Multimodal (Image Input) Not Working
Symptoms
Gemma 4 supports image understanding, but when you send an image through Antigravity, the model says it can't see the image or ignores it entirely.
Causes and fixes
Cause A: Not using the Instruct (IT) version
Multimodal features are reliable only on the instruction-tuned version (gemma4:9b-instruct). The base model doesn't handle images predictably.
ollama pull gemma4:9b-instruct-q4_K_M # IT version required for multimodalCause B: Ollama version is too old
Gemma 4 multimodal support was added in a more recent Ollama update. Older versions silently ignore image inputs.
ollama --version # Check current version
curl -fsSL https://ollama.ai/install.sh | sh # UpdateCause C: Antigravity model type set to text-only
In Antigravity's model settings, if the model type is configured as "text-only," image inputs will be stripped before reaching the model. Change it to "multimodal" or "vision." The exact setting name varies by Antigravity version — check the model configuration panel.
Issue 4: Output Quality Is Worse Than Expected
Symptoms
After switching to Gemma 4, you're seeing more repetition, hallucination, or responses that miss the point of the question.
Causes and fixes
Cause A: Temperature is too high
Gemma 4 was tuned with creativity in mind, and the default temperature in many integrations is higher than optimal for factual tasks.
Recommended settings in Antigravity:
temperature: 0.3–0.5 (factual tasks, summarization, analysis)
temperature: 0.7–0.8 (creative tasks, brainstorming)
top_p: 0.9
Cause B: Chat template mismatch
Gemma 4 Instruct uses a specific chat template format (<bos><start_of_turn>user...). If you're using Antigravity in OpenAI-compatible API mode and the template isn't being applied correctly, output quality degrades.
Ollama handles this automatically for Gemma 4. If you're connecting via a raw OpenAI API endpoint, verify that the Gemma chat template is being applied, not the default ChatML format.
Cause C: No repeat penalty configured
If you're seeing repetitive output, increase the repeat penalty:
repeat_penalty: 1.1–1.2
Adjust in increments of 0.05 — too high and output becomes incoherent.
Issue 5: Model Not Appearing in Antigravity's Model List
Symptoms
You've run ollama pull gemma4 successfully, but Gemma 4 doesn't appear in Antigravity's model selection dropdown.
Fix
- Confirm Ollama recognizes the model:
curl http://localhost:11434/api/tags | python3 -m json.tool | grep name-
Refresh the model list in Antigravity (or restart the app if there's no refresh button)
-
Verify the base URL in Antigravity matches Ollama's actual address
-
Check whether Antigravity has a model name filter that might be excluding
gemma4— some versions filter models by prefix
Recommended Settings Summary
Based on testing across multiple hardware configurations, these settings provide consistent performance for most use cases:
8 GB VRAM GPU:
- Model:
gemma4:9b-instruct-q4_K_M - Context length: 8,192 tokens
- GPU layers: maximum available (typically 28–35)
- Temperature: 0.5
16 GB VRAM GPU:
- Model:
gemma4:27b-instruct-q4_K_M - Context length: 16,384 tokens
- GPU layers: maximum (48–62)
- Temperature: 0.5
Apple Silicon Mac (16 GB unified memory):
- Model:
gemma4:9b-instruct-q4_K_M - Context length: 8,192–16,384 tokens
- No
OLLAMA_NUM_GPUneeded — Apple Silicon maximizes GPU automatically
Gemma 4 is currently among the strongest local models for multilingual tasks. The Antigravity + Gemma 4 combination, when configured correctly, provides a genuinely useful AI assistant that doesn't depend on cloud APIs. The setup investment is worth making properly.