Key facts
- Best overall local coding model (24 GB+ GPU or 32 GB+ Mac): Qwen3.8 27B. On Qwen’s own card it scores 61.7 on SWE-bench Pro, 73.0 on Terminal Bench 2.1 and 90.3 on LiveCodeBench v6, and it’s an 18 GB download in Ollama (
qwen3.8:27b). Apache 2.0. - Fastest strong option on the same hardware: Qwen3.6 35B-A3B. It’s a mixture-of-experts model with only 3B active parameters, scoring 73.4 on SWE-bench Verified (Qwen’s figure). It needs 23 GB but generates quickly.
- Best for 16 GB cards: Devstral Small 2 (24B, 15 GB, 68.0% SWE-bench Verified per Mistral) or gpt-oss-20b (14 GB). Both are Apache 2.0.
- Best for 8 GB: Gemma 4 12B (7.7–8.0 GB, LiveCodeBench 72.0 per Google) or Qwen3.5-9B. For autocomplete, use the tiny qwen2.5-coder:1.5b (986 MB).
- These scores are vendor-reported, and each vendor ran its own setup. Use them to build a shortlist, then test the top two on your own repo.
Tested on Coding test: Qwen3.5-4B Q4_K_M via Ollama 0.40.19 on Debian 13, CPU only. Benchmark scores are vendor-reported.
“What’s the best local LLM for coding?” has a new answer every few months, and in late 2026 it depends mostly on how much memory you have. Below are our picks by hardware tier, with each model’s size from Ollama’s library, its license, and the coding scores its developer published. We also explain what those benchmarks mean and how to run your own quick test.
How we built this list: sizes come from Ollama’s library pages (checked today), and benchmark numbers come from each model’s official Hugging Face card. We didn’t run these benchmarks ourselves. We did run a small hands-on coding test with a 4B model on our CPU-only test machine to show what even tiny models can do (results below). Every source is linked at the end.
Best local coding LLMs at a glance
| Model | Ollama tag | Download | Type | License | Best for |
|---|---|---|---|---|---|
| Qwen3.8 27B | qwen3.8:27b |
18 GB | Dense 27B | Apache 2.0 | Best overall, agents |
| Qwen3.6 27B | qwen3.6:27b-coding |
18–19 GB | Dense 27B | Apache 2.0 | Strong all-rounder |
| Qwen3.6 35B-A3B | qwen3.6:35b-a3b |
23 GB | MoE, 3B active | Apache 2.0 | Fast agentic coding |
| Gemma 4 31B | gemma4:31b |
19–20 GB | Dense 31B | Apache 2.0 | Competitive coding |
| Devstral Small 2 | devstral-small-2 |
15 GB | Dense 24B | Apache 2.0 | 16 GB GPUs, SWE agents |
| gpt-oss-20b | gpt-oss:20b |
14 GB | MoE, 3.6B active | Apache 2.0 | 16 GB GPUs, reasoning |
| Qwen3-Coder 30B-A3B | qwen3-coder:30b |
19 GB | MoE, 3.3B active | Apache 2.0 | Code-specialist, long context |
| Gemma 4 12B | gemma4:12b |
7.7–8.0 GB | Dense 12B | Apache 2.0 | 8–12 GB GPUs |
| Qwen3.5-9B | qwen3.5:9b |
6.6–7.6 GB | Dense 9B | Apache 2.0 | 8 GB GPUs |
| Qwen2.5-Coder 1.5B | qwen2.5-coder:1.5b |
986 MB | Dense 1.5B | Apache 2.0 | Tab autocomplete |
The download size is roughly the memory the weights need. You need extra for context: coding agents want 64K tokens or more, which can add several GB. See how much VRAM you need and context windows explained.

Coding benchmark scores (vendor-reported)
| Model | SWE-bench Verified | SWE-bench Pro | Terminal-Bench | LiveCodeBench v6 |
|---|---|---|---|---|
| Qwen3.8 27B | — | 61.7 | 73.0 (TB 2.1) | 90.3 |
| Qwen3.6 27B | 77.2 | 53.5 | 59.3 (TB 2.0) | 83.9 |
| Qwen3.6 35B-A3B | 73.4 | 49.5 | 51.5 (TB 2.0) | 80.4 |
| Gemma 4 31B | 52.0* | 35.7* | 42.9* (TB 2.0) | 80.0 |
| Devstral Small 2 | 68.0 | — | 22.5 (TB 2) | — |
| gpt-oss-20b | — | — | — | 74.6* |
| Gemma 4 12B | — | — | — | 72.0 |
| Qwen3.5-9B | — | — | — | 65.6 |
*Gemma 4 31B’s SWE-bench and Terminal-Bench numbers, and gpt-oss-20b’s LiveCodeBench number, come from Qwen’s model cards, where those models appear as comparisons. Everything else is from the model’s own card. A dash means the card we used doesn’t report that benchmark. Qwen3.8’s card reports Terminal Bench 2.1, while the Qwen3.6 cards report 2.0, so don’t compare those two columns directly.
What do these coding benchmarks measure?
- SWE-bench Verified / Pro: the model works as an agent in a real GitHub repository and must fix real issues so the project’s tests pass. This is the closest benchmark to “can it do my job.” Pro is a newer, harder set.
- Terminal-Bench: agentic tasks done in a terminal, such as installing things, debugging and running scripts.
- LiveCodeBench v6: competitive-programming problems collected after training cutoffs, to limit memorization. It measures algorithmic coding more than repo work.
- Codeforces Elo (Google reports 2150 for Gemma 4 31B): competition-style problem solving.
Benchmarks depend on the harness, settings and number of attempts. Qwen’s notes say its SWE-bench Pro runs used the Claude Code harness with a 256K context. Treat small differences as noise. Our guide to pass@k and reliability explains why.
Best local coding LLM for 24 GB GPUs and 32 GB+ Macs
This tier covers the RTX 3090/4090 class, RTX 5090, and 32–64 GB Apple Silicon.
1. Qwen3.8 27B (best overall). Qwen3.8-27B was released under Apache 2.0 with a 262,144-token native context. It has the highest scores in this roundup on every benchmark its card reports, including SWE-bench Pro 61.7 (vs 53.5 for Qwen3.6 27B) and LiveCodeBench 90.3. Thinking is on by default, and you can turn it off per request for quicker answers. At 18 GB in Q4_K_M it fits a 24 GB card with room for a moderate context. On a Mac, use qwen3.8:27b-mlx (18 GB). Our Mac guide explains MLX tags.
ollama run qwen3.8:27b
2. Qwen3.6 35B-A3B (fastest). It has 35B total parameters but only 3B active per token, so it generates much faster than a dense 27B and still scores 73.4 on SWE-bench Verified. The catch is the 23 GB size, which leaves little room for context on a 24 GB card. Partial CPU offload of the experts works well for MoE models, as covered in how to run MoE models on a small GPU and mixture-of-experts explained.
3. Gemma 4 31B (best for algorithms). Google reports LiveCodeBench 80.0 and a Codeforces Elo of 2150, but it scores much lower than the Qwen models on the agentic SWE-bench tests (52.0 per Qwen’s comparison). Pick it for algorithm-heavy work, or if you prefer Google’s models. See run Gemma 4 locally.
Also good: Qwen3-Coder 30B-A3B (19 GB, 3.3B active, 256K native context), a code-specialist MoE that Ollama updated for “faster, more reliable tool calling.”
Best local coding LLM for 16 GB GPUs
This tier covers the RTX 4060 Ti 16 GB, 4070 Ti Super, 5060 Ti 16 GB, 5070 Ti and 16 GB Macs (for the smaller picks).
1. Devstral Small 2 (24B). Mistral built it for software-engineering agents. It reports 68.0% on SWE-bench Verified and says it’s “light enough to run on a single RTX 4090 or a Mac with 32GB RAM.” In Ollama it’s 15 GB, which is tight on a 16 GB card, so keep the context modest or offload a little. Apache 2.0, with a 256K context window per Mistral.
2. gpt-oss-20b. OpenAI’s open-weight model has 21B parameters (3.6B active) and was trained with MXFP4 so that it can “run within 16GB of memory.” It’s 14 GB in Ollama. It’s a strong reasoner with good tool use (LiveCodeBench 74.6 per Qwen’s comparison table), and it runs fast because it’s a MoE model.
Best local coding LLM for 8–12 GB GPUs
This tier covers the RTX 3060 12 GB, 4060 and 5060 (8 GB), and similar cards.
1. Gemma 4 12B. It’s 7.7–8.0 GB with a 256K context window per Ollama, and Google reports LiveCodeBench 72.0. That’s a big jump over earlier small models. It’s the best pick for chat-style coding help on 8–12 GB.
2. Qwen3.5-9B. At 6.6–7.6 GB with LiveCodeBench 65.6 (Qwen’s card), it leaves more room for context on an 8 GB card.
On 8 GB, expect solid help with explaining code, writing functions and tests, and small refactors. Don’t expect reliable multi-file autonomous agents. These Ollama settings help squeeze in more context.
Best model for code autocomplete
Autocomplete has to respond in a fraction of a second, so smaller is better. Continue’s docs recommend Qwen2.5-Coder 1.5B (qwen2.5-coder:1.5b, 986 MB), or 7B (4.7 GB) if you have headroom. Thinking models are a poor fit. Setup is in our VS Code local LLM guide.
Our hands-on test: what a 4B model can do on a CPU
To show the floor, we gave Qwen3.5-4B (Q4_K_M GGUF, about 3.0 GB) a small coding task on our CPU-only test server (8 vCPUs, no GPU) through Ollama, with thinking turned off:
Write a Python function
parse_duration(s)that converts strings like “1h30m”, “45s”, “2h”, “10m5s” into seconds, and raises ValueError on empty or invalid input like “abc” or “5x”.
Results:
| Metric | Result |
|---|---|
| Time to full answer | 33.6 seconds |
| Generation speed | 13.6 tokens/s (370 tokens) |
| Our 7 test assertions | All passed (correct totals; ValueError for “”, “abc”, “5x”) |
The code was correct, with a validation regex followed by a parse loop, though it was wordier than necessary. Even a 4B model on a CPU can handle well-specified, single-function tasks. What small models can’t do reliably is the multi-step, multi-file agent work that SWE-bench measures. That’s where the 24B–35B models above earn their memory.
How to test a coding model on your own code
Benchmarks are a shortlist. Your codebase is the real test. A 30-minute process:
- Pick 5–10 real tasks from your work, such as a bug you fixed last week, a function to write with tests, or a refactor. Include one task in your least common language.
- Write or keep the tests, so “correct” is objective.
- Run each candidate with the same settings: same context length (64K for agents), same tool (Cline, Continue or
ollama launch), and the model’s recommended sampling. See sampling settings. - Score the results: pass/fail, number of attempts, time taken, and how much you had to fix by hand.
- Run it twice. Results vary from run to run.
Our guide to evaluating a local LLM on your own tasks has a template.
Tips for better local coding results
- Raise the context length. Ollama defaults to 4K on GPUs under 24 GB, which is far too small for code. Set 32K–64K+.
- Use a 4-bit quant (Q4_K_M) of a bigger model rather than 8-bit of a smaller one. That’s usually the better trade. See quantization explained.
- Turn thinking on for hard problems and off for quick edits. Many of these models let you switch per request. See reasoning effort explained.
- Give agents small, specific tasks and let them run the tests.
- Check the license before using a model commercially. All the main picks here are Apache 2.0 per their cards, but always read the card (open-weight licenses explained).
FAQ
What is the best local LLM for coding in 2026?
For 24 GB GPUs or 32 GB+ Macs, it’s Qwen3.8 27B, which has the highest vendor-reported scores here (SWE-bench Pro 61.7, LiveCodeBench 90.3). For 16 GB, try Devstral Small 2 or gpt-oss-20b. For 8 GB, try Gemma 4 12B or Qwen3.5-9B.
Can a local model replace GitHub Copilot?
For chat, explanations, tests and autocomplete, yes, especially with a 24 GB+ GPU. For long, autonomous multi-file tasks, the best cloud models are still ahead, but 27B–35B local models are increasingly capable.
How much VRAM do I need for a local coding LLM?
8 GB runs 9B–12B models (about 7–8 GB). 16 GB runs 20B–24B models (14–15 GB). 24 GB runs the 27B–35B class (18–23 GB). Add memory for context.
Is a MoE model better for coding?
MoE models like Qwen3.6 35B-A3B and gpt-oss-20b generate faster because only a few billion parameters are active per token. Dense models like Qwen3.8 27B often score higher for their size. If speed matters most, try the MoE first.
Which is the best small coding model for autocomplete?
Qwen2.5-Coder 1.5B, recommended by Continue’s docs. It’s under 1 GB and fast enough for tab-completion.
Watch: Qwen 3.8 27B tested
The takeaway
Choose by memory first: 24 GB+ → Qwen3.8 27B (or Qwen3.6 35B-A3B for speed), 16 GB → Devstral Small 2 or gpt-oss-20b, 8 GB → Gemma 4 12B or Qwen3.5-9B, plus Qwen2.5-Coder 1.5B for autocomplete. Then spend 30 minutes testing the top two on your own code, because the “best” model is the one that passes your tests.
Sources: Hugging Face model cards for Qwen3.8-27B, Qwen3.6-27B, Qwen3.6-35B-A3B, Qwen3.5-9B, Qwen3-Coder-30B-A3B-Instruct, Gemma 4 31B, Devstral Small 2, gpt-oss-20b; Ollama library pages for qwen3.8, qwen3.6, gemma4, devstral-small-2, gpt-oss, qwen3-coder, qwen2.5-coder; Ollama: new coding models; Continue: autocomplete. Benchmark scores are vendor-reported; our hands-on test used Qwen3.5-4B on a CPU-only Linux box. Facts checked November 29, 2026.
Cover image: from the Qwen/Qwen3.6-27B model card on Hugging Face
