The Wall of Local Inference and the Opportunities Provided by MoE
Attempts to run large language models locally constantly collide with hardware constraints. The author works between two environments: a dual RTX 4090 (24GB × 2) desktop 'Orthrus' and a 32GB unified memory MacBook M5. The fixed tower had to abandon Ubuntu dual boot due to being pushed aside by idle gaming disks, and the 'RMD (rooms moving development)' workflow requires a laptop for coding on the go.
"Experts account for over 90% of the MoE model weights, allowing even the 180B model to run with significantly less GPU memory."
This statement is key. Qwen3.8-Flash-Next has a structure where only 10 out of 512 experts per layer are activated across 48 layers, with expert weights alone reaching 121GB in FP8. Adding a 51GB n-gram embedding table makes it unmanageable with a single device's memory. Nevertheless, the Strata engine achieved 13.5 tok/s on the 32GB MacBook. This was accomplished through expert streaming at the engine level, solving what was impossible with the basic functionality of Transformers.
Why Existing Engines' Offloading Methods Failed
Before relying on Strata, the author experimented with how llama.cpp, vLLM, and Transformers (Accelerate) handle MoE. The test model was Qwen3.6-35B-A3B, and the hardware was A10G 24GB with sufficient system RAM.
| Engine | Offloading Mechanism | Expert Computation Location | Cache/Prefetch | Major Limitations |
|---|---|---|---|---|
| llama.cpp | GGUF mmap, experts resident on CPU with `--cpu-moe` option | CPU | GPU expert cache (recently added) with `--moe-cache-mib` | Page cache thrashing when experts exceed RAM, ~10% performance drop due to graph fragmentation when cache is activated |
| vLLM | Load weights into fixed memory with `--cpu-offload-gb N`, read directly via PCIe | GPU (kernel reads CPU memory) | None (hot experts cross PCIe per token) | Lack of disk tier, optimized for large batch serving, inefficient for single user/single GPU |
| Transformers (Accelerate) | `device_map="auto"`, module-wise copying with `offload_folder` | GPU (pre-copied via hook) | None, lack of routing concept | Copies the entire expert bank of MoE layers per token, no offloading effect due to CPU/GPU unified memory on Mac |
Harry Mellor adjusted the vLLM flag to offload only experts (`--cpu-offload-params experts`), doubling the speed and further improving it with FP8 quantization. However, the conclusion for Transformers was that it was "too slow compared to vanilla to be feasible for coding agents."
Slot Pool: The Key to Solving Bottlenecks
The issue was not I/O. The first prototype managed experts on disk with an LRU cache and executed them one by one in a Python loop. With cache hits, it achieved 10.1 tok/s, while vanilla achieved 32 tok/s. Profiling revealed that the lack of `grouped_mm` kernel was the cause. Vanilla executes all experts within a layer as a single kernel, but the Python loop called kernels for each expert, leading to significant overhead.
The solution is Slot Pool.
1. Single pre-allocated device tensor shared by all layers 2. Maintain a layer-specific expert ID → slot mapping table 3. Remap the expert IDs output by the router to slot indices 4. The pool appears like a regular expert bank, allowing the use of the existing `grouped_mm` as is
Without a custom expert matmul kernel, it restored vanilla 38.1 tok/s → 34.6 tok/s (90.8%). This code was submitted as PR `huggingface/transformers#50717` and integrated with the `from_pretrained` option.
Empirical Evidence of Qwen3.8-Flash-Next: Running 180B on a 32GB MacBook
Moving on to the actual target model, three additional techniques were combined.
- Expert 3-bit quantization: 121GB (FP8) → 49GB disk, device cache 12 GiB
- Dense layer 8-bit quantization: ~5.4 GB, perplexity increase +0.2% (compared to BF16)
- n-gram table (51GB) disk residency: reads only necessary rows
Running the conversion script takes about 5 hours. After loading, the base memory usage is ~18 GiB, with a peak of 25.4 GiB for 6K prompts, fitting within the 32GB limit. If the browser is not closed, macOS starts swapping.
| Vanilla_OLMoE | 38.1 |
| Slot_Pool_OLMoE | 34.6 |
| Strata_Qwen_M4 | 13.5 |
"When experts are mapped to disk, the streaming path is taken, and the loader skips that tensor while the MoE layer switches to offloading implementation. Eight I/O threads handle misses with a single continuous read per expert, and the next two layer routers are executed early from the current hidden state to predict prefetch targets."
Prefetching, quantization, and slot pooling work together to eliminate Python overhead, making SSD bandwidth the bottleneck. The API is still under discussion with maintainers, and quantized experts are expected to be integrated with the `#50245` layer-wise quantization plan.
Remaining Challenges and Developer Guide
The current implementation only applies to MoE models with a standard expert layout. The Mac Metal kernel, model-specific conversion packages, and Transformers PR were all written with AI support, and the author focused on the role of "choosing what to try and reading profiles to decide what to maintain." The entire reproduction environment is publicly available in the space tarekziade/moe-expert-streaming.
For developers looking to try it immediately:
- Install Transformers from the PR branch (`pip install git+https://github.com/huggingface/transformers.git@moe-expert-streaming`)
- Download the converted Qwen3.8-Flash-Next weights (dense 8-bit + expert 3-bit + n-gram table)
- Specify `"disk"` in `device_map` to activate the streaming path
An era of running 180B MoE on a 32GB MacBook has begun. However, the constraint of having to close the browser still remains.