Local and Private AI
Best Local LLM for Coding in 2026 (Picked by Your Hardware)
By Amjid Ali · · 7 min read

In this article
The best local LLM for coding in October 2026 depends on your memory. With 24 to 32 GB of VRAM or Mac unified memory, run Qwen3.8 27B (dense, Apache-2.0, 18 GB on Ollama) or Devstral Small 2 24B (Apache 2.0, 15 GB). With 64 GB or more, try Qwen3-Coder-Next, an 80B mixture-of-experts coder with 3B active parameters (52 GB at 4-bit). On a 16 GB machine, gpt-oss 20B (14 GB) is the practical choice. All of them run in Ollama, LM Studio or llama.cpp, and all of them can drive agent tools such as Claude Code through a local API.
Quick picks
| Your memory | Pick | Ollama tag | Download | License | Notes |
|---|---|---|---|---|---|
| 16 GB | gpt-oss 20B | gpt-oss:20b |
14 GB | Apache 2.0 | OpenAI's open-weight model; Ollama says it runs with as little as 16 GB |
| 24 GB | Devstral Small 2 | devstral-small-2 |
15 GB | Apache 2.0 | Built for agents that explore codebases and edit multiple files |
| 24 to 32 GB | Qwen3.8 27B | qwen3.8:27b |
18 GB | Apache-2.0 | Newest dense Qwen; strong vendor-reported coding scores |
| 32 GB | Qwen3.6 35B-A3B (coding tag) | qwen3.6:35b-a3b-coding |
23 to 24 GB | Apache-2.0 | MoE: 35B total, 3B active, so it computes like a small model |
| 64 GB+ | Qwen3-Coder-Next | qwen3-coder-next |
52 GB (q4_K_M) | Apache-2.0 | Dedicated agentic coder, 80B total, 3B active, 256K context |
| 128 GB Mac | Qwen3.8-Flash-Next | qwen3.8-flash-next:125b-mlx |
105 GB | qwen-community-1.0 | 125B MoE, about 6B active; MLX build |
Sizes are the download sizes Ollama lists. Leave headroom for context: coding agents read a lot of files.
How to read coding benchmarks
Vendors publish their own numbers, usually on SWE-bench Verified, SWE-bench Pro, LiveCodeBench or Terminal-Bench. They are useful signals, with three caveats:
- Different benchmarks are not comparable. SWE-bench Pro is harder than SWE-bench Verified, so a lower Pro score can mean a stronger model.
- The harness matters. The same model scores differently depending on the agent scaffold and settings the vendor used.
- Local quantization costs a little quality. Vendor scores are usually measured at full precision; your 4-bit download may do slightly worse.
So treat the numbers below as "worth trying", then test on your own repository.
The models in detail
Qwen3.8 27B: the best all-rounder for 24 to 32 GB
The Qwen3.8-27B model card describes a "compact, deployment-friendly dense model" with native vision, 262,144 tokens of native context (extendable to 1M with YaRN) and an Apache-2.0 license. Qwen reports 61.7 on SWE-bench Pro, 73.0 on Terminal Bench 2.1 and 90.3 on LiveCodeBench v6. On Ollama it is qwen3.8:27b at 18 GB, with an MLX build (27b-mlx) for Macs. It is also among the most downloaded models on Hugging Face right now.
Because it is dense, every token uses all 27B parameters, so it is slower per token than a 3B-active MoE model, but it tends to be more consistent.
Devstral Small 2: the agentic specialist on one GPU
Mistral's Devstral Small 2 is a 24B model with a 256k context and an Apache 2.0 license, built for software-engineering agents. Its model card lists 68.0% on SWE-bench Verified and says it is compact enough to run on a single RTX 4090 or a Mac with 32 GB of RAM. Ollama describes it as excelling "at using tools to explore codebases, editing multiple files". At 15 GB, it leaves more room for context than the 27B to 31B options.
Qwen3-Coder-Next: the dedicated coder for big-memory machines
Qwen3-Coder-Next is built on Qwen3-Next-80B-A3B: 80B total parameters with 3B activated per token, 256K native context, Apache-2.0. Its card lists 70.6 on SWE-bench Verified, 44.3 on SWE-bench Pro and 36.2 on Terminal-Bench 2.0, and names Claude Code, Qwen Code, Cline and others as supported agents.
The catch is memory. Only 3B parameters compute per token, which makes it quick, but all 80B must be loaded: 52 GB at q4_K_M and 85 GB at q8_0 on Ollama. That puts it in 64 GB Mac or multi-GPU territory.
Qwen3.6 35B-A3B: MoE speed in 32 GB
Qwen3.6-35B-A3B is a mixture-of-experts model with 35B total and 3B activated parameters under Apache-2.0. Ollama ships dedicated coding tags (for example qwen3.6:35b-a3b-coding, 23 to 24 GB) and lists "upgrades in agentic coding" in its description. If Qwen3.8 27B feels slow on your machine, this is the one to compare against.
gpt-oss 20B: the 16 GB option
OpenAI's gpt-oss 20B is Apache 2.0, supports tools and reasoning, and has its MoE weights quantized to MXFP4 (about 4.25 bits per parameter). Ollama says it runs on systems with as little as 16 GB of memory. It is a general model rather than a coding specialist, but it is the most capable option many 16 GB machines can hold with room for context.
Qwen3.8-Flash-Next: if you have 128 GB
Qwen3.8-Flash-Next is a 125B mixture-of-experts model with about 6B activated per token, released in August 2026 under the qwen-community-1.0 license (not Apache). Its card reports 62.5 on SWE-bench Pro. Ollama's MLX build is 105 GB, so this is for Mac Studio-class machines.
Still useful: older coding models
qwen2.5-coder (0.5B to 32B) and qwen3-coder (30B, 480B) remain among the most pulled coding models on Ollama. Newer models have overtaken them for agent work, but the small Qwen2.5-Coder sizes are still handy for fast autocomplete.
Hardware: weights plus context
For coding, context is not optional. An agent reads files, diffs and test output, and Ollama's docs recommend at least 64,000 tokens of context for coding tools. That context lives in the KV cache, which can add several gigabytes on top of the download size. A 15 to 18 GB model on a 24 GB card with 64k context is a comfortable fit; a 24 GB model on a 24 GB card is not.
Two ways to stretch memory:
- Quantize the KV cache. In Ollama,
OLLAMA_KV_CACHE_TYPE=q8_0uses about half the memory of the default f16 when flash attention is on. - Prefer MoE on Macs with lots of memory. A 3B-active MoE model generates faster than a 27B dense one, as long as you can load it.
Our local LLM hardware guide shows the full arithmetic.
How to use a local model for coding
In Claude Code
Ollama has a one-command integration:
ollama launch claude
Or set it up by hand, as the Ollama docs show:
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3.8:27b
Start the Ollama server with a bigger context first (OLLAMA_CONTEXT_LENGTH=64000 ollama serve). Ollama notes that hosted web search and some advanced tool controls are not fully supported this way. LM Studio also offers an Anthropic-compatible endpoint if you prefer it.
In other agents and IDEs
ollama launch also supports Codex, Copilot CLI, Droid and OpenCode. Any editor extension that accepts an OpenAI-compatible endpoint can use http://localhost:11434/v1 (Ollama) or LM Studio's local server. For a comparison of the main coding tools themselves, see Claude Code vs Codex vs Cursor and our best AI coding assistant guide.
Common problems and fixes
Local coding setups fail in predictable ways. Most are context or configuration problems, not model problems.
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent forgets the task after a few files | Context still at Ollama's default (4k on GPUs under 24 GiB) | Start the server with OLLAMA_CONTEXT_LENGTH=64000 or higher |
| Tool calls come back as plain text | Model without tool support, or a template mismatch | Use a model the library tags with tools; update Ollama |
| Very slow after a few turns | Context growth pushed part of the model to CPU | Check ollama ps; shorten context, quantize the KV cache or pick a smaller model |
| Edits break unrelated code | Model is too small for multi-file work | Move up a size, or keep the local model to single-file tasks |
| Good at Python, weak at your stack | Training mix | Try a second model family; Qwen, Mistral and Google models differ |
| Out of memory when loading | Download size plus context exceeds memory | Choose a smaller quantization tag or a smaller model |
Two habits help any local model:
- Give it a project rules file. A short file describing the stack, test command and conventions, loaded at the start, saves the model from rediscovering them. This is basic context engineering.
- Keep tasks scoped. "Fix the failing test in
billing/tax.py" works far better locally than "improve the billing module".
How to choose for yourself
Run this simple test on each candidate:
- Pick three real tasks from your own repo: a bug fix, a small feature, and a refactor across files.
- Run each model in the same agent with the same context length.
- Score: did it finish, did tests pass, how many corrections did you make, and how long did it take?
You will learn more from an afternoon of this than from any leaderboard. A pattern that works well: a local model for private code, routine edits and offline work, and a frontier cloud model for the hardest problems. New to local models? Start with how to run an LLM locally.
Frequently asked questions
What is the best local LLM for coding?+
For a 24 to 32 GB GPU or Mac, Qwen3.8 27B and Devstral Small 2 24B are the strongest all-round picks in October 2026. With 64 GB or more, Qwen3-Coder-Next (80B total, 3B active) is the dedicated coding model to try. On 16 GB, gpt-oss 20B is the practical starting point.
Can a local LLM replace Claude Code or Copilot?+
For many everyday tasks, yes, but not for everything. The best open models now post strong agentic coding scores, yet frontier cloud models still lead on the hardest multi-file work, and a local model is slower on consumer hardware. Many developers run local for private or routine work and cloud for the hardest jobs.
How much VRAM do I need for a local coding model?+
About 16 GB for a 20B-class model, 24 to 32 GB for 24B to 31B models at 4-bit with a useful context, and 64 GB or more for large mixture-of-experts coders. Coding agents need long context, which adds several gigabytes on top of the weights.
Can I use Claude Code with a local model?+
Yes. Ollama documents `ollama launch claude`, which points the Claude Code tool at a local model through Ollama's Anthropic-compatible API. Use a tool-capable model and a context of at least 64k tokens. The model is open-weight; Claude itself does not run locally.
Which local model is best for code autocomplete?+
Autocomplete needs speed more than depth, so use a small model. Small sizes of Qwen2.5-Coder (0.5B to 14B) or Qwen3.5 (0.8B to 9B) on Ollama are common choices, leaving your larger model free for chat and agent work.
Sources
- Qwen3.8-27B model card, Qwen (Hugging Face)
- Qwen3-Coder-Next model card, Qwen (Hugging Face)
- Qwen3.8-Flash-Next model card, Qwen (Hugging Face)
- Qwen3.6-35B-A3B model card, Qwen (Hugging Face)
- Devstral Small 2 model card, Mistral AI (Hugging Face)
- qwen3.8 on Ollama, Ollama
- qwen3-coder-next on Ollama, Ollama
- devstral-small-2 on Ollama, Ollama
- qwen3.6 tags on Ollama, Ollama
- gpt-oss on Ollama, Ollama
- Ollama model search: coder, Ollama
- Claude Code with Ollama, Ollama
- Context length, Ollama
- Ollama (README), Ollama
- LM Studio developer docs, LM Studio
The weekly AI briefing
Get the guides like this one, once a week
Keep reading
Local and Private AIOllama vs LM Studio: Which Local LLM Tool Should You Use?Ollama is the open-source, CLI-first runner for developers; LM Studio is the polished desktop app. Compare engines, APIs, platforms and licensing, and pick one. · 7 min read
Local and Private AIHow to Run an LLM Locally in 2026: Tools, Hardware and ModelsRun an LLM on your own computer: compare Ollama, LM Studio, llama.cpp, vLLM and Jan, size memory for any model, set up Ollama step by step and pick a model. · 9 min read
Local and Private AILocal LLM Hardware Guide: How Much VRAM and RAM You Really NeedWork out the memory any local LLM needs: weights by quantization, KV cache for context, a sizing table from 3B to 120B, and how GPUs and Macs compare. · 8 min read