llama.cpp's MoE cache CPU share helps only when your expert cache is small. On a small cache, the reported benchmark went from 24.2 to 47.6 tokens per second; on a larger cache, the same setting dropped from 65.5 to 54.1. Run the bundled tuner before you switch it on.
llama.cpp MoE Cache CPU Share: What the Flag Actually Does
llama.cpp's MoE cache CPU share is a flag that lets a CPU compute some cache-missed experts from system RAM instead of waiting for them to upload over PCIe. It ships at a default of zero, so the headline feature does nothing until you set it. The change merged into the llama.cpp repository on November 7, 2026.
A mixture-of-experts model splits its layers into many small subnetworks called experts, and a router picks a few of them per token. Qwen's model card for Qwen3-30B-A3B states that it activates 8 of its 128 experts per token, which is why most of a large model can sit unused in system RAM while only a slice is needed at any moment. That arrangement lets a model too big for your card still run, with experts held in host memory.
The October cache update, described in the project's documentation as a video memory budget for experts that live in CPU memory, gave the GPU a fixed set of slots for those experts. A hit runs on the GPU with no copy. A miss was uploaded over PCIe while the GPU idled. The November change adds a second path, where the CPU does the missed expert's math locally and both partial results are added together.
Why PCIe Bandwidth Is the Bottleneck the Flag Targets
The flag exists because PCIe upload bandwidth is several times slower than the CPU's read from system RAM in the benchmark machine. On the author's desktop, the link moved about 10 GiB/s while the CPU read experts from RAM roughly five times faster. Every miss spent that wait with the GPU idle.
Copying an expert over the link is not free even when the transfer is fast. The GPU has to finish the copy before it can compute, and a layer built only from GPU-resident experts stalls until the copy lands. The CPU, sitting next to the same weights in RAM, can run that expert's arithmetic while the GPU handles the cached ones.
The transcript attributes the original diagnosis to a developer who proposed keeping the repeatedly used expert weights in a pool of slots, in a proposal predating the October cache. Those names were not independently verified here and are omitted rather than guessed.
How the Split Runs on Both Chips
The layer is built on both chips at once when the share is active. On the GPU side, the layer runs from the experts already in the cache, and any expert handed to the CPU reads as zero there. In system RAM, the CPU runs those handed-off experts from its own copies. The two outputs are added before the layer finishes.
Results are handed over in the background so the CPU does not wait for the GPU and both work in parallel. The overhead is a flat cost that the tuner charges whenever the share is on at all, regardless of how many misses the CPU takes.
There is one condition worth stating plainly: every slot in a section of the cache must hold an expert before the CPU share kicks in. Until the cache is full, misses still make the PCIe trip. The CPU path engages only after the desk is full.
Large batches behave differently. According to the project documentation on the MoE cache, a batch larger than 32 tokens reads the cache but does not fill it, because large batches use most experts of a layer and would evict exactly the experts generation needs.
The Size You Set With --moe-cache-cpu-share
You set the amount with the flag --moe-cache-cpu-share, which takes the fraction of misses the CPU computes instead of uploading. Zero is the default and means every miss still travels over the link. A value near one sends almost every miss to the CPU.
The pull request does not specify which misses go to the CPU. The observable rule from the documentation is that the least-used misses go there. That distinction matters because a cache serving generation traffic and a cache serving large prompts have different miss patterns.
You need a llama.cpp build from release b12191 or later for the flag to exist. The transcript notes the author disclosed that the implementation was built with Claude, Anthropic AI assistant, which is an attribution detail rather than a performance claim.
Benchmark Evidence: Small Cache Doubles, Big Cache Drops
The author's own table, reported by channels covering the update, shows one setting nearly doubling decode speed and the same setting slowing a bigger cache. Decode on a small cache with the share off ran about 24.2 tokens per second, and with the share near full it ran about 47.6 tokens per second on the same desktop. On a much larger cache, the same machine ran about 65.5 tokens per second with the share off and about 54.1 with the share near full.
Treat that as a single-machine result. The pull request's earlier measurement showed a bit over twice on an RTX 5090, and a reviewer reported only about a 10% gain on their own card. Those numbers describe different hardware and different configurations.
The community results in the thread point the same way for small cards. An 8 GB RTX 3070 run reported close to 1.5x, and an 11 GB RTX 2080 Ti sat near that. The same 3070 run measured against a no-cache baseline came closer to 1.75x. On small cards, plan on half again, not double.
Hit rate moved the other way in the small-cache run. It went down, and the only explanation on record is that fewer misses were being uploaded into the cache in the first place. A high share means fewer uploads, so fewer chances for the cache to fill.
Enabling It: How to Run the Tuner
The tuner is a Python 3 script that runs your own server at a small grid of settings and picks a share from your machine's measured costs. It is shipped with the feature and is the recommended path to a setting. Running it takes time, so give the machine to itself while it works.
The command is python3 scripts/moe_cache_tune.py followed by your usual llama-server line, with the tuner flag appended so the script measures real server runs. It tests a small grid of cache sizes and shares rather than guessing from a specification sheet.
The grid uses two cache sizes, one about a tenth of your expert memory and one three times that, each at a few shares from off to nearly full. It records which experts your model routes to, fits a timing model with separate costs for uploads, CPU work, splitting and overlap, replays the recorded routing to predict untested settings, and picks the lowest share within 5% of the fastest result.
That 5% preference is written into the script, which is why a big cache can easily come back with the share turned off. On the author's desktop, the tuner recommended an even bigger cache with the share disabled. The script that ships with the CPU share told that machine not to use it.
Deciding Whether Your Cache Is Small Enough
The deciding question is how much of your expert memory the cache holds. With a small cache, plenty of misses are left, and taking them off the PCIe link saves a lot. With a big cache, few misses remain, and the flat split cost is what you keep paying.
On the author's desktop, three times the cache size was enough to flip the recommendation to off. If your cache holds a small slice of your experts, expect the tuner to push the share up. If it holds a much bigger slice, expect it to say off, and believe that answer.
Batch shape changes the calculus. The transcript cites a test of the October cache on a free 16 GB Tesla T4, a cloud GPU card, where nearly every expert lookup came from video memory with a model too big for the card, but the hit rate fell a long way once it served several requests at once. The NVIDIA T4 datasheet lists the card's 16 GB of GDDR6, which is the configuration that test used.
Comparison: When the Share Helps and When It Hurts
The share is a win on small caches with heavy misses and a loss on large caches where the GPU already serves most lookups. The table below summarizes the reported configurations; every row is a decoded token-rate measurement from the author's desktop or the comment thread, not an independent benchmark.
The single-machine nature of these numbers is the point. One desktop produced nearly doubling, one reviewer produced about 10%, and one card reported about 1.5x. The mechanism explains the spread, and the tuner measures which row your machine lands in.
Frequently Asked Questions
- Does llama.cpp's MoE cache CPU share always speed up MoE models? No. The reported desktop run nearly doubled decode on a small cache and dropped from about 65.5 to 54.1 tokens per second on a large cache. The flag defaults to zero and the bundled tuner can recommend leaving it off.
- What value should I set for --moe-cache-cpu-share? Let scripts/moe_cache_tune.py pick it. The script runs your server at several cache sizes and share values, fits a timing model to your machine's upload and CPU costs, and returns the lowest share within 5% of the fastest result it found.
- Which llama.cpp build added the CPU share flag? The change merged on November 7, 2026, and release b12191 or later carries the flag. Builds before that date do not have --moe-cache-cpu-share or the tuner script.
- Why does the hit rate fall when I raise the CPU share? Fewer misses get uploaded into the cache, so fewer experts move into the slots. The reported small-cache run showed a lower hit rate alongside the faster decode, and lower upload activity is the explanation on record.
- Does this flag help multi-user or large-batch serving? Less than it helps single-stream generation. Batches larger than 32 tokens read the cache without filling it, and a concurrent-request test on a Tesla T4 showed the hit rate dropping a long way, so validate the tuner's pick under your real traffic.
Turn the Explainer Into a Written Article
The most useful part of this story is the table row that looked like a failure: the big cache that got slower when the share went up. That row is what makes the tuner the actual recommendation rather than the 2x number, and it is the kind of detail that gets lost when a technical explanation only exists inside an eight-minute video.
If you have similar explanations, interviews, or hard-won tuning lessons sitting in a YouTube video, YouBlog turns the recording into a structured draft you can edit and publish. Paste the video URL, let it transcribe the audio, and review the article it generates.
The tooling behind that workflow is documented at CrazyStack, and the CrazyStack TypeScript templates are the same stack the team covers as Crazystack TypeScript. Contributors like Dev doido write about these setups, and the YouBlog carries more of the writing.