Transformers adds experts_offload streaming and achieves near‑native Strata speed
Transformers introduces an experts_offload option that streams MoE weights from SSD, replaces the LRU cache with a slot‑pool, and reaches token generation within 6 % of native Strata performance while delivering 13.5 tok/s on a Mac M5.
Transformers adds an experts_offload option to from_pretrained that streams mixture‑of‑experts weights from disk. The option is enabled via a device_map entry "experts.*": "disk". The implementation swaps the previous LRU cache for a slot‑pool that preallocates a shared device tensor, allowing grouped_mm to run unchanged and reaching 34.6 tok/s on OLMoE‑1B‑7B. Missing experts are read by eight I/O threads with contiguous reads, and routers of later layers prefetch experts based on current hidden states.
Streaming MoE experts directly from SSD achieves token generation speed within 6 % of native Strata performance. Running Qwen 3.8‑Flash‑Next (180 B) on a MacBook M5 with 32 GB unified memory yields 13.5 tok/s. In A10G GPU benchmarks, Strata with Q8_0 quantization reaches 82‑88 tok/s, surpassing llama.cpp (63‑64 tok/s) and vLLM (as low as 20.1 tok/s). Offloading only the experts in vLLM doubles its throughput, and FP8 quantization further reduces memory per expert, boosting speed. On the same M5 Mac, Transformers decodes at 10 tok/s while Strata 0.1.60 decodes at 14.8 tok/s (1.5× faster); for a 4 K prefill, Transformers runs at 68 tok/s versus Strata 220 tok/s (3.2× faster).
For Qwen 3.8‑Flash‑Next, experts quantized to 3 bits occupy 49 GB on disk with a 12 GiB device cache; dense layers in 8‑bit use ~5.4 GB, and a 51 GB n‑gram table remains on disk. Loading the model consumes ~18 GiB RAM, and a 6 K token prompt peaks at 25.4 GiB, close to the 32 GB Mac limit. vLLM‑metal on Apple GPUs cannot run the model on 32 GB because the n‑gram table must stay in memory. The conversion script for expert streaming takes approximately 5 hours to complete.
- Code and model files are hosted in the Hugging Face Space
tarekziade/moe-expert-streamingand can be downloaded viasnapshot_download. - Install the PR version with
pip install "git+https://github.com/huggingface/transformers.git@refs/pull/50717/head". - Enable streaming offload by using the
experts_offloadoption with adevice_mapthat routes"experts.*"to"disk".