Best Local LLM for Coding in 2026: What Actually Fits on Your Machine

Best Local LLM for Coding in 2026: What Actually Fits on Your Machine

IBM’s Granite 4.2 8B is a 5.35GB download. On a 16GB MacBook it needs 10.72GB to run, and it does not fit.

That gap is the KV cache, and almost no guide to local coding models publishes it. They quote the file size, which is the one number that cannot tell you whether a model will run.

This is what actually fits at 8GB, 16GB, 24GB and 64GB, with every weight read from the model’s own repository rather than estimated. It is the compatibility companion to our Apertus 1.5 measurement, built on the same method. Figures checked 10 September 2026, refreshed monthly.

The Short Version

QuestionAnswer
Best coding LLM for 8GB?Qwen2.5-Coder-1.5B for autocomplete; Granite 4.2 3B for chat
For 12GB?Qwen2.5-Coder-7B, still the best-evidenced small coder with real fill-in-the-middle
For 16GB?Gemma 4 12B, or Granite 4.2 8B dropped to Q4_K_S
For 24GB?Devstral Small 2 24B, the first tier that does real work
For 32GB+?GLM-4.7-Flash, or gpt-oss-20b with room to breathe
For 48GB+?Qwen3-Coder-Next (80B, SWE-bench Verified 70.6%)
Why don’t the usual picks fit?They are 24B to 80B models. The “coder” label does not shrink them
Can a small model replace a coding agent?No. See the quality cliff

How Much Memory Does a Coding LLM Actually Need?

Three numbers, and most guides publish only the first.

Weights come to roughly 0.6GB per billion parameters at Q4_K_M. The KV cache stores a key-value pair for every token the model has read, in every layer: 2 × layers × kv_heads × head_dim × context × bytes. At 32,000 tokens, which is a few files open, that adds about 1.8GB to 5.4GB depending on the attention design. For Granite 4.2 8B the raw product is ~5.2GB at FP16; the 5.37GB used below includes allocator padding. Then add about 15% headroom on top of weights plus cache.

What Your Hardware Actually Gives You

Subtract all of that from what the machine actually gives you, which is always less than the number on the box. On Apple silicon the figures below use about two-thirds of listed unified memory, not 75%. The 75% “wired limit” number is a community rule of thumb; in practice Activity Monitor and Metal leave less. That is why a 16GB Mac is treated as 10.6GB here, not 12GB.

HardwareTotalUsable for the model
MacBook Air/Pro 8GB8GB~5.3GB (macOS reserves ~33%)
MacBook 16GB16GB~10.6GB
MacBook 24GB24GB~16GB
MacBook 32GB32GB~21GB
MacBook 64GB+64GB~43GB
RTX 3060 / 4060 / 40708–12GB VRAM7.5–11.5GB
RTX 4080 / 4060 Ti 16GB16GB VRAM~15.5GB
RTX 3090 / 409024GB VRAM~23GB
RTX 509032GB VRAM~31GB

The two-thirds figure is a community rule of thumb, not an Apple specification. It can be raised with sudo sysctl iogpu.wired_limit_mb=, which resets on reboot and risks swapping. Raising it is how a 16GB Mac can be forced toward the 12GB the 75% rule implies. On Nvidia there is no equivalent override. VRAM is a hard ceiling.

Why File Size Misleads

Granite has the smallest file of the three and still misses a 16GB Mac by 0.12GB. Weights from Hugging Face repository listings, KV calculated at 32k context, 10 September 2026.

Granite pays that price because it is a dense 40-layer model with no sliding-window attention, so its cache costs 5.37GB, as much as the model itself. Gemma 3 12B is 2GB heavier on disk and fits at 9.78GB, because sliding-window attention holds its cache to 2.48GB. Drop Granite to Q4_K_S at 5.09GB and it lands at 10.46GB, inside the limit. File size predicts none of this.

Two more traps sit in the table below. gpt-oss-20b cannot be quantised down to fit 16GB. OpenAI’s model card says it runs within 16GB of memory, which is true of system RAM and of a 16GB NVIDIA card at moderate context, but not of the default Metal cap (~10.6GB usable). Its mixture-of-experts weights already ship in native MXFP4. Every GGUF from Q2_K to Q8_0 lands between 11.5GB and 12.1GB. There is no smaller fallback. Qwen3-Coder-Next activates 3B parameters and still needs 48.4GB for the weights alone, because active-parameter counts tell you speed, not memory. All 80B stay resident. That is a 64GB-class workstation or an 80GB-class GPU, not a 48GB Mac.

What Fits at Each Memory Tier

Weights read from repository file listings on 8–10 September 2026. KV calculated at 32,000 tokens.

ModelWeightsKV @32kTotal neededMinimum tierLicenceOfficial GGUF · updated
Qwen2.5-Coder-1.5B1.12GBlow~2GB8GBApache 2.0Yes · Jan 2025
Granite 4.2 3B2.32GBlow~5GB8GBApache 2.0Yes, IBM · Sept 2026
Qwen2.5-Coder-7B4.68GBmoderate~8GB12GBApache 2.0Yes · Jan 2025
Gemma 4 E4B4.98GBlow~7GB12GBGoogle’s termsYes, Google QAT · 30 Jul 2026
Granite 4.2 8B5.35GB Q4_K_M /
5.09GB Q4_K_S
5.37GB10.72GB /
10.46GB
16GB at Q4_K_SApache 2.0Yes, IBM · Sept 2026
Gemma 3 12B7.30GB2.48GB9.78GB16GBGoogle’s termsYes
Gemma 4 12B6.98GBlow~9.5GB16GBGoogle’s termsYes, Google QAT · 17 Jul 2026
gpt-oss-20b11.5–12.1GB~13GB24GBApache 2.0Native MXFP4 · Aug 2025
DeepSeek-R1-Distill-Qwen-14B9.0GBhigh~15GB24GBMIT
Devstral Small 2 24B~14GB~20GB24–32GBApache 2.0No, community only · 15 Jul 2026
GLM-4.7-Flash~18GB1.77GB~20GB32GBMITNot found · 29 Jan 2026
Qwen3-Coder-Next48.4GB~55GB64GBApache 2.0Yes, Qwen · 3 Feb 2026

Two licence traps are worth naming. Qwen2.5-Coder is Apache 2.0 at 1.5B and 7B but non-commercial at 3B, because model families do not always share a licence. And Hugging Face tags are not the licence. Gemma 3 and earlier Gemma releases used Google’s custom Gemma Terms of Use. Gemma 4 is Apache 2.0; Google said so on the Open Source Blog in April 2026, and the Gemma terms page now points Gemma 4 traffic to that Apache text. The same discipline applies across every open-weight family, as our Chinese LLM map found: the licence travels with the release, not with the company.

Which Model to Run at Each Tier

8GB. Qwen2.5-Coder-1.5B for autocomplete, with native fill-in-the-middle at 1.12GB. Granite 4.2 3B if you want chat as well. IBM reports LiveCodeBench v6 69.71 for it, self-reported and unverified.

12GB. Qwen2.5-Coder-7B is a January 2025 release, old for this field, but nothing newer at this size has displaced it on published evidence. Gemma 4 E4B scores higher on LiveCodeBench at 52.0%, though its fill-in-the-middle support appears broken, with an unresolved issue open on Hugging Face. Treat it as a chat model.

16GB. Gemma 4 12B. Its 1,024-token sliding window keeps the KV cache far below a dense model of the same size, and quantisation-aware-trained builds hold up better at 4-bit than post-hoc ones. It is not a specialist coder, which is the trade-off at this tier.

24GB. Devstral Small 2 24B, around 68% on SWE-bench. This is the first tier where a local model does real multi-file work. Note that Mistral publishes no official GGUF for it, so you are on a community build.

32GB and up. GLM-4.7-Flash adds MIT licensing and an unusually small KV cost, 1.77GB at 32k, from multi-head latent attention. Community GGUFs run it in 24GB at 4-bit; 32GB is the comfortable tier once context and headroom are included. gpt-oss-20b also belongs here on a Mac. Qwen3-Coder-Next is the next step up, not a 32GB or 48GB-Mac model: 262,144-token context, Apache 2.0, 48.4GB of resident weights, and Qwen’s reported 70.6% on SWE-bench Verified, 44.3% on SWE-bench Pro and 36.2% on TerminalBench 2.0. Plan for a 64GB-class workstation with the wired limit raised, or an 80GB-class GPU. Active parameters are 3B. Memory is still 80B.

Where the Quality Cliff Is

No model that fits in roughly 6GB has ever been run on SWE-bench Verified or Aider polyglot. Not one. The nearest published data point is Qwen2.5-Coder 32B, four times larger than anything in the 8 to 12GB tiers, scoring 16.4% on Aider polyglot.

Since that measurement, IBM has published 47.67% SWE-bench Verified for Granite 4.2 8B. That is vendor-reported, unverified here, and still well below Devstral Small 2’s 68%. It does not move the 8–12GB models into the agent tier. It does mean the cliff is no longer “nothing below 24B has a SWE-bench number.

In short, the 1.5B to 12B range is useful for autocomplete, single functions, small refactors and reading a stack trace. It is not useful for multi-file agentic work, and prompting does not fix that. If the job is fixing a failing test across three files, you need the 24B tier, which means 24GB of memory or an API.

How We Checked

Every weight figure was read from the model’s own repository file listing on Hugging Face on 8–10 September 2026, not derived from the 0.6GB-per-billion shorthand. KV figures are calculated at 32,000 tokens from each model’s published layer, key-value head and head-dimension counts. Usable memory assumes about two-thirds of unified memory on macOS and near-full VRAM on NVIDIA.

We did not run these models. This is a compatibility guide, not a benchmark. Every score here belongs to the organisation that published it, and vendor figures with no independent verification are marked as such. We do not quote HumanEval, which is saturated and no longer separates current models. Where we do measure, the method is the one in our Apertus test.

Author: Akos Szima

This article is for information only and is not deployment advice. Model availability, sizes, licences and scores change frequently. Every figure was checked against its primary source on 8–10 September 2026 and this page is refreshed monthly. Performance scores are vendor-published unless stated otherwise. Corrections welcome and published inline.

See Also:

What Is the Best Open-Source LLM in 2026?

European LLMs in 2026: The Complete Map

Chinese LLMs in 2026: The Complete Map

Frequently Asked Questions
What is the best local LLM for coding?

It depends on memory. 8GB: Qwen2.5-Coder-1.5B. 16GB: Gemma 4 12B. 24GB: Devstral Small 2 24B, the first tier that handles real multi-file work. 64GB-class workstation or 80GB-class GPU: Qwen3-Coder-Next.

Can I run Qwen3-Coder locally?

Qwen3-Coder-Next needs 48.4GB for weights alone, because all 80B parameters stay resident even though it activates just 3B at a time. Under the usable-memory rule in this piece, a 64GB Mac offers about 43GB. You need a 64GB+ workstation with the wired limit raised, a larger unified-memory Mac, or an 80GB-class GPU / multi-GPU offload.

How much RAM do I need to run an LLM for coding?

8GB for autocomplete, 16GB for useful chat assistance, 24GB minimum for multi-file agentic work. A 16GB Mac gives a model about 10.6GB, and the KV cache at 32,000 tokens adds another 1.8GB to 5.4GB on top of the file size.

Which local coding models can a business use commercially?

Qwen2.5-Coder-1.5B and 7B, Granite 4.2, Devstral Small 2, Qwen3-Coder-Next and Gemma 4 are Apache 2.0. GLM-4.7-Flash and the DeepSeek distills are MIT. Qwen2.5-Coder-3B is not commercially licensed despite the rest of its family being Apache 2.0. Older Gemma releases (Gemma 3 and earlier) still use Google’s custom Gemma Terms of Use. Open the linked licence file for the exact repo you download.

Is MLX better than GGUF on a Mac?

MLX is usually faster on Apple silicon, and it is what makes Granite 4.2 8B fit at a 32k context where its Q4_K_M GGUF does not. Fewer models have MLX builds, so availability tends to decide it.

Share this article

Latest news

Subscribe to our newsletter

More News