Run oversized MoE LLMs on small Macs with ramgod
ramgod streams Mixture-of-Experts weights from SSD to RAM, enabling 8 GB Macs to run 11–18 GB models at 3–5× the speed of llama.cpp.
A new open-source tool called ramgod enables Apple Silicon Macs with limited memory to run large Mixture-of-Experts (MoE) language models that exceed their available RAM. Released in late November 2026 by developer Ri4dH, the project leverages aggressive I/O optimization and predictive prefetching to stream model weights from solid-state storage directly into memory during inference.
The tool targets a specific hardware constraint: running high-quality 4-bit quantized models on machines like the 8 GB M1 MacBook, where standard inference engines typically fail or perform poorly due to memory pressure. By bypassing operating system page fault overhead, ramgod achieves token generation speeds significantly higher than existing baselines.
What happened
Standard inference libraries like llama.cpp rely on the operating system to manage memory when a model exceeds physical RAM. For MoE models, which activate only a subset of parameters per token, this often results in inefficient paging. On an 8 GB M1 Mac running macOS 26, default llama.cpp settings fail entirely for models like gpt-oss-20b (11.6 GB) and Qwen3-30B-A3B (18.6 GB) because they cannot fit into GPU memory.
Even with tuned settings that force experts onto the CPU via memory-mapped files, llama.cpp achieves only 0.72 tokens per second for gpt-oss-20b and 1.12 tokens per second for Qwen3-30B-A3B. These speeds are generally considered too slow for interactive use. The bottleneck is not the mathematical computation itself, but the latency incurred when the OS fetches scattered 16 KB pages from the SSD as needed.
ramgod addresses this by taking control of the data movement process. In benchmark tests conducted on the same 8 GB M1 hardware, ramgod ran gpt-oss-20b at 3.66 tokens per second and Qwen3-30B-A3B at 3.54 tokens per second. This represents a 5.1× and 3.2× speedup over the best-configured llama.cpp baseline, respectively. The output text remains identical to llama.cpp, as ramgod does not alter the mathematical operations, only the timing and method of weight delivery.
How it works
MoE models consist of many "experts," but only a few are active for any given token. ramgod exploits this sparsity by hooking into llama.cpp’s internal router output, specifically the ffn_moe_topk tensor, to determine which experts are needed before they are executed. Instead of waiting for the OS to trigger a page fault for each missing weight, ramgod proactively reads the required experts in large, parallel 4 MB chunks using eight I/O threads. This approach utilizes the SSD’s full bandwidth of approximately 4.3 GB/s, compared to the ~0.4 GB/s achieved by random small-page reads.
The system also employs a technique called "pre-gating" to predict future memory needs. By applying the router of the next layer to the current layer’s hidden state, ramgod predicts which experts will be needed in the subsequent step with 87–89% accuracy. It prefetches these predicted weights while the current layer computes, hiding I/O latency behind computation. Additionally, two background threads "touch" newly read pages immediately after they arrive from disk. This forces the macOS memory manager to map the pages before the compute threads access them, avoiding costly double-fault penalties during matrix multiplications.
To prevent frequent eviction of useful weights, ramgod locks the most frequently used experts for each layer into physical RAM using mlock. By default, it pins about a quarter of the available RAM, ensuring that the most critical parameters remain resident while less used experts are left to the system’s page cache. This strategy reduces the total bytes read per token by 15–20% and prevents the OS from compressing or swapping out the active model weights.
Key details
- Performance: On an 8 GB M1 Mac, ramgod achieves 3.66 tok/s for gpt-oss-20b and 3.54 tok/s for Qwen3-30B-A3B, outperforming llama.cpp by factors of 5.1× and 3.2×.
- Hardware Requirements: Currently supports only Apple Silicon Macs running macOS, relying on specific features like the unified buffer cache and
F_RDADVISE. - Model Support: Works with any llama.cpp-compatible MoE architecture that exposes
ffn_inpandffn_moe_topktensors, including tested models like gpt-oss-20b and Qwen3-30B-A3B. - Memory Management: Uses
mlockto pin frequently used experts in RAM, reducing I/O churn and preventing macOS from compressing model weights. - Dependencies: Built against llama.cpp version 1.0.0 (Homebrew build 12359); future updates to llama.cpp may break compatibility due to reliance on internal tensor names.
- License: Released under PolyForm Noncommercial 1.0.0, allowing free use for personal, research, and educational purposes but requiring a commercial license for profit-driven use.
Why it matters
For developers and researchers working with consumer-grade hardware, ramgod removes a significant barrier to experimenting with large MoE models. Previously, users with 8 GB or 16 GB Macs had to choose between heavily quantized models that sacrificed answer quality or slow, non-interactive inference speeds. ramgod allows these users to run standard 4-bit quantized models that were previously inaccessible, preserving model fidelity while maintaining usable throughput.
The project also highlights the importance of I/O optimization in local LLM inference. As models grow larger, the bottleneck shifts from compute to memory bandwidth and storage latency. By demonstrating that proactive prefetching and large-block reads can outperform OS-level demand paging by an order of magnitude, ramgod provides a blueprint for future inference engines. It shows that understanding the specific access patterns of MoE architectures can yield substantial performance gains without requiring specialized hardware.
What you can do
- Install Homebrew and llama.cpp on your Apple Silicon Mac, then clone the ramgod repository from GitHub.
- Download a GGUF-formatted MoE model, such as gpt-oss-20b, and test it using the
./build/ramgod chatcommand. - Close memory-intensive applications like web browsers and Docker to maximize free RAM for expert caching.
- Keep your Mac plugged in and disable Low Power Mode, as power-saving settings can halve inference speed.
- Run the included A/B benchmark script (
scripts/engine_ab.py) to compare ramgod’s performance against llama.cpp on your specific hardware. - If you encounter compatibility issues, check the troubleshooting guide for instructions on building against a specific pinned version of llama.cpp.



