Best local LLMs for agentic coding on Apple silicon

You've decided to run your coding agent locally. Now comes the question that decides whether you'll actually like it: which model?

A silver Mac Studio on a wooden desk, the class of Apple silicon hardware that runs local coding models.
Photo by Joey Banks on Unsplash.

The hardware is a purchase. The model is a download.

That asymmetry is the whole reason this page exists. Pick the wrong Mac and you live with it for years. Pick the wrong model and you type one Ollama command and try again.

So people relax and grab whatever tops this month's leaderboard. Then the agent forgets its own plan mid-task, or generates at a pace that makes you nostalgic for dial-up, and they conclude local coding doesn't work. The model was wrong for the machine, not wrong in general.

This guide is the missing selection step. The agentic coding setup guide covers getting the winner running. This page is about picking the winner.

The four questions that pick the model

A model card is a dating profile. Everyone lists their best benchmarks, nobody mentions what they're like to live with. These four questions are what actually predicts the experience, in the order they eliminate candidates.

1. Does it fit in memory the GPU can address?

The weights and the context window have to sit in unified memory at the same time, and macOS only lets the GPU address roughly two-thirds to three-quarters of what the spec sheet says. A 48GB Mac presents about 36GiB to Ollama. If the model doesn't fit, nothing else about it matters.

Remember that agentic coding is the hungriest context workload there is. The agent stuffs your codebase, its plan, and every tool result into the window, so budget tens of gigabytes beyond the weights, not hundreds of megabytes.

2. Dense or mixture-of-experts?

Token generation speed is approximately memory bandwidth divided by the bytes read per token. A dense model reads every weight for every token: an 18GB model on a 273GB/s Mac mini tops out around 15 tokens per second, and on a 614GB/s M5 Max around 34. A mixture-of-experts model activates only a few billion parameters per token, so the same division yields several times the speed on the same machine.

This is why the MoE question matters more on cheaper hardware. On a Mac mini, MoE is often the difference between usable and not. On an Ultra-class Studio with 1.2TB/s of bandwidth, dense models are already fast and their per-token quality tends to be steadier.

3. Is the context window agent-sized?

Ollama's own documentation puts the floor for coding agents at 64,000 tokens. A model that tops out below that will lose the plot mid-task no matter how well it writes code, and a model trained for 256K gives the agent room to hold a real codebase in its head. Check the trained context length, not the default your runtime happens to configure, which is a separate trap the setup guide covers in detail.

4. Coding-tuned or general?

At equal size, a coding-tuned model usually writes better code. But agentic coding rewards more than code: the loop lives or dies on instruction following, tool calling, and staying on task across a long session, and strong general models are often better at exactly that. This is the question benchmarks answer worst, and the reason the final call belongs to a two-week trial on your own backlog rather than to a leaderboard.

The contenders

Five open-weight models are worth your download bandwidth right now. Sizes below are the quantized builds you would actually run, 4-bit unless noted.

Model Architecture 4-Bit Size Trained Context Role
Qwen3.8-27B 27B dense 18GB 256K The all-rounder this series runs
Qwen3-Coder-30B-A3B 30B MoE, about 3B active 19GB 256K The speed pick for modest bandwidth
Gemma 4 26B 26B dense, multi-token prediction 16GB 128K The efficiency pick
DeepSeek V4 Flash 284B MoE, about 13B active 155GB, or 90GB at 2-bit 1M The flagship a Mac Studio can actually house
GLM-5.3 753B MoE, about 40B active 425GB, heavy quants smaller 1M The open-weight ceiling, for 512GB Ultras

Qwen3.8-27B: the default

This is the model the rest of this series runs, and the reasons are the four questions above rather than sentiment. It fits comfortably at 64GB, its 256K trained context is genuinely agent-sized, and its instruction following is what makes agent mode viable at all. The qwen3.8 tag on Ollama is one command away. If you have the bandwidth to run a dense 27B at usable speed, start here.

Qwen3-Coder-30B-A3B: the speed pick

The name decodes as 30 billion parameters with about 3 billion active per token, and that second number is the one your memory bus feels. Reading a tenth of the weights per token moves the generation ceiling from teens to triple digits on the same Mac mini. It is also coding-tuned, so on constrained hardware you're not trading quality for speed so much as trading a little generality for a lot of throughput. Grab it from the qwen3-coder tag on Ollama. If your cluster is Mac minis rather than Studios, this is probably your model.

Gemma 4 26B: the efficiency pick

Google's entry ships with multi-token prediction, which lets speculative decoding draft several tokens per read and verify them in one pass. In practice that recovers a chunk of the MoE speed advantage while keeping a dense model's consistency. Its 128K context is half of what the Qwen pair trains for, which for agentic work on a large codebase is a real limit rather than a spec-sheet footnote. Pull the 26B from the gemma4 tag and keep it resident as the second model for review passes and quick edits.

DeepSeek V4 Flash: the flagship a Studio can house

This is the model that moved the local ceiling this year. 284 billion parameters with about 13 billion active per token means it reasons like a frontier model and generates like a mid-size one, and its 1M-token context window is trained in rather than bolted on. Community testing puts the 4-bit build around 35 tokens per second on a 512GB M3 Ultra, which is a frontier-class agent running at usable speed with the meter off.

The catch is residency. The 4-bit conversions land around 155GB, which wants a 256GB Studio, and the aggressive 2-bit builds near 90GB squeeze onto a 128GB machine with a real quality tax. If you specified an M5 Ultra from the hardware comparison, this is what all that unified memory is for. The deepseek-v4-flash tag carries it.

GLM-5.3: the open-weight ceiling

Z.ai's flagship is the most capable open-weight coding model you can download right now, built specifically for coding agents and scoring 88.2 on Terminal-Bench 2.1. At 753 billion parameters with about 40 billion active, even the 4-bit build is around 425GB, so a genuinely local run means a 512GB Ultra-class Studio and an aggressive quant, and most teams will run it hosted instead. Its smaller multimodal sibling on the glm-5.3 family tags, GLM-5.3-Flash with 18 billion active parameters, is the one to watch for the local tier.

The ones you license instead of house

Open weights and locally runnable are different claims, and the gap between them is now hundreds of gigabytes. Kimi K3 is a 2.8-trillion parameter monster whose 1-bit quant still wants a 650GB floor, per Unsloth's deployment docs. DeepSeek V4 Pro at 1.6 trillion and the 2.4-trillion Qwen3.8 flagship are the same story. MiniMax-M3 at 428 billion is the borderline case, quantizable onto a 512GB Ultra if you want its multimodal input. For everything in this paragraph, you are choosing a hosting provider, not a Mac, and that decision has its own compliance math covered in the security and compliance article.

Match the model to the Mac

Cross the four questions with the hardware you own and the field usually collapses to one obvious answer per machine.

Your Mac Run This Why
32GB Mac mini Qwen3-Coder-30B-A3B MoE speed makes modest bandwidth usable, and the context window has to stay capped anyway at this memory size.
64GB Mac mini or MacBook Pro Qwen3.8-27B The series pick. Full 256K context fits, and the dense model's steadiness pays for itself across long agent sessions.
128GB M5 Max Mac Studio DeepSeek V4 Flash at 2-bit The 90GB builds put a 284B-class agent on a desktop. Tight on context, and the quality tax is real, so weigh it against Qwen3.8-27B with room to breathe.
256GB Ultra-class Mac Studio DeepSeek V4 Flash at 4-bit The 155GB conversion fits with agent-sized context to spare, at roughly 35 tokens per second on Ultra-class bandwidth.
512GB M5 Ultra Mac Studio GLM-5.3, heavily quantized The only Mac where the open-weight ceiling is reachable at all, with DeepSeek V4 Flash at full quality as the safer resident.

To check any pairing not listed here, the local LLM memory and speed calculator estimates required unified memory and generation speed for every chip from M1 to M6. And if the answer to the hardware question is still open, the M5 Ultra vs. M5 Pro vs. M6 comparison is the buying decision this table assumes you've already made.

Whichever row is yours, the final step is the same: pull the model, set the context window correctly, and wire it into your editor. That is exactly what the agentic coding setup guide walks through, including the context window trap that makes a right model feel like a wrong one.

Join the Local AI Group

Scaling localized AI workloads in enterprise and hyper-growth environments requires solving highly complex infrastructure, secure networking, and hardware optimization challenges at scale.

The Local AI Group is the premier global technical network designed exclusively for active senior engineering leaders, including Chief Technology Officers, VPs of Engineering, and Directors of Engineering at Fortune 500 companies and top-tier startups. Our invitation-only space connects leaders scaling production-grade local AI systems. We bypass commercial marketing hype to focus strictly on hardware topologies, private LLM clusters, enterprise security frameworks, and custom sandboxing alongside elite peers operating at the absolute top of the global technology sector.

Roundtable focus areas

  • Direct exchange on physical cluster topologies, high-throughput GPU clusters, and enterprise server architecture
  • Vetted blueprints for thermodynamic profiles, process orchestration, and private model deployment pipelines
  • Hardened boundary defense frameworks for satisfying SOC 2, ISO 27001, and GDPR perimeters with repatriated infrastructure

I vet each application myself to ensure a high-signal environment of peer practitioners.

Apply to Join the Slack Group

Sharing confidential or proprietary information is strictly forbidden. Participation is subject to the Terms of Use.

Building a Mac cluster for local AI

This article is part of an in-depth technical series detailing the creation of a localized Apple silicon server cluster for enterprise AI inference, covering Mac mini and Mac Studio hardware, local agent hosting, and agentic coding.

Overview
How we built an M4 Mac mini cluster to cut AI cloud spend by $40k/year

The business case and localized architecture that cut enterprise Google Cloud spend by $40,000 annually.

Read Article
Part 1
Local AI use cases: local vs. cloud AI architecture

The enterprise decision matrix mapping air-gapped compliance, agentic coding, robotics, batch execution, and offline operations to local Apple silicon or cloud APIs, plus the hybrid local-first framework.

Read Article
Part 2
M5 Ultra vs. M5 Pro vs. M6 for local AI

Whether to buy one 512GB M5 Ultra Mac Studio, one M5 Pro Mac mini, or a swarm of 2nm M6 Mac minis, with the memory bandwidth math that decides it.

Read Article
Part 3
How to build an M6 or M5 Pro Mac mini cluster

Step-by-step setup guide covering hardware configuration, base macOS setup, secure remote access, process management, and cloud fallbacks.

Read Article
Part 4
Run Qwen 3.8 on Apple silicon, without rate limits

Running Qwen3.8-27B locally with Ollama and Zoo Code, plus the Mac mini and Mac Studio memory bandwidth numbers that decide whether local agentic coding is usable.

Read Article
Part 5 Currently Reading
Best local LLMs for agentic coding on Apple silicon

Qwen 3.8, Qwen3-Coder, Gemma 4, DeepSeek V4 Flash, and GLM-5.3 compared for agentic coding, with the memory math that matches each model to the Mac that runs it.

Current Page
Part 6
Local AI agent hosting on M6 and M5 Pro Mac minis

Configuring a secure, low-power private AI appliance for always-on autonomous agent workflows.

Read Article
Part 7
Local AI Security: ISO 27001:2022, SOC 2 & GDPR Compliance

Architecting a hardened physical perimeter to satisfy rigorous enterprise ISO 27001:2022 and SOC 2 audits, plus the GDPR case for keeping inference in-house.

Read Article

Picking models is the easy half

Getting an engineering org to actually adopt local AI is the hard half, and it is what I speak about. My hands-on workshop, Modernize Your Engineering Org for the AI Era, takes teams from their first local model to a production agentic coding stack.