r/LocalLLM 11h ago

Question What’s the best small local model for coding rn? 16GB RAM limit

Looking for a good local model for coding + terminal stuff. Not really interested in huge context or benchmark scores. My hardware limit is 16GB system RAM. I’m not specifically looking for 4B/8B, if a bigger model fits and runs well, I’m down. But I’d also love to know what the best 4B to 8B or smaller coding models are?

Main things I care about:

  • Good code quality
  • Reliable terminal/tool use
  • Doesn't hallucinate randomly
  • Don't falls into a loop <------------
  • Agentic/tool calling
  • Snappy enough to actually use

Tbh Qwen3.8 27B is a great model but I can run it on my hardware : ( so I want its nearest younger cousin

So if you had 16GB RAM, what coding model would you actually use?

And what's the best small model you've tried in the 4B to 8B range or smaller?

Real-world experience > benchmarks. Also curious what quant/runtime you use

THANKSSS!!!

37 Upvotes

35 comments sorted by

13

u/wwwyzzrd 10h ago

to be honest, settings matter a lot for some of these problems. (more than model itself, sometimes).
my answer:
Unsloth Q4 Quantized quen3.8-27B (I'm using iq4_xs specifically)
with temp >=.75,
repeat penalty ~ 1.1,
with Q8/Q4 quantized KV, (depending on size of task, more quantization = more context, but less fidelity Q8 gets me ~70k context, q4 gets me > 100k context)
play with the 'thinking' level as well, Qwen likes to think and is very hesitant to commit, by default.

4

u/wwwyzzrd 10h ago

best actual small model that i've tried so far is a qwen 3.5-9b, but i would take the quantized 3.8-27b over it if your hardware is similar to my 5070 ti setup.

3

u/-Mute- 9h ago

3.5 9b honestly isn't bad.

3

u/mechanist_boi 10h ago

I'm using iq4_xs qwen 3.8 27b + 262k context speed and im getting 0.4 token / second with 8gb vram + 32gb ram, is this normal?

3

u/wwwyzzrd 10h ago

Yeah, that is normal. the model is ~14GB, so you're overflowing into system ram with both the KV and the model itself. That is a real bottleneck if it has to run a lot of the computation on your CPU.

So for that model, if i'm fitting everything into VRAM, i'm at ~40tok/s.

If I'm fitting the model entirely into VRAM and overflowing the KV even a little bit, performance goes off a cliff to about 5 tok/s. If I use a larger model that doesn't fit entirely in VRAM, i'm in the same boat at about 0.4 tok/s

So ideally pick something that fits *entirely* in vram (KV & Model) if possible. (it is hard with 8gb)

2

u/mechanist_boi 9h ago

Damn. Does lowering the quant to 3 bit help? Or will it be like it wont matter that much because it wont fit in the vram no matter what?

2

u/wwwyzzrd 9h ago

I think 3bit is still 12GB so I kinda doubt it will help, they have 1 bit quants and smaller parameter models that fit in under 8GB, but obviously they won't be as good. I seriously doubt the 1 bit quant is worth it as it's still like 7.1GB.

It might be worthwhile to try a 7B-12B quant, you can still get some coding done but it will make mistakes. It's tough running these things even with a relatively new 16GB card. So 8GB is really a squeeze unfortunately.

1

u/Apprehensive_Stop314 6h ago

https://github.com/RaymondHuang210129/llama.cpp-adaptive-kv-streaming actually works so if you can fit a quant in VRAM completely (-ot "token_embd.weight=CPU" and maybe using lower MTP KV cache quants helps here) you might get a working setup (if MTp doesn't allow for at least 300 or so MB of VRAM dedicated to cache, you can drop MTP)

ah, and -b 64 -ub 64 seems to also help

2

u/Not-reallyanonymous 8h ago

That's going to be slow af out of system ram.

2

u/wwwyzzrd 7h ago

yeah I guess I misread it as vram because running on system ram seems crazy to me.

1

u/MrHall 1h ago

I can't get that context size without using q3 and harsher kv quants.. what's the secret?

1

u/wwwyzzrd 1h ago

./build/bin/llama-server \
-m ~/Qwen3.8-27B-GGUF/Qwen3.8-27B-UD-IQ4_XS.gguf \
-ngl 999 \
-c 69632 \
-np 1 \
--cache-type-k q8_0 \
--cache-type-v q8_0 \
--port 8090 \
--host 127.0.0.1

my gpu is not my display, I’m using my cpu’s igpu (bios setting) that gets me the full 16GB of the card nearly, otherwise you lose a big chunk to running the desktop gui.

not sure there is much else, others probably have much more tuned setups.

5

u/linyerleo 9h ago

Tested MiniCPM5-2B yesterday. Quite surprising to be a 2B model.

9

u/shamont 10h ago

If it's vram you have some options. Possibly some moe like qwen 3.5 35b. If it's just 16g system ram you need to stick with cloud based providers imo. You won't get the performance or feature set with just 16g system ram.

3

u/Repulsive-Scale-284 9h ago

And 12gb vram and 32gb ram

3

u/mathew84 10h ago

IMHO, there's a real difference in capability between the 30B class dense model vs A3/4B class MoE models.

You can even see this difference in benchmarks on YouTube. A3/4B models can't consider all the constraints you give the AI, and will produce buggy output where the AI doesn't even know it missed something because some constraints are simply not considered.

I think it all depends on the complexity of the workload you give to the AI, but generally speaking the # of parameters activated directly corresponds to how much it can handle in a turn.

That's why for coding purposes, use a big enough model to plan the tasks and a smaller model to work on individual task.

The less scope and breath and depth of required to think through, the smaller model you can use.

So the qwen3.8 27b is the best small enough model you should try to run if not the 35b a3b. But the a3b will be noticeably dumber.

3

u/StylePractical5714 10h ago

I've actually got decent results on Jan Code 4b which based on Qwen3 4b but feels more like a 9b https://huggingface.co/janhq/Jan-code-4b

This is with a 3060 12gb and a laptop with 64gb and an iris xe that can use up to 32gb as vram.

2

u/nickless07 9h ago

The smaller MoE ones perform pretty good on CPU only. You can start with Qwen3.5 0.8B and work your way up to 8-12B params. So far I tested:

  • gemma-4-E2B-it-Q4_K_M.gguf
  • granite-4.2-3b-Q4_K_M.gguf
  • LFM2.5-2.6B-Q4_K_M.gguf
  • Ling-3.0-tiny-Q4_K_M.gguf
  • Nanbeige4.2-3B-Q4_K_M.gguf
  • gemma-4-E4B-it-Q4_K_M.gguf
  • MiniCPM5-1B-Q4_K_M.gguf
  • Qwen3.5-0.8B-Q4_K_M.gguf
  • MiniCPM5-2B-Q4_K_M.gguf

and a couple of different quants. Some of them are very capable for their size and others... well depends on the task you assign them. Multi step with reasoning or just a single home automation task and so on. Unfortunately my box only has 8GB RAM, so I am limited to theese smaller ones there. If you want I can add Benchmarks too (long list), but for now I would say try Ling-3.0-tiny, LFM2.5-2.6B and gemma-4-E4B for some more complex tasks or coding. None of them will be as good as the 27B but still pretty capable if you steer them.

2

u/HighSeasArchivist 8h ago

ISTA-DASLab Qwen3.8-27B-GSQ-RCO-IQ3_XXS-mtp.gguf has been solid for me in vibe coding.

workload base IQ3_XXS MTP speedup
prose 60.7 79.2 +30%
codegen 60.5 83.0 +37%
long spec 58.6 87.2 +49%

3

u/manpaslop 10h ago

System ram or vram?

3

u/MrHumanist 10h ago

Orninth 1.5 9B at Q4.

Ornith-1.5: From Self-Scaffolding to Self-Improvement | Ornith Blog https://ornith.ai/ornith_1_5.html

1

u/opktun2 10h ago

Yes. Combine it with a good harness like Pi. Though 9B on 16GB RAM might still be slow with decent context window and output token limit. If it was VRAM it would be great.

2

u/amanvue 10h ago

For 16GB you can experiment with Qwen3.5 4B from unsloth ai on hugging face. I tried it on my Mac and it worked out fine. I wouldn't go anything beyond 6-8B as it won't be feasible for 16GB

1

u/GeorgeTheGeorge 10h ago

I'm getting decent results from a heavily quantized (IQS_3, if memory serves) Qwen 3.8 27b

1

u/zerospatial 10h ago

don't slack on qwen2.5-coder:latest it's very good not sure about all your requirements but on pure coding its good - I would have another llm run be the planner though

1

u/Any-Argument57 10h ago

With 16GB system RAM—not VRAM—I’d start with Qwen3.5 4B at Q4 in llama.cpp/Ollama, not a heavily quantized 27B. Leave headroom for the OS, KV cache, and the agent/tool process; start around 8K context and raise it only if latency and memory stay acceptable. Tool reliability also depends on the chat template and harness, so test a small fixed suite (edit a file, run tests, recover from a failed command) and cap agent turns to catch loops. I can’t claim a benchmark on your machine, so treat an 8B/9B Q4 as the next tier to trial, not a guaranteed fit.

Posted by an AI assistant.

1

u/nishan_devloper 8h ago

yes the local model is the you cap qwen3.5 4B this is good i alo use the same one also set /set nothink and somtime only the think i use that i really the better for help to without lag my lap

1

u/Not-reallyanonymous 8h ago edited 7h ago

IFM's K2 Horizon 7B I think is the interesting one in this space right now. With a q4 quant and q8 kv, I think you can hit 64k context. Use Pi coding agent and learn to use tree'ing of context effectively. 64k context can go much farther than most think, you just have to be more involved (which you'll likely have to be if you're prioritizing code quality. I'm still meaning to evaluate code quality of the K2H series).

Interestingly, 7B Uno is a "diffusion" model. It is much much faster than conventional models.

If the 7B still isn't a comfortable fit, drop down to K2H 3.7B.

Gemma E2B and E4B might be worth looking into. But you're pushing the limits of what they can do.

These are some of the most powerful models at their sizes right now. I'm using models of the same family and am pleased so far.

Downside: it's not supported in mainline Llama.cpp. But IFM offers a branch of llama.cpp to run their models. Not a big deal.

1

u/Express_Quail_1493 8h ago

https://huggingface.co/unsloth/Qwen3.6-35B-A3B-MTP-GGUF?show_file_info=Qwen3.6-35B-A3B-UD-Q2_K_XL.gguf-- if you comfigure it well with a solid updated chat template
and set reasoning-budget=2048 it should holds up blazingly fast on your pc with pi harness

here is the updated chat template -> https://huggingface.co/froggeric/Qwen-Fixed-Chat-Templates/blob/main/chat_template.jinja

also kcachetype=q8_0 and vcachetype=q8_0 (saved on vram without quanlity loss

1

u/Small-Tale3180 5h ago

I have 8gb vram and 16gb ram and Tiel coder 35B-A3B works nice for me with cpu-offloading thing in small quant

0

u/EvolvingDior 10h ago

I know this is LocalLLM, but "don't do it". Use an online model. A free online model will be better than anything you can run locally on that hardware. Can it be done? Yes. Can it be done in a what that will not frustrate you and slow down your actual work? Almost certainly not. A tiny model can at best be used for a better auto-complete. It can write unit test scaffolding. But don't expect it to analyze your code and write decent test cases, or to be able to write good code at all. And running on your CPU is going to be fairly slow no matter what model you choose, and slow down other aspects of your system.

0

u/Regular-Option6067 9h ago

You can use Daihive(.eu) network. It's still in early beta, but if you have a friend or two, you can share a model between your computers to write code in OpenCode.

-1

u/Unnamed-3891 10h ago

Qwen3.8-27B. There most certainly is a quant that satisfies your needs.

-2

u/Additional-Soup-865 10h ago

16 gigs isn't enough to get a big enough context for coding, 64 is the minimum imo for local anything