New llama.cpp PR: MoE Expert Cache Lets Large Models Run on Low VRAM

New llama.cpp PR uses expert caching plus CPU fallback to run MoE models efficiently on low-VRAM devices.
Pull Request #30966 (llama_moe_cache) in the llama.cpp community, by author am17an, proposes a VRAM optimization for MoE models: build a GPU cache for experts, compute on the GPU on a cache hit, and temporarily hand an expert's computation to the CPU on a miss, along with a tuning script to help users find a suitable cache size and strategy. MoE models activate only some experts per inference, yet all expert parameters occupy VRAM, which is the main bottleneck for low-VRAM devices. The approach offloads at the granularity of individual experts, finer than whole-layer offloading, avoiding a complete fallback to CPU. Reddit users report a significant speedup for low-VRAM users; the idea resembles the earlier Strata, but as a native llama.cpp feature its impact is greater. The PR is still under discussion, and actual gains depend on the model and hardware.
A New Solution for Running MoE Models on Low VRAM
Recently, a Pull Request named llama_moe_cache (#30966) appeared in the llama.cpp community. Author am17an proposed a VRAM optimization approach for MoE (Mixture of Experts) models: run missed experts on the CPU, along with a tuning script. According to feedback from Reddit users, this is a significant speedup for MoE offloading scenarios, especially suited to users with limited VRAM.

MoE models are characterized by activating only some experts per inference, but all expert parameters still need to be loaded into VRAM, which is extremely unfriendly to low-VRAM devices. The idea behind llama_moe_cache is to keep only the currently needed experts on the GPU, and when an expert is not cached, hand its computation to the CPU temporarily. This way, most computation can still be GPU-accelerated while avoiding a complete fallback to CPU due to insufficient VRAM.
MoE (Mixture of Experts) is a sparsely activated model architecture: the model contains multiple parallel "expert" subnetworks (usually feed-forward layers), but each forward pass selects only a few experts through a router/gate. For example, Mixtral 8x7B has 8 experts per layer, and each token activates only 2. This design allows the total parameter count to be very large while the computation per inference depends only on the number of activated experts, yielding stronger expressiveness at the same compute budget. But the key contradiction is: the parameters of unactivated experts still need to reside in memory, so the VRAM footprint of an MoE model scales with its total parameter count, not its activated parameter count—this is precisely the core bottleneck for running MoE models on low-VRAM devices.
Core Mechanism: Expert Cache and CPU Fallback
According to the PR description, the approach implements an expert cache mechanism and allows offloading expert computation to the CPU on a cache miss. This is similar to the tuning mechanism in some earlier attempts (such as Strata), but integrated within the llama.cpp ecosystem, meaning broader compatibility and community support.
Specifically, when a certain expert is needed during inference, the system checks whether that expert is already in the GPU cache. On a hit, the GPU computes directly; on a miss, the expert parameters are loaded into the CPU and computed there, while potentially updating the cache for later use. This dynamic scheduling strategy must trade off between latency and VRAM usage, and the tuning script provided by the author is intended to help users find a cache size and strategy suited to their own hardware.
Expert offloading refers to the technique of placing some or all expert parameters in CPU memory (or NVMe storage) when VRAM is insufficient to hold all experts, transferring them to the GPU on demand during inference. llama.cpp itself already supports offloading model layers to the CPU (--n-gpu-layers), but the granularity is "layer", which is not fine enough for MoE: all experts within the same layer are moved in and out together, while each token actually uses only a few of them. llama_moe_cache refines the granularity to "individual expert", keeping only hot experts on the GPU and cold experts on the CPU, thereby retaining more of the actually used parameters on the GPU side under the same VRAM budget—this is the fundamental reason it speeds things up compared to whole-layer offloading.
Significance for Low-VRAM Users
For users with consumer-grade GPUs (such as 8GB or 12GB of VRAM), running large MoE models has always been a challenge. Traditional methods either offload entirely to the CPU (extremely slow) or use partial offloading with poor efficiency. llama_moe_cache provides finer-grained control: keep only the most frequently used experts on the GPU and call the rest on demand. Reddit users commented that "this is a major speedup for low-VRAM users", indicating that the approach has already received positive feedback in real-world scenarios.
However, this approach also introduces extra overhead: data transfer between CPU and GPU, cache management logic, and possible synchronization waits. Therefore, the existence of the tuning script is crucial—users need to adjust parameters based on model structure, hardware configuration, and task type to achieve the best performance.
llama.cpp is a large-model inference framework implemented in C/C++ and oriented toward the GGUF quantization format. It is known for being cross-platform, having low dependencies, and supporting CPU/GPU hybrid inference, and is one of the most commonly used tools for local deployment of large models. The GGUF format supports multiple quantizations from 2-bit to 8-bit, allowing model size to be compressed to a fraction of the original weights. llama.cpp's Pull Request mechanism means that new features must go through community code review and discussion before being merged into the mainline, so PR numbers (such as #30966) are often used as identifiers to track the progress of a feature. For users, before a PR is merged, they usually need to compile the corresponding branch themselves to try it out.
Community Reaction and Future Outlook
The PR is still under discussion but has already attracted community attention. Some users mentioned having tried a similar mechanism in Strata and believe that llama_moe_cache may follow a similar line of thought, but as a native llama.cpp feature, its potential impact is greater. If the PR is merged, llama.cpp will be able to more efficiently support the deployment of MoE models in low-VRAM environments, further lowering the barrier to large-model inference.
It should be noted that the approach is still at an early stage, and the actual performance gain depends on the specific model and hardware. Users who are interested are advised to follow the PR's progress and use the tuning script for real-world testing.
Summary
llama_moe_cache provides a practical caching and fallback strategy for MoE model inference on low-VRAM devices. Combined with a tuning script, it has the potential to become an important performance optimization feature in the llama.cpp ecosystem. For developers focused on local large-model deployment, this is an update worth tracking.
Related articles
Tech FrontiersMuJoCo: An Analysis of DeepMind's Open-Source General-Purpose Physics Simulator
An in-depth analysis of Google DeepMind's open-source physics simulator MuJoCo: high-performance C++ kernel, MJCF modeling format, contact solving principles, MJX GPU acceleration, and robot reinforcement learning use cases.
Tech FrontiersClaude API Quick Start: The Official Quickstarts Project Collection
Anthropic's official claude-quickstarts project collection helps developers quickly build deployable apps with the Claude API. Nearly 20k stars, Python-based, great for beginners and prototyping.
Tech FrontiersAI Agents Connecting Directly to APIs: Which Calls Can Be Safely Allowed?
AI agents can call any API, but the real challenge is deciding which calls can be safely allowed. This article analyzes allowance decisions from three dimensions—intent matching, least privilege, and controllable impact—and argues that the control layer should sit outside the agent, combined with audit traceability to build a trustworthy API call governance mechanism.