Best Local AI Coding Models for Ollama (2026): Run Offline, 100% Private
Want to go deeper than this article?
Free account unlocks the first chapter of all 25 courses — RAG, agents, MCP, voice AI, MLOps, real GitHub repos.
Ollama’s running. Here’s what to build with it. Go from “ollama run” to RAG apps, agents, and fine-tuned models — structured and hands-on. First chapter free.
Best Ollama Model for Coding: The Short Answer
The best Ollama model for coding depends on how much memory you have, so here is the answer by tier. With 64GB or more, run ollama run qwen3-coder-next: its model card reports 70.6 on SWE-bench Verified, the highest vendor-published score of any model in the Ollama library, but the tag is a 52GB download. On a 24GB GPU or a 32GB Mac, run ollama run devstral-small-2 (15GB, 68.0 on the same benchmark per its card). With 16GB, ollama run gpt-oss:20b (14GB) or ollama run deepseek-r1:14b (9GB). With 8GB, ollama run qwen2.5-coder:7b (4.7GB).
Quick answer: top 5 local coding models
- Qwen3-Coder-Next — 80B total, ~3B active; SWE-bench Verified 70.6 (card); 52GB download; Apache 2.0
- Devstral Small 2 (24B) — SWE-bench Verified 68.0 (card); 15GB; runs on one RTX 4090 or a 32GB Mac per Mistral; Apache 2.0
- Qwen3-Coder 30B-A3B — 30.5B total, 3.3B active; 19GB; 256K context; the fast agent model for a 24GB card
- Qwen2.5-Coder 32B — Aider 73.7 at launch (Qwen blog); 20GB; the strongest dense code-completion model that fits 24GB
- gpt-oss 20B — 20.9B total, 3.6B active; SWE-bench Verified 60.7 at high reasoning (OpenAI model-card paper); 14GB; built for 16GB machines
Every tag above exists on ollama.com today, every size is the one the tag page prints, and every score is the one the vendor printed on its own card. If you want a model to drive a coding agent rather than answer in chat, jump to the coding-agent picks; if you would rather have the choice made for you, the coding model router picks from your hardware. The per-VRAM pull commands also live on our best Ollama model for coding page.
How This Ranking Works
This is an editorial ranking, not a leaderboard. We did not run these models against each other, and we do not print numbers we did not find in a primary source. Three things decide the order:
- Published coding scores, taken only from the model's own card or launch post, with the benchmark named. Vendors pick different benchmarks (SWE-bench Verified, Aider, LiveCodeBench, HumanEval), so the column in the table is labelled per row and the numbers are not comparable across rows. Where a card publishes a chart but no figure, the cell is blank.
- What it actually costs to run: the download size on the Ollama tag page plus the KV cache you need for a useful coding context, worked out from the model's config. A model that only fits with a 4K context is not a coding model in practice.
- Agent behaviour: whether the model was trained for tool use and multi-file edits (Devstral, Qwen3-Coder, gpt-oss) or for single-shot completion (Qwen2.5-Coder, StarCoder2, CodeGemma).
Aider's polyglot leaderboard (last updated 20 November 2025) is the one independent board that covers several open-weight models, and it only lists large ones: DeepSeek-V3.2-Exp reasoner 74.2%, DeepSeek R1 (0528) 71.4%, Qwen3 235B-A22B 59.6%, Kimi K2 59.1%, gpt-oss-120b 41.8%, Qwen3 32B 40.0%. None of the models that fit a consumer GPU appear on it, which is why this page leans on cards.
Top Local AI Coding Models: Complete Rankings
| Rank | Model | Params (active) | Ollama command | Download | Context | Published score (source) | Best for |
|---|---|---|---|---|---|---|---|
| #1 | Qwen3-Coder-Next | 80B (3B active MoE) | ollama run qwen3-coder-next | 52GB | 262,144 | SWE-bench Verified 70.6 (model card) | Coding agents on 64GB+ machines |
| #2 | Devstral Small 2 24B | 24B dense | ollama run devstral-small-2 | 15GB | 256K | SWE-bench Verified 68.0 (model card) | Agents on one 24GB GPU / 32GB Mac |
| #3 | Qwen3-Coder 30B-A3B | 30.5B (3.3B active MoE) | ollama run qwen3-coder:30b | 19GB | 262,144 | — (card publishes no table) | Fast agent model, long context, 24GB |
| #4 | Qwen2.5-Coder 32B | 32.5B dense | ollama run qwen2.5-coder:32b | 20GB | 131,072 | Aider 73.7 (Qwen blog, Nov 2024) | Code completion and editing, 24GB |
| #5 | gpt-oss 20B | 20.9B (3.6B active MoE) | ollama run gpt-oss:20b | 14GB | 128K | SWE-bench Verified 60.7, high reasoning (model-card paper) | All-round reasoning + tools on 16GB |
| #6 | DeepSeek-R1 14B (Qwen distill) | 14B dense | ollama run deepseek-r1:14b | 9.0GB | 128K | LiveCodeBench 53.1 (model card) | Think-first debugging on 16GB |
| #7 | Llama 3.3 70B | 70B dense | ollama run llama3.3:70b | 43GB | 128K | HumanEval 88.4 (model card) | Best general model that also codes; needs 48GB+ |
| #8 | Qwen2.5-Coder 7B | 7B dense | ollama run qwen2.5-coder:7b | 4.7GB | 131,072 | — (blog charts only) | Code model for 8GB |
| #9 | Llama 3.1 8B | 8B dense | ollama run llama3.1:8b | 4.9GB | 128K | HumanEval 72.6 (Llama 3.3 card table) | General model for 8GB |
| #10 | DeepSeek-Coder-V2 Lite 16B | 16B (2.4B active MoE) | ollama run deepseek-coder-v2:16b | 8.9GB | 128K | — (card publishes a chart) | Older budget MoE, still quick |
| #11 | Llama 4 Scout | 109B (17B active MoE) | ollama run llama4:scout | 67GB | 10M | LiveCodeBench 32.8, MBPP 67.8 (model card) | Very long context; weak at code for its size |
| #12 | StarCoder2 15B | 15B dense | ollama run starcoder2:15b | 9.1GB | 16,384 | HumanEval 46.3 (model card) | Fill-in-the-middle completion only |
| #13 | CodeGemma 7B | 7B dense | ollama run codegemma:7b | 5.0GB | 8K | HumanEval 56.1, 7B-IT (model card) | Lightweight completion, short context |
Editorial ranking, October 2026. Download sizes and context figures are what each ollama.com tag page prints; scores are the vendor's own, on the benchmark named, and are not comparable across rows.
Model-by-model notes
#1 Qwen3-Coder-Next: the highest published score you can pull from Ollama
Qwen3-Coder-Next is an 80-billion-parameter mixture-of-experts model that routes each token through about 3B parameters (512 experts, 10 active plus one shared, per the card). The card reports 70.6 on SWE-bench Verified, 44.3 on SWE-bench Pro and 36.2 on Terminal-Bench 2.0, a native context of 262,144 tokens and an Apache 2.0 licence. It runs in non-thinking mode only.
The misunderstanding to clear up: active parameters govern speed, total parameters govern memory. The Ollama tag is 52GB, so this is a 64GB Mac, a dual-GPU box, or a GPU plus a lot of system RAM, not a 16GB laptop. What you get for that memory is a model that generates at roughly 3B-model speed while scoring like a frontier agent. Its KV cache is unusually small because only every fourth layer is full attention (12 of 48; the rest are linear-attention layers with a fixed-size state): 2 × 12 layers × 2 KV heads × 256 dims × 2 bytes = 24 KiB per token, so even the full 256K context adds only about 6 GiB. Full breakdown on the Qwen3-Coder-Next page.
#2 Devstral Small 2: the best model for a single 24GB card
Devstral Small 2 (the 2512 release) is Mistral's 24B agent-first coding model. Its card reports 68.0 on SWE-bench Verified, 55.7 on SWE-bench Multilingual and 22.5 on Terminal-Bench 2, a 256K context, Apache 2.0, and says it runs on "a single RTX 4090 or a Mac with 32GB RAM". On Ollama the tag is devstral-small-2 (15GB at q4_K_M, 26GB at q8_0, 48GB at fp16). Note that plain ollama run devstral pulls the older May 2025 Devstral Small (14GB, 128K), not this one.
KV cache: 40 layers × 8 KV heads × 128 dims → 2 × 40 × 8 × 128 × 2 = 160 KiB per token: 5 GiB at 32K, 20 GiB at 128K. A 24GB card holds the 15GB weights plus a 32K cache with a little to spare. The same card lists Claude Sonnet 4.5 at 77.2 and GPT-5.1 Codex Max at 77.9, which is the honest size of the local-versus-cloud gap on this benchmark. More on the Devstral page.
#3 Qwen3-Coder 30B-A3B: fast and long-context on 24GB
The smaller Qwen3-Coder: 30.5B total, 3.3B active, 128 experts with 8 active, 262,144 native context (1M with YaRN per the card), Apache 2.0. Ollama's qwen3-coder:30b tag is 19GB. The card describes agentic coding results but prints no score table, so the cell above is blank rather than guessed. Its KV cache is tiny for its size: 48 layers × 4 KV heads × 128 dims → 96 KiB per token, 3 GiB at 32K, 24 GiB at the full 256K. Pair it with a 24GB card and you can afford a 64K context, which is what makes it the pleasant choice for repo-wide agent work. Guide: Qwen3 Coder.
#4 Qwen2.5-Coder 32B: the dense completion workhorse
32.5B dense parameters, 64 layers, trained on 5.5 trillion tokens of code and code-adjacent text, 131,072-token context, Apache 2.0. The launch blog (12 November 2024) reports Aider 73.7 ("comparable to GPT-4o" in Qwen's words), McEval 65.9 and MdEval 75.2. Ollama tags: 32b 20GB, 14b 9.0GB, 7b 4.7GB, 3b 1.9GB, 1.5b 986MB, 0.5b 398MB. KV cache: 64 layers × 8 KV heads × 128 → 256 KiB per token, 8 GiB at 32K. On a 24GB card run it at 16K or set OLLAMA_KV_CACHE_TYPE=q8_0. For inline autocomplete on a low-RAM laptop, drop to Qwen2.5-Coder 1.5B; the 32B deep dive is on the Qwen2.5-Coder 32B page.
#5 gpt-oss 20B: OpenAI's open-weight model for 16GB machines
OpenAI's August 2025 open-weight release: 20.9B total parameters, 3.6B active, 24 layers, MXFP4-quantised expert weights, Apache 2.0, and the card states it runs "on systems with as little as 16GB memory". The accompanying model-card paper (arXiv 2508.10925, Table 3) reports SWE-bench Verified 60.7 at high reasoning effort (62.4 for the 120B). Ollama: gpt-oss:20b 14GB, gpt-oss:120b 65GB, 128K context. KV cache is small (24 layers × 8 KV heads × 64 dims → 48 KiB per token at most; half the layers use a 128-token sliding window, so real usage is lower). Its reasoning effort is configurable, which matters for autocomplete latency. Page: gpt-oss.
#6 DeepSeek-R1 14B: reason first, then answer
deepseek-r1:14b is DeepSeek-R1-Distill-Qwen-14B: Qwen2.5-14B fine-tuned on R1's reasoning traces, MIT licence. The card reports LiveCodeBench 53.1, Codeforces 1481, AIME 2024 69.7 and MATH-500 93.9; the 32B distill does 57.2 on LiveCodeBench and the 7B does 37.6. It emits its chain of thought before the answer, so for debugging it is worth the wait and for autocomplete it is the wrong tool. Ollama sizes: 7b 4.7GB, 14b 9.0GB, 32b 20GB, 70b 43GB. KV: 48 layers × 8 × 128 → 192 KiB per token, 6 GiB at 32K.
#7 Llama 3.3 70B: the strongest general model that also codes
Meta's card (6 December 2024) reports HumanEval 88.4 and MBPP EvalPlus 87.6 for Llama 3.3 70B Instruct, against 80.5 / 86.0 for Llama 3.1 70B and 89.0 / 88.6 for the 405B. Context 128K, Llama 3.3 Community License. The Ollama tag is 43GB at q4_K_M; the q2_K cut is 26GB and q8_0 is 75GB. KV: 80 layers × 8 KV heads × 128 → 320 KiB per token, 10 GiB at 32K. The 70B section below covers why no single consumer card holds it. Page: Llama 3.3 70B.
#8–#13: more options by memory budget
Qwen2.5-Coder 7B (qwen2.5-coder:7b, 4.7GB) is the code-specialist pick for 8GB. Llama 3.1 8B (llama3.1:8b, 4.9GB, 128K) is the general pick for 8GB; Meta's table gives it HumanEval 72.6, and its KV cache is 128 KiB per token (4 GiB at 32K). DeepSeek-Coder-V2 Lite (deepseek-coder-v2:16b, 8.9GB, 16B total / 2.4B active, 128K) is the 2024 budget MoE; its card shows a chart, not a table, so no score is printed here. Llama 4 Scout (llama4:scout, 67GB, 109B total / 17B active, 10M context) is included for the context length alone: its card's coding numbers (LiveCodeBench 32.8, MBPP 67.8) are below the 14B models above. StarCoder2 15B (starcoder2:15b, 9.1GB, 16,384 context, HumanEval 46.3, OpenRAIL-M) and CodeGemma 7B (codegemma:7b, 5.0GB, 8K context, HumanEval 56.1 for the instruct variant) are completion-era models: fine for fill-in-the-middle, not for agents. The 7B-and-under tier is covered in more detail on best local autocomplete models.
Best Ollama Model for Coding by Memory
Memory needed = weights (the Ollama download) + KV cache (grows with context) + a little runtime overhead. The KV cache per token at f16 is 2 × layers × KV heads × head dimension × 2 bytes, read from each model's config.json. Everything in this table is that arithmetic, not a measurement.
| Your memory | Pick | Weights (Ollama tag) | KV per token | KV at 16K / 32K | Fits? |
|---|---|---|---|---|---|
| 8GB | qwen2.5-coder:7b | 4.7GB | 56 KiB (28 layers × 4 KV × 128) | 0.9 / 1.75 GiB | Yes at 32K |
| 8GB | llama3.1:8b | 4.9GB | 128 KiB (32 × 8 × 128) | 2 / 4 GiB | 16K yes; 32K tight |
| 12GB | deepseek-r1:14b | 9.0GB | 192 KiB (48 × 8 × 128) | 3 / 6 GiB | 8K–16K; use q8_0 cache for more |
| 16GB | gpt-oss:20b | 14GB | ≤48 KiB (24 × 8 × 64) | ≤0.75 / 1.5 GiB | Yes at 32K |
| 16GB | devstral-small-2 | 15GB | 160 KiB (40 × 8 × 128) | 2.5 / 5 GiB | No at 16GB; spills to RAM |
| 24GB | devstral-small-2 | 15GB | 160 KiB | 2.5 / 5 GiB | Yes at 32K |
| 24GB | qwen3-coder:30b | 19GB | 96 KiB (48 × 4 × 128) | 1.5 / 3 GiB | Yes at 32K |
| 24GB | qwen2.5-coder:32b | 20GB | 256 KiB (64 × 8 × 128) | 4 / 8 GiB | 16K yes; 32K only with q8_0 cache |
| 32GB Mac | devstral-small-2 or qwen3-coder:30b | 15–19GB | as above | as above | Yes at 32K–64K |
| 48–64GB | llama3.3:70b | 43GB | 320 KiB (80 × 8 × 128) | 5 / 10 GiB | 64GB yes at 32K; 48GB at 8K |
| 64GB+ | qwen3-coder-next | 52GB | 24 KiB (12 attn layers × 2 KV × 256) | 0.4 / 0.75 GiB | Yes, even at 256K (~6 GiB) |
Weights are the sizes printed on each Ollama tag page (q4_K_M unless stated). KV cache is f16 arithmetic from the model's config.json; OLLAMA_KV_CACHE_TYPE=q8_0 roughly halves it (Ollama FAQ).
Two Ollama settings matter here. First, context: the Ollama FAQ gives the default context window as 4,096 tokens and the current context-length page describes a VRAM-tiered default (4K below 24 GiB of VRAM, 32K between 24 and 48 GiB, 256K above). Either way, set it yourself for coding: OLLAMA_CONTEXT_LENGTH=32768 ollama serve, or /set parameter num_ctx 32768 inside ollama run, or num_ctx in the API options. Second, OLLAMA_KV_CACHE_TYPE accepts f16 (default), q8_0 and q4_0 when flash attention is on, which is how a 32B model gets a 32K context onto a 24GB card. Check ollama ps: if the PROCESSOR column shows a CPU share, the model has spilled and will be slow.
How to Predict Local Speed Before You Buy
Generating a token means moving every active weight from memory into the compute units once, so decoding is memory-bandwidth bound. That gives you a ceiling you can calculate on paper:
tokens/sec ceiling = memory bandwidth (GB/s) ÷ bytes moved per token (GB)
At Q4_K_M, weights ≈ 0.6 GB per billion ACTIVE parameters.Vendor spec-sheet bandwidths: RTX 5090 1,792 GB/s, RTX 4090 1,008 GB/s, RTX 3090 936 GB/s, RTX 4070 504 GB/s, RTX 3060 12GB 360 GB/s, RTX 4060 272 GB/s; Apple lists 546 GB/s for the M4 Max and 150 GB/s for the M3 Pro.
- A 70B dense model at Q4_K_M moves about 42GB per token. On an RTX 5090 that is 1,792 ÷ 42 ≈ 43 tok/s, a hard ceiling before attention, sampling and framework overhead, and only if the whole thing fit in 32GB, which it does not. On an M4 Max, 546 ÷ 42 ≈ 13 tok/s.
- A 32B dense model (~19GB) on an RTX 4090: 1,008 ÷ 19 ≈ 53 tok/s ceiling. A 14B (~8.4GB) on a 12GB RTX 3060: 360 ÷ 8.4 ≈ 43 tok/s; on an M3 Pro, 18 tok/s.
- A 3B-active MoE moves roughly 1.8GB per token regardless of its total size. That is why Qwen3-Coder 30B-A3B and Qwen3-Coder-Next feel like 3B models to type against, provided the whole checkpoint is resident.
Every throughput number on this page is that division, labelled as an upper bound. Real numbers land below it. Use the arithmetic to sanity-check claims: a triple-digit tok/s figure for a 70B dense model on one consumer card is measuring something else (a smaller model, batched throughput, or a draft model). The longer explanation, with the KV-cache side of it, is on our 7B vs 14B vs 32B vs 70B for coding page.
Best Ollama Model for Coding Agents (Cline, Aider, OpenHands)
There is a real difference between a model that answers coding questions in chat and one that can drive a coding agent: reading a repo, planning a change, editing several files and calling tools without losing the plot. Completion-era models often fall apart inside an agent scaffold. The models that were trained for it are Devstral Small 2, the Qwen3-Coder family and gpt-oss, all of which publish SWE-bench Verified figures because that benchmark is an agent task.
| Model | Params (active) | SWE-bench Verified (source) | Context | Ollama command | Why pick it |
|---|---|---|---|---|---|
| Qwen3-Coder-Next | 80B (3B active) | 70.6 (model card) | 262,144 | ollama run qwen3-coder-next | Top published score; needs 64GB+ |
| Devstral Small 2 24B | 24B dense | 68.0 (model card) | 256K | ollama run devstral-small-2 | Agent-first training; one 24GB card |
| gpt-oss 20B | 20.9B (3.6B active) | 60.7 at high reasoning (model-card paper) | 128K | ollama run gpt-oss:20b | Tools + reasoning on 16GB |
| Qwen3-Coder 30B-A3B | 30.5B (3.3B active) | — (not on card) | 262,144 | ollama run qwen3-coder:30b | Fastest long-context agent model on 24GB |
| Qwen2.5-Coder 32B | 32.5B dense | — (Aider 73.7 instead) | 131,072 | ollama run qwen2.5-coder:32b | Strong edits; weaker tool discipline |
SWE-bench Verified figures are each vendor's own, measured with the vendor's own scaffold. Your agent (Cline, Aider, OpenHands, Claude Code via Ollama) and quantisation will move them; treat them as the published claim, not a promise of your result.
Rule of thumb: on a 24GB GPU or 32GB Mac, ollama run devstral-small-2 produces the cleanest multi-file diffs; on 16GB, ollama run gpt-oss:20b; with 64GB+, ollama run qwen3-coder-next. Set the context to at least 32K before pointing an agent at a repo, because the agent's tool output eats context fast. Setup walkthroughs: Cline + Ollama and local coding agents with Ollama; the 14B tier is on best 14B coding models.
Qwen vs DeepSeek vs Llama for Coding
For pure code generation and editing, Qwen's coder models lead; for debugging that benefits from visible reasoning, DeepSeek-R1; for one general-purpose model that is also decent at code, Llama. The three families publish different benchmarks, so the comparison has to be qualitative with each family's own number attached.
- Best Qwen model for coding: Qwen3-Coder-Next if it fits (70.6 SWE-bench Verified), otherwise Qwen3-Coder 30B-A3B for agents and Qwen2.5-Coder 32B (Aider 73.7) for completion. Qwen2.5-Coder is the one with a full ladder (0.5B to 32B) and base variants for fill-in-the-middle, which is why it is still the default in autocomplete plugins.
- Best DeepSeek model for coding: locally, the R1 distills (14B: LiveCodeBench 53.1; 32B: 57.2). The full DeepSeek-R1 (0528) scores 71.4% on Aider's polyglot board, but the Ollama tag is 404GB and the Coder-V2 236B is 133GB; neither is a consumer download. DeepSeek-Coder-V2 Lite (16B, 2.4B active) remains a quick budget option.
- Best Llama model for coding: Llama 3.3 70B (HumanEval 88.4) if you have 48GB+, otherwise Llama 3.1 8B (72.6). Llama 4 Scout's coding figures (LiveCodeBench 32.8) are below the 14B specialists despite its 67GB download, so pick it for its 10M context, not for code.
The best GGUF coding model question has the same answer: Ollama's tags are GGUF files, and the q4_K_M builds listed above are the ones most people run. If you want a specific quant, the tag pages list q2_K through fp16 for Qwen2.5-Coder, Llama 3.3 and DeepSeek-R1; our quantisation guide covers what each costs in quality.
Best 14B Local Models for Coding and General Use
The 14B tier is where a 12GB or 16GB card gets a serious model. Two tags dominate it: qwen2.5-coder:14b (9.0GB, 131,072 context, Apache 2.0) for code, and deepseek-r1:14b (9.0GB, MIT, LiveCodeBench 53.1) when you want reasoning plus general chat. Both are dense Qwen2.5-14B derivatives with the same KV cost (192 KiB per token), so on a 16GB card each leaves roughly 6GB for context, enough for 32K at f16.
For a single model that handles coding and everyday general use, gpt-oss:20b (14GB) is the better fit at 16GB than either 14B: it was trained for tool use and instruction following and publishes an agent-benchmark score, where the Qwen2.5-Coder 14B card does not. If 14B is the ceiling because the card is 12GB, Qwen2.5-Coder 14B at an 8K–16K context is the right call, and OLLAMA_KV_CACHE_TYPE=q8_0 buys the rest. Full tier breakdown: best 14B coding models.
Best 70B Coding Model
Llama 3.3 70B is the best 70B coding model you can pull from Ollama (HumanEval 88.4 on Meta's card, 43GB at q4_K_M), with DeepSeek-R1's 70B Llama distill (deepseek-r1:70b, 43GB, LiveCodeBench 57.5) as the reasoning alternative. The problem is not quality, it is memory: 43GB of weights plus 320 KiB per token of KV cache does not fit a 24GB RTX 4090 or a 32GB RTX 5090. The machines that hold a 70B at a useful context are a 64GB Mac (M-series unified memory), a 2×24GB or 2×32GB GPU box, or 48GB of system RAM accepting CPU-speed generation. The q2_K build (26GB) fits a 32GB card but the quality cost at 2-bit is steep.
The honest comparison is Qwen3-Coder-Next: at 52GB it needs the same class of machine as a 70B, publishes a higher agent score, and decodes at 3B-model speed because only 3B parameters are active. If you are buying hardware for a 70B dense model in 2026, consider whether the same 64GB would serve you better running the MoE. Memory tiers above 32GB are covered on Ollama system requirements.
Setup Guide: Running Local Models with Ollama
Step 1: install Ollama
- macOS / Windows: download the installer from ollama.com; Ollama runs in the menu bar / tray.
- Linux:
curl -fsSL https://ollama.com/install.sh | shinstalls it as a systemd service.
Step 2: pull a model for your memory
# 8GB
ollama pull qwen2.5-coder:7b
# 16GB
ollama pull gpt-oss:20b
ollama pull deepseek-r1:14b
# 24GB GPU or 32GB Mac
ollama pull devstral-small-2
ollama pull qwen3-coder:30b
ollama pull qwen2.5-coder:32b
# 64GB+
ollama pull qwen3-coder-next
ollama pull llama3.3:70bStep 3: set the context window
# server-wide default (Ollama FAQ)
OLLAMA_CONTEXT_LENGTH=32768 ollama serve
# or per session inside ollama run
>>> /set parameter num_ctx 32768
# optional: halve the KV cache (needs flash attention, on by default where supported)
OLLAMA_KV_CACHE_TYPE=q8_0 ollama serveStep 4: connect your editor
Continue.dev, Cline and Zed all take an Ollama provider with the model name; the Continue config block below is the minimum. Our Continue.dev + Ollama guide covers autocomplete versus chat model selection.
{
"models": [
{ "title": "Devstral Small 2", "provider": "ollama", "model": "devstral-small-2" },
{ "title": "Qwen3 Coder 30B", "provider": "ollama", "model": "qwen3-coder:30b" }
],
"tabAutocompleteModel": { "title": "Qwen2.5 Coder 1.5B", "provider": "ollama", "model": "qwen2.5-coder:1.5b" }
}Step 5: check it is on the GPU
ollama ps prints each loaded model with a PROCESSOR column; "100% GPU" is what you want. Any CPU share means the weights or the cache spilled to system RAM, and the fix is a smaller model, a smaller context, or a quantised KV cache. Prefer a GUI? LM Studio runs the same GGUF files; Open WebUI (setup guide) puts a chat front end on Ollama.
Local vs Cloud for Coding: What Is Actually Different
Three things differ: where your code goes, what you pay per token, and the ceiling on the hardest tasks. Local models send nothing anywhere and cost nothing per token after the hardware; cloud models still lead on agent benchmarks. The size of that lead is on the vendors' own cards: Devstral Small 2's card lists Claude Sonnet 4.5 at 77.2 and GPT-5.1 Codex Max at 77.9 on SWE-bench Verified against its 68.0 and Qwen3-Coder-Next's 70.6.
Choose local when
- the code cannot leave the machine, whether by policy, contract or preference;
- you work offline or on an unreliable connection;
- you want autocomplete with no per-token meter running, which is most of what a coding assistant does all day;
- you already own the hardware. A 16GB card runs gpt-oss:20b; a 24GB card runs Devstral Small 2.
Choose cloud when
- the task is long-horizon agentic work where a few points on SWE-bench are the difference between a merged PR and a mess;
- you need images in the loop (screenshots, diagrams), which the text-only local picks above do not take;
- you have 8GB and no appetite to upgrade: a 7B model is fine for chat and completion, but it is not an agent.
Most developers end up hybrid: a local model for completion and private code, a cloud model for the hard problem of the day. Continue.dev and Cline both switch providers per request, so this is a config choice, not a workflow change. For the cloud side of the comparison see best AI coding models.
Frequently Asked Questions
What is the best Ollama model for coding?
If you have 64GB or more of memory, Qwen3-Coder-Next (ollama run qwen3-coder-next, 52GB download) has the highest vendor-published SWE-bench Verified score of any model you can pull from the Ollama library: 70.6 on its model card. On a 24GB GPU or a 32GB Mac, Devstral Small 2 (ollama run devstral-small-2, 15GB) is the pick at 68.0 on the same benchmark. With 16GB, gpt-oss:20b (14GB) or deepseek-r1:14b (9GB). With 8GB, qwen2.5-coder:7b (4.7GB). The ranking on this page is editorial; the scores come from each model's own card.
Which Ollama model is best for coding on 8GB of RAM or VRAM?
qwen2.5-coder:7b (4.7GB download) or llama3.1:8b (4.9GB). Both leave room for a few thousand tokens of context on an 8GB card. Llama 3.1 8B scores 72.6 on HumanEval according to Meta's Llama 3.3 model card table; Qwen2.5-Coder 7B is the one trained specifically on code. If 8GB is system RAM on a laptop with no GPU, expect CPU-speed generation, which is usable for chat but slow for autocomplete.
Is Qwen3-Coder-Next really a 3B model? Why is the download 52GB?
It has 80B parameters in total but only about 3B are active for any one token (a mixture-of-experts design, per the model card). Speed is governed by the active 3B, so it generates quickly, but every expert still has to sit in memory, which is why the Ollama tag is a 52GB download. It is a fast model that needs a big machine, not a small model.
Qwen2.5-Coder vs DeepSeek-R1 vs Llama 3.1 for coding: which is better?
They publish different benchmarks, so there is no single number to compare. Qwen2.5-Coder 32B reports 73.7 on Aider (its launch blog); DeepSeek-R1-Distill-Qwen-14B reports 53.1 on LiveCodeBench (its card); Llama 3.1 8B reports 72.6 on HumanEval (Meta's card). The practical split: Qwen2.5-Coder for code completion and editing, DeepSeek-R1 when you want the model to reason through a bug before answering, Llama 3.1 8B when you want one general model that also codes.
How much VRAM do I need for a local coding model?
Add the download size of the Ollama tag to the KV cache for the context you want. The KV cache per token is 2 × layers × KV heads × head dimension × 2 bytes at f16. For Qwen2.5-Coder 32B that is 256 KiB per token, so a 32K context costs about 8 GiB on top of the 20GB weights: a 24GB card is tight at 32K and comfortable at 16K. Ollama can shrink the cache with OLLAMA_KV_CACHE_TYPE=q8_0 (documented in the Ollama FAQ).
Can I use these models for commercial work?
Licences differ and are stated on each card: Qwen3-Coder-Next, Qwen3-Coder, Qwen2.5-Coder, Devstral Small 2 and gpt-oss are Apache 2.0; the DeepSeek-R1 distills are MIT; Llama 3.1, 3.3 and 4 use Meta's community licence; StarCoder2 uses BigCode OpenRAIL-M; CodeGemma uses Google's Gemma terms. Read the one that applies to you; this page is not legal advice.
Do local coding models replace Claude or GPT?
Not on the hardest agentic tasks. Devstral's own card lists Claude Sonnet 4.5 at 77.2 and GPT-5.1 Codex Max at 77.9 on SWE-bench Verified next to its 68.0, so the gap is real but narrower than it was a year ago. Local models win on cost (nothing per token), privacy (code never leaves the machine) and offline use.
Next Steps
- Best Ollama model for coding by VRAM tier — one pull command per tier
- Coding model router — pick a model from your hardware and task
- Cline + Ollama setup — a local coding agent, step by step
- Continue.dev + Ollama — free Copilot-style completion
- Quantisation explained — what q4_K_M, q8_0 and fp16 cost you
- SWE-bench explained — what the scores on this page measure
Sources
- Ollama library tag pages — tag names, download sizes and context figures
- Qwen3-Coder-Next model card, Devstral Small 2 model card, gpt-oss-20b model card, Llama 3.3 70B model card, DeepSeek-R1-Distill-Qwen-14B model card
- Qwen2.5-Coder family launch post (12 November 2024)
- Aider polyglot leaderboard (last updated 20 November 2025)
- Ollama FAQ — context window default, OLLAMA_CONTEXT_LENGTH, OLLAMA_KV_CACHE_TYPE

Written by
Barsha Mohapatra
Founder and Editor, Local AI Master · Founder, Little AI Master
Founder of Little AI Master and the editor behind every course and guide on Local AI Master. Years of tutoring students taught her where AI education actually fails.
Related Guides
Continue your local AI journey with these comprehensive guides
Qwen3-Coder-Next: Local Coding AI, 70% SWE-Bench
The #1 pick on this page, in depth: architecture, memory and agent setup
Devstral: Mistral's Coding-Agent Model
The best pick for a single 24GB GPU
Best AI Models for Coding: Top 20 Ranked
The wider ranking including cloud models
🎓 Continue Learning
Deepen your knowledge with these related AI topics
Context length, KV cache and GPU settings from the source
Integrate local models into VS Code with Continue.dev
The model cards every score on this page comes from
Ready to Go Beyond Tutorials?
25 structured courses with hands-on chapters - build RAG chatbots, AI agents, and ML pipelines on your own hardware.
Ollama’s running. Here’s what to build with it.
Go from “ollama run” to RAG apps, agents, and fine-tuned models — structured and hands-on. First chapter free.
Stop piecing Ollama together from blog posts
Ollama Mastery is 15 chapters end to end — install, model choice, Modelfiles, GPU offload, the API, and the 20 errors that actually happen. Plus 24 more courses.
Liked this? 25 full AI courses are waiting.
From fundamentals to RAG, agents, MCP servers, voice AI, and production deployment with real GitHub repos. First chapter free, every course.
Build Real AI on Your Machine
RAG, agents, NLP, vision, and MLOps - chapters across 25 courses that take you from reading about AI to building AI.
Want the structured version?
Hands-on courses on local AI, from $8.99 a month. The first chapter of each is free.
Keep going
- PILLARBest Local AI for Coding 2026: 10 Models Ranked by VRAM
- 7B vs 14B vs 32B vs 70B for Coding (2026): What Size?
- AI Context Windows: 4K vs 128K vs 1M Tokens Explained (2026)
- Aider + Ollama Setup (2026): Free Local AI Coding Agent
- Best 14B Coding Models (2026): Ranked by HumanEval + VRAM
- Best Claude Model for Coding: Sonnet 5, Opus 4.8, Fable 5
- Best Ollama Model for Coding: Picks by VRAM Tier
- ChatGPT vs Claude vs Gemini Coding: Which Wins (2026)
- Claude 4 Sonnet for Coding: Is It Worth $20/mo? (77.2% SWE-bench)
- Claude Opus 4.8 Review: 88.6% SWE-Bench (2026)
Comments (0)
No comments yet. Be the first to share your thoughts!