Show HN: Open-source engine running Gemma 4 26B in 2 GB RAM on any M-series Mac (opens in a new tab)github.com
919 pointsI built a specialized inference engine for running 4-bit Gemma 4 26B-A4B-IT on any M-series Mac using about 2 GB of RAM. It is called TurboFieldfare and is written in Swift and Metal.
I have always adored on-device AI. It feels like magic that you can run a powerful NN on your Mac or iPhone. So I wanted to push the limits a bit and run a model whose weights don’t fit in memory.
The model’s 4-bit quantized weights occupy roughly 14 GB, which makes running it with conventional inference tools almost impossible on an 8 GB or even 16 GB Mac once the OS, applications, and KV cache are included.
The trick is to keep the shared part of the model and the KV cache in RAM, then stream only the routed experts needed for each token from SSD. An SSD is way slower than RAM, so the runtime uses a small expert cache and bounded parallel `pread`. While those reads are in flight, the GPU runs the shared part of the layer.
I ran more than 100 experiments. Most didn’t work. A few got me here. The experiments are described in the GitHub repo.
It currently generates 5–6 tok/s on an 8 GB M2 MacBook Air and 31–35 tok/s on an M5 MacBook Pro.
I also added an experimental OpenAI-compatible local server. It supports streaming and tool calls, and reuses one prompt prefix from the KV cache.
Try it! The Mac app is easy to install. On the first run, it will download 15 GB of weights from Hugging Face. The model is surprisingly capable.
I would love any kind of feedback!
Comments (342) 81 threads
Show all comments
Showing thread 25 of 81
I am using Gemma for a few tasks simply because it’s “good enough”.
Continue this thread — 1 reply
Otherwise IMO it codes about as well as the Qwen MoE for PHP and SQL. It's a fully impressive model (though it is not as mindbendingly impressive as the 12B, which is outrageously good for its footprint)
- The consensus is that if you have a properly kitted out PC with enough VRAM, the Qwen 3.6 27B dense model is the one to beat.
Bit slow on my M1 Max so I haven't bothered with it much but I have no reason to doubt the consensus. Prism ML's new Ternary Bonsai variant of it makes it much easier to play with this model in limited RAM, but in my own toy experiments I have seen Ternary Bonsai get very stuck in thinking loops. There is another post-train variant from BottleCap called ThinkingCap, which you could try.
- The Qwen 35B MoE model is really impressive for code generation. I personally would pick this one for an older Mac or a machine with smaller VRAM; it's pretty fast, has good built-in MTP, great tool-calling.
- The Gemma 4 26B MoE has a similar capability but biased more to writing than coding. I think it writes really well, and it seems to have good knowledge of e.g. WordPress coding, SQL etc. Tool-calling let it down for agentic coding, and I haven't retested it since they fixed that
- The dense 31B Gemma 4 is large and runs slowly on my machine, but has very good general knowledge, writes well, so it should I think be better than the Qwen 27B for research tasks, and it should now be pretty solid at tool-calling.
- If you don't have much VRAM, you are not doing much coding (e.g. you want short snippets) and you want to experiment with local LLMs and perhaps in particular image analysis, the Gemma 4 12B is fun. It has an integrated vision decoder which is very impressive. Codewise, it's going to fail on long context tasks.
Continue this thread — 2 replies