Lurker News
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!

Comments (342) 81 threads

Earlier comments
greggh1 reply#
It does exactly what it says it does. On my Mac mini M4 with 16GB of ram it is running at just over 5 tok/s. That jump from M4 to M5 is crazy.
gitpusher422 replies#
What exact specs do you have? It might be because it's the 256 GB version. afaik, those versions have much slower memory bandwidth than the 512 GB models

My friend tried it on an M4 MacBook Pro and got 25–27 tok/s

giobox#
This is correct, the 256gb is substantially slower as uses fewer physical memory chips - less ability to read/write in parallel. The 512gb or larger models have substantially higher read/write rates, and typically performs 50-100 percent faster in benchmarks than the 256.

Was a primary factor in me buying a 512gb M4 Mac Mini, even though I planned to use large external SSD - I wanted faster spec boot volume.

greggh#
Yeah, its the 256gb version.
dboreham1 reply#
I'm intrigued to try a slightly different experiment:

Did LLMs arise because a) humanity created circuits so large and so fast and so easy to use in parallel that only then did it become possible to run an LLM, or b) because sufficient data useful for training was accumulated such that experiments in different neural network arrangements could be done to see what came out?
My hunch is (b) and so I further wonder how far back in time could we have made a usable LLM if we had only known to try? E.g. can you run any sort of LLM on a VAX 11/780?

gitpusher42#
There was an ai winter for very long time. The math for NNs was already here, but not enough compute/data

I saw a pretty cool project to run an llm on an esp32 device https://github.com/slvDev/esp32-ai

znpy2 replies#
I wonder if i can run this on my MacBook Neo!
gitpusher422 replies#
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#
iPhones and iPads have much slower flash.
jrgifford2 replies#
Confirmed on my Neo!

Got 4.5 tokens / second sustained.

gitpusher42#
Thank you for testing and sharing, it is useful info!
raver19751 reply#
I'm only getting < 1 token/second on my Neo, did you change some settings?

Continue this thread — 1 reply

trollbridge#
Yes, a Neo is roughly equivalent to an M1.
hsienchuc2 replies#
I've run local video generation models on an 8GB graphics card and know firsthand that nothing runs smoothly when memory is insufficient. So seeing 14GB of weights crammed into 2GB of RAM is impressive.

If running continuously for over an hour (like an overnight batch task), will a fanless MacBook Air overheat and throttle? Can the SSD handle the continuous weight reads and sustained output speeds?
Great work, congratulations on the release!

m00x#
This is where MoEs shine though. You don't need all experts in memory at once. Diffusion inference doesn't have sparse inference.
gitpusher42#
Thank you very much!

I think it will throttle quite soon, but I haven't tried runs longer than 30minutes with this engine.
However, there is no constant load on ssd or gpu. i/o and gpu work are alternating and there is a brief idle periods for each i/o and gpu during inference (because gpu waits for i/o and after that i/o waits for gpu)

Load more comments