Local LLM for Coding: What Runs on a Laptop, Tested vs Claude
I tested local LLMs for coding on an old CPU laptop and a 4 GB RTX 3050 against Claude: pass rates, tokens per second, real hardware requirements and limits.
A local LLM for coding works on ordinary hardware, but not the way most guides suggest. I ran the same 12 coding tasks through eight local model setups on two machines I own, an old ThinkPad with a 2013 Intel i7 and no usable GPU, and a gaming laptop with a 4 GB RTX 3050, and through Claude. The best local result was 8 of 12 tasks passed. Claude Haiku and Claude Sonnet both passed all 12. The local models were fast enough on the GPU and painfully slow on the old CPU, and the 4 GB card turned out to be the real bottleneck.
This post has the numbers, what they mean for the hardware you need, and how to set up the local route if you still want it.
TL;DR
- Best local pass rate: qwen3.5:4b passed 8 of 12 tasks on both machines. qwen2.5-coder:7b passed 7, and qwen2.5-coder 1.5b and 3b passed 6. Claude Haiku and Sonnet passed 12 of 12.
- Every local model failed the same four tasks: parsing durations, making URL slugs, splitting quoted CSV and comparing semantic versions. They write plausible code and miss the edge cases in the spec.
- A 4 GB laptop GPU holds about 2.3 GB of model. A 3B model that fits ran at 69 tokens per second. Bigger models spilled onto the CPU and dropped to 8 to 10 tokens per second.
- Coding agents need a big context window, and that costs memory. Ollama recommends at least 64k tokens for agents like Claude Code and Codex. At 64k, the 3B model fell from 67 to 23 tokens per second on my GPU.
- An old CPU-only laptop can run 1.5B to 4B models, at roughly 5 to 14 tokens per second on two threads. Good enough for a quick function, too slow for an agent.
- Use local models for privacy, offline work and small completions. For agentic coding on hardware like this, a hosted model is still the practical choice.
How I tested
Each model got the same 12 small programming tasks, written for this test so no model could have memorised them. Each task has unit tests, and a task only counts as passed if the returned code runs and passes every assertion. The tasks:
| Task | What it checks |
|---|---|
| parse_duration | Parse 1h30m15s style strings, reject malformed input |
| merge_intervals | Merge overlapping ranges without changing the input |
| int_to_roman | Roman numerals with range checks |
| LRUCache | A least-recently-used cache class |
| slugify | URL slugs with accented letters folded to ASCII |
| parse_csv_line | CSV fields with quotes and escaped quotes, no csv module |
| top_k_words | Word counts with apostrophes and alphabetical tie breaks |
| valid_ipv4 | Strict dotted-quad validation |
| flatten | Flatten nested lists and tuples, but not strings or dicts |
| diff_dicts | Added, removed and changed keys between two dicts |
| semver_compare | Semantic version order, including prerelease rules |
| binary_search | Fix a buggy binary search |
Settings were the same everywhere: temperature 0, seed 42, thinking switched off, a 4,096-token context (Ollama’s default on these machines), one request at a time, through Ollama 0.40.
The two machines:
| Machine | CPU | Memory | GPU | Limits I set |
|---|---|---|---|---|
| ThinkPad | Intel Core i7-4600U (2013), 2 cores / 4 threads | 8 GB | None used | 2 threads, 5 GB memory cap, lowest priority |
| Gaming laptop | AMD Ryzen 7 4800H, 8 cores | 16 GB | NVIDIA RTX 3050 Laptop, 4 GB | None |
The ThinkPad also runs my other research jobs around the clock, so the test was capped to two of its four threads and paused itself whenever another job or a Lighthouse run started. Its numbers are what you’d get on a busy old laptop, not a benchmark rig.
For Claude I sent the same prompts through Claude Code in headless mode (claude -p, version 2.1.332) with the haiku and sonnet model aliases, all tools disabled, from an empty folder.
Results
“Speed” is generation speed reported by Ollama, the median over the 12 tasks. “Time per task” is the median wall-clock time for one answer, including prompt processing.
| Machine | Model | Size on disk | Passed | Speed (tokens/s) | Time per task |
|---|---|---|---|---|---|
| ThinkPad | qwen3.5:0.8b | 1.2 GB | 0 / 12 | 11.7 | 20 s |
| ThinkPad | qwen2.5-coder:1.5b | 1.0 GB | 6 / 12 | 14.0 | 12 s |
| ThinkPad | qwen3.5:2b | 2.7 GB | 4 / 12 | 7.4 | 31 s |
| ThinkPad | qwen2.5-coder:3b | 1.9 GB | 6 / 12 | 7.4 | 23 s |
| ThinkPad | qwen3.5:4b | 3.3 GB | 8 / 12 | 4.7 | 50 s |
| RTX 3050 | qwen2.5-coder:3b | 1.9 GB | 6 / 12 | 69.1 | 1.9 s |
| RTX 3050 | qwen3.5:4b | 3.3 GB | 8 / 12 | 9.7 | 19 s |
| RTX 3050 | qwen2.5-coder:7b | 4.7 GB | 7 / 12 | 7.7 | 17 s |
| Cloud | Claude Haiku | n/a | 12 / 12 | n/a | 12 s |
| Cloud | Claude Sonnet | n/a | 12 / 12 | n/a | 11 s |
Three things stand out.
The 3B coder model on the GPU answered in under two seconds, faster than Claude’s round trip, and passed half the tasks. That is the best case for local models: instant, private, and right about half the time on tasks like these.
qwen2.5-coder:3b passed exactly the same six tasks on both machines, and qwen3.5:4b passed the same eight on both. Same weights, same seed, same answers. The hardware changed the speed, not the quality: qwen3.5:4b took a median 50 seconds per task on the ThinkPad and 19 on the GPU laptop.
The smallest model, qwen3.5:0.8b, wrote code for every task and every answer was wrong. It produced the wrong Roman numerals, modified the input list it was told not to touch, and raised a KeyError on the dict diff. Below about 1.5B parameters, I wouldn’t trust a model with code at all.
Where local models fail
Across the eight local runs, these tasks failed most often:
| Task | Local runs that failed (of 8) |
|---|---|
| parse_duration | 8 |
| slugify | 8 |
| parse_csv_line | 8 |
| semver_compare | 8 |
| merge_intervals | 6 |
| flatten | 4 |
| diff_dicts | 3 |
The failures weren’t exotic. Most models’ duration parsers threw an error on perfectly valid input, while the 7B model’s version accepted 1h1h, which the spec says to reject. The 3B and 7B models on the GPU got Hello, World! wrong in the slug task, before accents even came into it. The 3B and 4B models broke on a doubled quote inside a quoted CSV field, and the 7B model failed on a plain comma inside quotes. The 3B model ranked version 1.2.3 above 1.10.0, and the 7B model put beta.2 above beta.11.
All of that is code that looks right at a glance. It’s exactly the kind of bug a quick review misses, so with a small local model you need tests, not just a read-through.
The 4 GB GPU problem
The RTX 3050 laptop GPU has 4 GB of video memory, but Ollama never put more than about 2.3 GB of a model on it. The rest of the card goes to the display and the driver. Anything bigger is split between GPU and CPU, and the CPU part sets the pace.
I measured what that does, including what happens when you raise the context window to the 64k that Ollama’s own guides ask for when you run coding agents like Claude Code or Codex on local models:
| Model | Context | Total memory | On the GPU | Speed (tokens/s) |
|---|---|---|---|---|
| qwen2.5-coder:3b | 4k | 2.16 GB | 2.16 GB | 66.9 |
| qwen2.5-coder:3b | 64k | 3.59 GB | 2.32 GB | 23.3 |
| qwen2.5-coder:7b | 4k | 5.15 GB | 2.30 GB | 8.1 |
| qwen2.5-coder:7b | 64k | 6.84 GB | 2.36 GB | 4.2 |
At 64k context the 3B model loses two thirds of its speed, and the 7B model drops to about 4 tokens per second. An agent that reads a few files and writes a change can easily generate thousands of tokens, so at that speed one step takes minutes.
Ollama’s context length docs explain why the default is small: below 24 GiB of video memory it uses a 4k context, between 24 and 48 GiB it uses 32k, and at 48 GiB or more it uses 256k. It also says agents and coding tools should get at least 64,000 tokens. Put those together and the hardware bar for a comfortable local coding agent is a GPU with 24 GB or more, not a laptop card.
Local LLM hardware requirements for coding
Based on these runs and Ollama’s documented defaults:
| What you want | Hardware that works | What to expect |
|---|---|---|
| Quick functions, offline, private | Any laptop with 8 GB RAM | 1.5B to 4B model, 5 to 14 tokens/s on CPU, half to two thirds of tasks right |
| Fast completions and small edits | A GPU with 4 GB or more | A 3B model fully on the GPU, around 70 tokens/s |
| 7B to 9B models at usable speed | A GPU with 8 GB or more | Model fits on the GPU instead of spilling to the CPU |
| A coding agent with 64k context | 24 GB or more of GPU memory | Ollama’s 32k default tier starts at 24 GiB; agents want 64k |
System RAM matters less than video memory once a model spills. My 16 GB laptop had room for the 7B model, but the speed was set by the 2.3 GB that fit on the GPU.
Local LLM vs Claude for coding
| Local (my laptops) | Claude via Claude Code | |
|---|---|---|
| Tasks passed | 0 to 8 of 12 | 12 of 12 |
| Time per answer | 2 s (3B on GPU) to 31 s (CPU) | 11 to 12 s including startup |
| Cost for this test | Electricity | $0.12 (Haiku), $2.26 (Sonnet), as reported by Claude Code |
| Privacy | Code never leaves the machine | Code goes to Anthropic |
| Works offline | Yes | No |
| Agent use at 64k context | Too slow on this hardware | Yes |
The Sonnet cost looks high for 12 short answers because each headless claude -p call carries Claude Code’s own system prompt and tool definitions. You pay for that context on every call, whatever you ask. Inside a normal interactive session, or on a Claude plan rather than API billing, the per-task cost works out very differently. If you’re weighing plans, my Claude Code + Opencode Zen cost breakdown has the numbers.
How to try a local coding model
Install Ollama, then pull the model that fits your hardware. On an 8 GB laptop or a 4 GB GPU, start with the 3B coder:
1
2
ollama pull qwen2.5-coder:3b
ollama run qwen2.5-coder:3b "Write a Python function that validates an IPv4 address."
To use a local model inside a coding agent, Ollama’s docs give a launcher for Claude Code and for Codex. Both docs pages ask for a context window of at least 64k:
1
2
ollama launch claude # Claude Code against Ollama
codex --oss # Codex CLI against Ollama
Expect the speed drop from the table above if your GPU is small. OpenCode, Aider and the other open-source agents in my list of free Claude Code alternatives also work with Ollama. If you want a one-click local runner for bigger models on a desktop with plenty of RAM, Strata from my fall 2026 trending repos list is built for that.
Limitations
- Twelve tasks is a small test. Each one is a single function. It says nothing about multi-file changes, refactors or reading a large codebase, which are harder for small models.
- One run per model. With temperature 0 and a fixed seed, reruns should repeat, but I didn’t measure run-to-run variance.
- Thinking was off. qwen3.5 models can reason before answering. With thinking on they might pass more tasks, and they would also take much longer on this hardware.
- The ThinkPad was capped at two threads so it wouldn’t disturb other work. Uncapped, it would be faster.
- Claude’s times include Claude Code starting up, about the same overhead as opening a session. The raw model answer is faster.
FAQ
Is a local LLM good enough for coding?
For small, well-specified functions, a 3B to 7B coding model got about half of my tasks right. It’s useful for autocomplete, boilerplate and offline work, but you have to check its output closely, because it misses edge cases in the spec. Claude passed every task in the same test.
What are the requirements for running a local LLM for coding?
An 8 GB laptop runs 1.5B to 4B models on the CPU at about 5 to 14 tokens per second. A GPU with 4 GB runs a 3B model at about 70 tokens per second. For a coding agent with the 64k context Ollama recommends, plan on 24 GB or more of GPU memory.
Local LLM for coding vs Claude: which is better?
In my test Claude Haiku and Sonnet passed 12 of 12 tasks and the best local model passed 8. Local wins on privacy, offline use and cost per request. Claude wins on correctness and on agent work that needs a large context.
Can I use Claude Code with a local LLM?
Yes. Ollama documents ollama launch claude to run Claude Code against a local model, and recommends a context window of 64k or more. On a laptop with a 4 GB GPU, expect it to be slow at that context size.
What is the best local LLM for coding on 8 GB of RAM?
On my 8 GB ThinkPad, qwen3.5:4b passed the most tasks (8 of 12) but needed about 50 seconds per answer. qwen2.5-coder:1.5b was the better trade-off for quick help: 6 of 12 at 14 tokens per second and about 12 seconds per answer.
What is the best local LLM for a 4 GB GPU?
qwen2.5-coder:3b. It fits entirely in the roughly 2.3 GB my 4 GB card made available and ran at 69 tokens per second. qwen3.5:4b passed more tasks (8 of 12) but spilled onto the CPU and ran at under 10 tokens per second.
Method and data
Tests ran on 30 November 2026 with Ollama 0.40.19 on the ThinkPad (Debian 13) and Ollama 0.40.18 on Windows 10, using the default builds from the Ollama library (Q4_K_M for every model I checked with ollama show). Speeds are Ollama’s own eval_count / eval_duration. Code was checked by running the unit tests in an isolated Python subprocess with a 10-second timeout. The Claude runs used the same prompts, the same test harness and the same pass rule.
