A custom inference engine for half a million tokens of context on a 24 GB MacBook
- Hardware
- 24 GB MacBook
- Models & engines
- Ternary Bonsai 2 27B (a 2-bit build of Qwen3.8-27B)
Custom inference engine with a Metal kernel, compared against llama.cpp - Key gotcha
- The stock YaRN mscale value breaks 2-bit models; he uses mscale = 1.0.
What they built
Marco Franzon wanted to be ready for the Qwen4 release on his own laptop, so he built a custom inference engine for Ternary Bonsai 2 27B, a 2-bit build of Qwen3.8-27B, on a 24 GB MacBook.
The engine targets very long context: he reports half a million tokens of context running locally on the MacBook.
Setup
- 24 GB MacBook
- Ternary Bonsai 2 27B (a 2-bit build of Qwen3.8-27B)
- Custom inference engine with a Metal kernel, compared against llama.cpp
How it works
- Sparse paged KV: each decode step attends only to the top pages, picked from per-page min/max key summaries.
- NVMe acts as a KV tier, holding 32 GB of cache with only 2 GB in RAM.
- A custom Metal flash-decoding kernel reads through the page table.
- MTP speculative decoding, where verifying 2 tokens costs about the same as decoding 1.
Results & numbers
- 500k context at 19 tok/s with 15 GB peak RAM.
- He reports it is 2.3x faster than llama.cpp at 4x the context.
Gotchas
- The stock YaRN mscale value breaks 2-bit models; he uses mscale = 1.0.
“Half a million tokens of context. 27B model. 24 GB MacBook.”— Marco Franzon
Similar setups
Booting a local Qwen3.6 35B chat server straight from UEFI on an RTX 3090
Alexey Fateev wrote a 528 KB pure-assembly UEFI file that boots an RTX 3090 with no operating system, loads a 20.5 GB GGUF model and serves an OpenAI-style API and web chat on his LAN.
Running Inkling 2 Mini on a 12 GB AMD card for a Twitch AI moderator
An applied AI engineer tuned llama.cpp to run Inkling 2 Mini on an RX 6750 XT for his home Twitch moderator project, and found that a shared-KV loop setting was quietly hurting the model's quality.
Faster local Qwen on an AMD eGPU with the llama-cpp-rdna-boosts patches
A developer running a Qwen3.8-27B fine-tune on an AMD R9700 eGPU swapped vanilla llama.cpp for a small set of AMD-specific patches in a Podman image and roughly doubled prefill speed.
Running 80 GB MoE models on two 16 GB GPUs with llama.cpp 1.0
Gancho Stoychev measured five llama.cpp 1.0 settings one at a time on his homelab box with two RTX 5060 Ti 16 GB cards, running Qwen3.8-Flash-Next and DeepSeek V4 Flash, each about 80 GiB.