DEV Community

Cover image for πŸ’» I Tried Running Gemma 4 Locally on My Mac to Refactor Code. After 15 Minutes, I Hit Ctrl+C.
Rishikesh Vedpathak
Rishikesh Vedpathak

Posted on Edited on Originally published at rishikesh-vedpathak.hashnode.dev

πŸ’» I Tried Running Gemma 4 Locally on My Mac to Refactor Code. After 15 Minutes, I Hit Ctrl+C.

Running frontier-level AI models locally on a MacBook feels like living in the future- until you actually try to use one for real software engineering work.

Recently, I spun up gemma4:12b locally using Ollama on my Mac for what seemed like a straightforward task: reviewing a JavaScript tokenizer script and applying the suggested fixes.

The code review went great. Snappy feedback, solid analysis, and I was feeling optimistic. Then... I asked it to actually write the updated code.

Thinking... [β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰------------------------] 15 mins passed

Enter fullscreen mode Exit fullscreen mode

My Mac’s fans spun up. My terminal cursor blinked. After nearly 15 minutes of waiting, I hit Ctrl+C.

My immediate takeaway? Local AI isn’t worth the wait for complex, generation-heavy coding tasks.

But as it turns out, I fell straight into a few hidden traps of local LLM behavior on Apple Silicon. Here’s what went wrong under the hoodβ€”and how to make local models actually usable. πŸ‘‡


πŸ”Ž Why It Took 15+ Minutes (The Anatomy of a Stall)

When a local model crawls on a task it should easily handle, it usually comes down to three silent killers:

1️⃣ The Silent Memory Spillover πŸ§ πŸ’€

Apple Silicon's Unified Memory is amazing, but it has limits.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   YOUR 16GB MAC RAM                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   macOS + IDE + Apps  β”‚       GPU VRAM Boundary        β”‚
β”‚       (~6-8 GB)       β”‚   (Ollama is forced to swap)   β”‚
β”‚                       β”‚      🚨 1-2 tokens/sec 🚨      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


Enter fullscreen mode Exit fullscreen mode

A 12B model needs about 8 GB just to load, plus extra for the context window. Once you factor in your IDE and browser tabs, macOS quietly offloads processing to the CPU or SSD swap , dropping generation from a fast 35 tokens/sec to a painful 1–2 tokens/sec.

2️⃣ The Hidden "Thinking" Trap πŸ’¬πŸ€―

Advanced models like Gemma 4 use an internal reasoning channel (<|thought|>).

  • When reviewing , the thinking phase is short.
  • When generating , the model can burn thousands of invisible tokens planning edge cases before writing a single line of JS.

3️⃣ Full-File Regeneration πŸ“„β³

Cloud APIs have massive clusters to output full files in seconds. Locally, every token costs you time. Forcing the model to rewrite a 300-line script instead of target diffs multiplies your wait time exponentially.


πŸ› οΈ 4 Quick Fixes for Speed

Before giving up on local coding, use these optimizations to supercharge your setup:

🚨 Speed Tip 1: Run ollama ps

Always verify if you are hitting a RAM bottleneck. Open a second terminal while it runs:

> ollama ps

NAME        ID            SIZE    PROCESSOR  CONTEXT  RUNNER  UNTIL              
gemma4:12b  c7292fb00b86  7.7 GB  100% GPU   4096     mlx     4 minutes from now


Enter fullscreen mode Exit fullscreen mode

If the processor column says anything less than 100% GPU , your model has spilled over into CPU/swap territory.


🚨 Speed Tip 2: Switch to MLX Builds (Multi-Token Prediction)

If you are on Apple Silicon, GGUF builds can waste potential. Ollama’s MLX-backed gemma4:12b-mlx uses speculative decoding to boost speeds. On a 16GB RAM machine, drop to gemma4:e4b-mlx to keep the footprint light.


🚨 Speed Tip 3: Cap Your Context Window πŸ“

Large context windows destroy performance on consumer hardware. Tighten the limits:

ollama run gemma4:12b-mlx --ctx-size 8192

Enter fullscreen mode Exit fullscreen mode

🚨 Speed Tip 4: Ask for Diffs, Not Full Files βš™οΈ

Prompt specifically to keep output short:

"Review this file, then output ONLY a unified diff or the specific modified functions. Do not rewrite unchanged code."


βš–οΈ The Verdict: Where Should Local Models Actually Live?

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       πŸš€ USE CLOUD FOR       β”‚       πŸ”’ USE LOCAL FOR          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Massive refactoring        β”‚ β€’ Zero-latency auto-complete    β”‚
β”‚ β€’ Multi-file architectural   β”‚ β€’ NDAs & strict client privacy  β”‚
β”‚   changes                    β”‚ β€’ Offline coding (flights)      β”‚
β”‚ β€’ Writing entire scripts     β”‚ β€’ Fast, iterative queries       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


Enter fullscreen mode Exit fullscreen mode

Local AI is not a cloud replacement for heavy-lifting refactoring on a consumer Mac. But when configured right, it acts as a perfect private, offline co-pilot. Keep the small tasks local, but send the heavy lifting to the cloud!


πŸ’‘ Have you tried running models locally for your dev workflow? What is your go-to setup? Let’s chat in the comments!

Top comments (0)