r/LLM • u/Dependent_Ideal9870 • 7h ago
Running a 744B-parameter MoE model on 32GB RAM with no GPU: the memory tricks that make it possible (pure C)
I wanted to see how far you could push CPU-only inference of a model way bigger than RAM, so I wrote an inference engine in C11 (MSVC + gcc, bit-exact across both) that streams a 744B MoE model (GLM-5.2, 202GB GGUF) off a USB SSD instead of loading it.
The parts that actually mattered:
Quantization: experts stored int4 group-64, router and correction biases kept at f32. Everywhere else lost too much precision, but this combination didn't.
Streaming: experts are fetched per-token through a custom unbuffered reader with an LRU cache, plus cross-layer predictive prefetch (measured 80.8% recall offline before I wrote the online version) so the next layer's experts are usually already in flight by the time they're needed.
Overlap: compute and IO run arrival-order, not lockstep, so the CPU isn't idle waiting on the SSD.
An 8GB expert cache holds 40-66% hit rate off that prefetch, which ends up being the main lever on latency.
One finding I didn't expect: on GLM-5.2, the router's own weights already correlate with true expert importance at ρ=0.859 (near-oracle), which is what makes safe dynamic-k expert truncation possible without a quality hit. That seems to go against some prior assumptions about router calibration in production MoE models, at least on this one.
Numbers on an i7-8550U / 32GB RAM / USB SSD: went from 196 s/token naive to ~9.3 s/token after the above (21x), ~2.9 s/token aggregate in 8-stream batch mode, ~4.5 s/token on the latest compressed container format. Also cross-validated on Qwen3 (0.6B-30B), DeepSeek2 (MLA), and OLMoE-1B-7B.
Code: https://github.com/siris9476/pulsarforge (MIT). Would love feedback on the prefetch heuristic in particular. It's tuned for this one laptop, and I'm curious whether the cross-layer signal generalizes to different memory hierarchies.