You can run a useful coding model on your own machine today, and which one to pick comes down to how much memory you have.
Pick a model that’s too big and it spills into system RAM and crawls. Pick one that’s too small and it makes up APIs that don’t exist. Below is the model and command I’d use for each memory tier, checked against the current Ollama library and llama.cpp builds.
Use one model for autocomplete and another for chat
Tab autocomplete uses fill-in-the-middle (FIM) models that look at the code before and after your cursor and predict what goes in between. They need to be tiny and fast because they fire on nearly every keystroke. A 1.5B to 7B model is plenty, and you should skip “thinking” models here unless you want to wait seconds for a one-line suggestion.
Chat and agentic coding need the opposite. That model reads files, plans a change, calls tools, and edits across your repo in something like OpenCode, so you want the smartest one your memory can hold, with a big context window. Ollama’s docs recommend at least 64K tokens of context for coding tools. That context cache takes memory too, which is why a model that fits at 4K context often spills onto CPU at 64K.
If quantization terms like Q4_K_M and Q8_0 are new to you, read my quantization explainer first. Short version: Q4 is the sweet spot for most people, Q8 is better quality at roughly double the size.
Install Ollama and llama.cpp
You only need one of these, though the commands below cover both. Ollama is the easy button. llama.cpp’s llama-server gives you more control, and it’s what the llama.vscode autocomplete extension talks to.
# Ollama (macOS and Linux)
curl -fsSL https://ollama.com/install.sh | sh
# llama.cpp (macOS, or Linux with Homebrew)
brew install llama.cpp
# llama.cpp (Windows)
winget install llama.cppOn Windows, grab the Ollama installer from ollama.com/download. On Linux without Homebrew, the llama.cpp releases page has prebuilt binaries.
Raise Ollama’s context length (don’t skip this)
Ollama picks a default context based on your VRAM: 4K under 24GB, 32K from 24 to 48GB, and 256K at 48GB and up. For agentic coding on smaller machines, that default is too small. Set it yourself:
# Run the server with a 64K context
OLLAMA_CONTEXT_LENGTH=64000 ollama serveOn Linux, where Ollama runs as a systemd service, set it permanently:
sudo systemctl edit ollama
# add these two lines in the editor, then save:
# [Service]
# Environment="OLLAMA_CONTEXT_LENGTH=64000"
sudo systemctl restart ollamaOn a Mac, the Ollama app has a context slider in Settings. After loading a model, check what you got:
ollama psLook at the CONTEXT column, and make sure PROCESSOR says 100% GPU. If it shows a CPU/GPU split, the model plus context is too big for your machine. Drop to a smaller model or a smaller context.

16GB laptop: autocomplete is great, agents are tight
This is the base MacBook Air, the base M6 Mac mini, or a laptop with an 8 to 12GB GPU. Your OS and browser already eat several gigabytes, so realistically you have 10 to 12GB to work with.
A 16GB machine makes an excellent autocomplete box and a decent “explain this error” chat box. Full agentic loops with 64K of context are a stretch.
Autocomplete pick: Qwen2.5-Coder 1.5B
It’s under 1GB and fast, and Continue’s autocomplete docs still list it first.
ollama pull qwen2.5-coder:1.5bWith llama.cpp, a built-in preset downloads the right file and serves it on port 8012:
llama-server --fim-qwen-1.5b-defaultIf you have a dedicated GPU with 8GB or more, step up to --fim-qwen-3b-default.
Chat and agent pick: gpt-oss 20B
OpenAI’s open-weight gpt-oss:20b is 14GB, it handles tool calls well, and the llama.vscode README names it the best local model for its agent mode right now. Close your browser tabs before you load it.
ollama run gpt-oss:20bllama-server \
--hf-repo ggml-org/gpt-oss-20b-GGUF \
--hf-file gpt-oss-20b-mxfp4.gguf \
-c 32768 -ngl all --port 8080If gpt-oss is too heavy alongside your other apps, use qwen2.5-coder:7b (4.7GB) for chat. It won’t drive an agent well, but it handles “write me a regex” and “why is this test failing” just fine.
On a 16GB machine, I’d keep qwen2.5-coder:1.5b running for autocomplete all day and load gpt-oss:20b only when I need chat. Don’t keep both large models loaded at once.
24 to 32GB desktop or Mac: the sweet spot
This covers a single 24GB GPU (RTX 3090, 4090), a 24GB or 32GB Mac mini or MacBook Pro, and 32GB desktops.
Autocomplete pick: Qwen2.5-Coder 7B
You have room for a smarter autocomplete model now. The 7B tends to do better on multi-line suggestions than the 1.5B.
ollama pull qwen2.5-coder:7bllama-server --fim-qwen-7b-defaultChat and agent pick: Qwen3.8 27B
Alibaba’s qwen3.8:27b is the model to beat on a single 24GB card right now. BenchLM’s December rankings put it at the top for coding among models you can pull for a single 24GB GPU. It’s 18GB at Q4, handles tools well, can read screenshots, and has a 256K context ceiling.
ollama run qwen3.8:27bOn Apple Silicon, Ollama also publishes an MLX build:
ollama run qwen3.8:27b-mlxWith llama.cpp:
llama-server \
-hf unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M \
-c 65536 -ngl all -fa on --port 8080Faster alternatives in the same tier
The 27B is a dense model, so every token runs through all 27 billion parameters. If it feels slow, these mixture-of-experts (MoE) models only activate about 3B parameters per token and are much quicker:
# Qwen3-Coder 30B (MoE, 19GB, 256K context)
ollama run qwen3-coder:30b
# Qwen3.6 35B coding variant (MoE, about 23GB, better on 32GB machines)
ollama run qwen3.6:35b-a3b-coding
# Devstral Small 2 (24B, 15GB, 384K context, built for multi-file agent work)
ollama run devstral-small-2
# Recursive Flint 1.1 (40B MoE, about 2.5B active, 24GB, 256K context)
ollama run flint-1.1
# Inkling 2 Mini (26B MoE, about 5.4B active, 19GB, 1M context)
ollama run inkling-2-miniDevstral Small 2 is the one I would pick on a 24GB GPU if you plan to use a big context window, since its smaller footprint leaves more room for the cache.
Flint is Recursive’s open coder for agent loops, and 1.1 is the new release (it replaces the original Flint, which is still in the library). It’s Apache 2.0, and Recursive says its 4-bit build loses only about a point against the full model and that tool calls almost never fail. Those are the publisher’s numbers, so test it on your own repo. At 24GB it’s a squeeze on a 24GB card once you add context, so it fits better on a 32GB Mac. Ollama can launch it straight into Claude Code or OpenCode with ollama launch claude --model flint-1.1 or ollama launch opencode --model flint-1.1.
Inkling 2 Mini is a newer Apache 2.0 model from Thinking Machines. It’s a 19GB download with a 1M context window, so it’s worth a try on a 32GB Mac if your agent keeps running out of context. It is brand new, so treat it as one to try rather than a proven pick.
The llama.cpp equivalent for Qwen3-Coder 30B:
llama-server \
-hf unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M \
-c 65536 -ngl all -fa on --port 8080If I were setting up a 24GB box, I’d pair qwen3.8:27b for the agent with qwen2.5-coder:1.5b for autocomplete so every spare gigabyte goes to the agent’s context. On a 32GB Mac, you have the headroom to bump autocomplete up to the 7B.
64GB+ workstation: run the big coders
This is a 48GB or 64GB M5 Pro Mac mini, a Mac Studio, a dual-GPU rig, or a workstation with 64GB or more of fast memory. At this size you can run models built for agentic coding at Q4 or better and still have room for a long context.
Autocomplete pick: Qwen2.5-Coder 7B or Qwen3-Coder 30B
The 7B is still the practical choice. If you have memory to burn (the llama.vscode docs suggest more than 64GB of VRAM), llama.cpp has a preset that serves Qwen3-Coder 30B as an autocomplete model. It’s a 32.5GB Q8 download, but since it’s MoE, it stays quick.
# Practical
llama-server --fim-qwen-7b-default
# Memory to burn
llama-server --fim-qwen-30b-defaultChat and agent pick: Qwen3-Coder-Next
qwen3-coder-next is Qwen’s dedicated agentic coding model. It’s 52GB at Q4 with a 256K context, so it fits on a 64GB Mac or a machine with that much VRAM.
ollama run qwen3-coder-nextllama-server \
-hf unsloth/Qwen3-Coder-Next-GGUF:UD-Q4_K_XL \
-c 131072 -ngl all -fa on --port 8080Other options at this tier
# Qwen3.8 27B at Q8: higher quality than Q4, 30GB, leaves lots of room for context
ollama run qwen3.8:27b-q8_0
# gpt-oss 120B: 65GB, so you really want 96GB or more
ollama run gpt-oss:120bAt 64GB, I’d pair qwen3-coder-next for the agent with qwen2.5-coder:7b for autocomplete. If you have 96GB or 128GB, run gpt-oss:120b against it on your own codebase and keep whichever one fails less.
Quick reference table
| Your machine | Autocomplete (FIM) | Chat / agent | Agent size |
|---|---|---|---|
| 16GB laptop | qwen2.5-coder:1.5b | gpt-oss:20b | 14GB |
| 24GB GPU or Mac | qwen2.5-coder:1.5b | qwen3.8:27b or devstral-small-2 | 18GB / 15GB |
| 32GB desktop or Mac | qwen2.5-coder:7b | qwen3.8:27b, qwen3.6:35b-a3b-coding, or flint-1.1 | 18GB / 23GB / 24GB |
| 64GB+ workstation | qwen2.5-coder:7b | qwen3-coder-next | 52GB |
| 96GB+ | --fim-qwen-30b-default | gpt-oss:120b | 65GB |
Wire a local model into OpenCode
OpenCode is an open-source terminal coding agent, and it’s the easiest way to put a local model to real work.
The fast way with Ollama
Ollama ships a launcher that starts OpenCode already pointed at a local model:
ollama launch opencodeYou pick a model, and it runs OpenCode with an inline config, so your existing opencode.json stays untouched.
The permanent way: opencode.json
OpenCode auto-detects Ollama on 127.0.0.1:11434, so all you really need is to set a default model. Put this in ~/.config/opencode/opencode.json (global) or opencode.json in your project root:
{
"$schema": "https://opencode.ai/config.json",
"model": "ollama/qwen3.8:27b"
}If Ollama runs on another box (say, a homelab server), point OpenCode at it. Note the /v1 on the end:
{
"$schema": "https://opencode.ai/config.json",
"model": "ollama/qwen3.8:27b",
"providers": {
"ollama": {
"settings": {
"baseURL": "http://192.168.1.50:11434/v1"
}
}
}
}Using llama-server with OpenCode
llama-server speaks the OpenAI API, so you add it as a custom OpenAI-compatible provider. Start it with one of the commands above on port 8080, then:
{
"$schema": "https://opencode.ai/config.json",
"model": "llamacpp/coder",
"providers": {
"llamacpp": {
"name": "llama.cpp",
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"coder": {
"modelID": "coder",
"capabilities": {
"tools": true,
"input": ["text"],
"output": ["text"]
},
"limit": {
"context": 65536,
"output": 8192
}
}
}
}
}
}Set limit.context to match the -c value you gave llama-server. If they disagree, OpenCode will happily overflow the server’s context and you will get truncated, confused answers.
Wire a local model into VS Code
There are two good extensions, and they pair well: Continue for chat and agent mode, llama.vscode for autocomplete.
Option 1: Continue (Ollama for chat and autocomplete)
Install the Continue extension, then open its config (~/.continue/config.yaml) and give each model a role:
name: Local Coding
version: 0.0.1
schema: v1
models:
- name: Qwen3.8 27B
provider: ollama
model: qwen3.8:27b
roles:
- chat
- edit
- apply
capabilities:
- tool_use
- name: Qwen2.5-Coder 1.5B
provider: ollama
model: qwen2.5-coder:1.5b
roles:
- autocompleteSwap in the models from your tier, keeping the big one on chat and the tiny one on autocomplete.
Option 2: llama.vscode (llama-server autocomplete)
The llama.vscode extension comes from the llama.cpp team. It talks straight to llama-server and is built around fast, small FIM models, which is what you want for completions.
- Install llama-vscode from the VS Code marketplace.
- Start a FIM server for your tier (these presets listen on port 8012, which is what the extension expects):
llama-server --fim-qwen-1.5b-default # 16GB
llama-server --fim-qwen-7b-default # 24GB and up- Start typing. Suggestions appear inline; press Tab to accept.
The extension’s README writes these commands as llama serve. If llama-server isn’t on your path, try that form instead.
Option 3: the Ollama extension for VS Code chat
Ollama also has an official VS Code extension (Ollama.ollama, needs VS Code 1.127 or newer) that adds your local models to the chat model picker. Set Ollama’s context to at least 64K in its settings, or agent mode will lose the thread halfway through a task.
Troubleshooting
If generation feels painfully slow, run ollama ps and look at the PROCESSOR column. Any CPU/GPU split means the model plus context doesn’t fit, so drop a tier or cut the context. If the agent keeps losing track of a task halfway through, your context is too small: raise OLLAMA_CONTEXT_LENGTH or pass -c 65536 (or higher) to llama-server.
When tool calls fail or come back as plain text, double-check that you picked a model with tool support (everything in the agent picks above supports it; current llama.cpp builds enable Jinja chat templates by default). And if autocomplete lags behind your typing, your FIM model is either too big or fighting the agent model for the same GPU, so drop back to the 1.5B.
Local Coding Models FAQ
What is the best local coding model for 16GB of RAM?
Use qwen2.5-coder:1.5b for tab autocomplete and gpt-oss:20b for chat. gpt-oss is 14GB, so close other heavy apps before loading it. Full agentic coding with a 64K context is a stretch at this tier.
What is the best local coding model for a 24GB GPU?
qwen3.8:27b is the top pick for chat and agent work at 18GB. If you want a larger context window, devstral-small-2 is 15GB and leaves more room for the cache.
Can I use the same model for autocomplete and chat?
You can, but you should not. Autocomplete needs a tiny, fast fill-in-the-middle model like Qwen2.5-Coder 1.5B or 7B. Agent work needs the biggest model your memory allows. Running both separately gives you fast completions and a smarter agent.
Should I use Ollama or llama.cpp?
Ollama is easier: one command pulls and runs a model, and it integrates directly with OpenCode and VS Code. llama.cpp gives you finer control over quantization, context, and GPU offload, and its llama.vscode extension is the fastest local autocomplete option.
How much context does a local coding agent need?
Ollama recommends at least 64,000 tokens for coding tools, and OpenCode requires 64K or more. Set OLLAMA_CONTEXT_LENGTH=64000, or pass -c 65536 to llama-server.
Where to start
Find your tier, pull the two models, and use them on real work for a week before you go shopping for something better. If you have a 24GB GPU or a 32GB Mac, this is where to start:
ollama pull qwen2.5-coder:1.5b
ollama run qwen3.8:27bThese model names will be out of date within months, but the setup won’t: a small model for autocomplete, the biggest one that fits for the agent, and at least 64K of context.
This page may contain affiliate links. Please see my affiliate disclaimer for more info.
