Running Gemma 4 locally with LM Studio's new headless CLI and Claude Code
TL;DR Highlight
Gemma 4 26B ran at 51 tok/s on a MacBook via LM Studio's headless lms CLI
Who Should Read
A developer worried about API costs and privacy who wants to plug a local LLM into Claude Code or other CLI agents
Core Mechanics
- MoE makes 26B run like 4B
- Gemma 4 26B-A4B activates 8 of 128 experts (3.8B parameters) per token.
- It hit 51 tokens/s on a 14-inch MacBook Pro M4 Pro with 48GB.
- The author says it slows down noticeably inside Claude Code.
- LM Studio 0.4.0 runs without a GUI
- The llmster daemon splits out the inference engine, and the lms CLI handles download, load, chat and serving.
- It works on servers, CI/CD and SSH sessions.
- Concurrent requests use continuous batching, which merges requests into one batch.
- Each context doubling adds 3-4GiB
- The base model takes about 17.6GiB regardless of context.
- 48K context needs about 21GiB and 256K needs 37.48GiB.
- lms load --estimate-only calculates this before loading.
- Benchmarks close to the 31B dense model
- 26B-A4B scores 82.6% on MMLU Pro and 88.3% on AIME 2026.
- The 31B dense scores 85.2% and 89.2%.
- Elo is about 1441 for 26B-A4B versus about 1451 for 31B.
- Skip speculative decoding on MoE
- Verification pulls in different experts per token, which blows up memory bandwidth.
- Mixtral benchmarks showed a 39% speedup on code but a 54% slowdown on math.
- The author advises skipping it for Gemma 4 26B-A4B.
- LM Studio's server also speaks the Anthropic API
- The OpenAI-compatible API is at localhost:1234/v1.
- The desktop server view lists POST /v1/messages for the Anthropic protocol.
- The author used a claude-lm alias to point Claude Code at it.
Community Reactions
- tau2 bench shows it trailing Qwen
- One commenter got 40 tok/s on an M1 Max 64GB, nearly double Qwen3.5 35B-A3B.
- But tau2 bench shows 68% versus 81% for Qwen, so they don't expect it to do well on tool-heavy agentic work.
- Reported endless tool-call loops
- One commenter said finding the largest text file in subfolders sent it into an endless tool-call loop, even at Q8.
- Another said an interleaved jinja chat template in llama.cpp fixed repetition and stalls.
- Correction: MoE doesn't save RAM
- A commenter noted all weights must stay in memory, so MoE only improves tok/s, not memory use.
- Simpler alternatives were shared
- One comment suggested ollama launch claude --model gemma4:26b.
- Others mentioned llama-server with uvx swival, and said omlx beats ollama on Apple Silicon.
How to Apply
- Estimate memory for your Mac with estimate-only
- Install the lms CLI and run lms load google/gemma-4-26b-a4b --estimate-only --context-length 48000.
- Vary the context and find the largest value after subtracting 4-6GB for the OS.
- Use the local model only for review and drafting
- For privacy- or cost-sensitive tasks, run lms server start and set localhost:1234/v1 as the base URL.
- Keep tool-heavy agent work on a cloud model.
- Test tool-call loops on the local model
- Run a short tool task like finding files and check for repeated calls.
- If it loops, enable the interleaved chat template in llama.cpp.
- Tune TTL and parallel slots for your usage
- Pass --ttl 1800 to lms load on tight memory to unload idle models.
- Start with 2 parallel slots and 48K context.
Try It
# Paste into a terminal (macOS/Linux): load Gemma 4 26B headless with LM Studio and start the server
curl -fsSL https://lmstudio.ai/install.sh | bash
lms daemon up
lms get google/gemma-4-26b-a4b
lms load google/gemma-4-26b-a4b --estimate-only --context-length 48000
lms load google/gemma-4-26b-a4b --context-length 48000 --ttl 1800
lms chat google/gemma-4-26b-a4b --stats
# In another terminal: lms server start (http://localhost:1234/v1)Terminology
Related Papers
A Beginner's Guide to Local AI with Inkling, Qwen, and Unsloth
Install Unsloth Desktop, load a quantized Qwen model, and share a private ChatGPT-like AI on your home LAN.
Muru – AI-assisted Rust server for Python apps by mod_WSGI's creator
mod_wsgi's creator is building Muru, an AI-assisted Rust ASGI/WSGI server, documenting it in public
87% of the Anthropic power will come from gas and 11% from coal in 2028
Analysis of Anthropic's contracted data centers: 87% gas, 11% coal power in 2028
Anthropic’s Nasdaq debut
Anthropic listed on Nasdaq and closed its first day below its opening price.
OpenAI still has a WebRTC Problem
WebRTC drops late audio, hurting voice AI; MoQ retransmits and buffers instead
Gemini 4 Neon
Gemini 4 Neon cuts cost per task 32% versus Carbon, at $3 input and $15 output per million tokens
AI is killing All About Berlin
After Google AI Overviews, a Berlin guide site lost 70-75% of its traffic.
Not Everything Needs an LLM
PostHog used small decision models to skip 98.7% of expensive LLM calls