Top
Best
New

Posted by gitpusher42 9 hours ago

Show HN: Open-source engine running Gemma 4 26B in 2 GB RAM on any M-series Mac(github.com)
Hi HN,

I 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!

597 points | 209 commentspage 5
Pragmata 7 hours ago|
Would it be possible to use this for kimi k3?

what are the limitations

orliesaurus 1 hour ago||
Thank you honestly
gitpusher42 1 hour ago|
Thank you! If you can use it for your tasks I would be happy!
sscarduzio 8 hours ago||
How does this compare to DwarfStar4?
fghorow 7 hours ago||
I'm curious too!

One obvious thing is that the memory requirements for this are substantially smaller than DwarfStar-- which AFAIK can only start to be used at 64GB ram and upwards. Another obvious thing is that antirez is pretty obsessed with making sure that DwarfStar passes all of DeepSeek V4 Flash's generating tests (loosely). I suspect that is also true of DwarfStar's implementation of GLM5.2, but I don't use that.

liuliu 7 hours ago|||
DS4 is designed to do real-work. Gemma 4 is not going to cut it.
lemonlimesoda 6 hours ago||
[dead]
gitpusher42 1 hour ago||
uh, I don't think it is possible to compare them. DwarfStar4 is for high end macs and a lot of ram. this project is more targeted to low end devices and "general use" Gemma4 model
awesomeusername 4 hours ago||
Asahi?
gitpusher42 4 hours ago|
Uh, not really, unfortunately. Asahi uses Vulkan for gpu, but kernels for this project are metal.
znpy 8 hours ago||
I wonder if i can run this on my MacBook Neo!
gitpusher42 8 hours ago||
I haven't tried it but it should work! You can try it and share your results, it would be really appreciated

I tried it on my wife's M1 MacBook Air 512GB and it gets 4–5 tok/s

Also, it must be easy to adjust for iPhones and iPads in theory

trollbridge 6 hours ago||
iPhones and iPads have much slower flash.
trollbridge 6 hours ago||
Yes, a Neo is roughly equivalent to an M1.
weras 7 hours ago||
Rushing to try it!
gitpusher42 6 hours ago|
Thank you! Share your tok/s results later
novoreorx 6 hours ago||
It’s like how Super Mario Bro was managed to put into 40KB of ROM
gitpusher42 6 hours ago|
My friend just compared this project to running Cyberpunk on a very old machine at 16 FPS, huh
fintuner 5 hours ago||
[flagged]
Helldez 4 hours ago||
[dead]
Natalia724 7 hours ago|
[dead]