Black Friday week: local AI hardware on sale. See the list.
← All guides

llama.cpp MoE Cache Explained (2026): 2.2x on an RTX 5090

The llama.cpp MoE cache keeps the most-used experts of a mixture-of-experts model in GPU memory while the rest stay in system RAM. Its author measured 2.2 times the speed on an RTX 5090. Other testers measured a slow-down on dual-GPU rigs. This page decodes the two flags, names the build that has each part, and gives the method to find your own numbers.

Jump to 10 sections
  1. Bottom Line
  2. How the Cache Works
  3. Which Build Has What
  4. Measured Results
  5. What the CPU Share Changes
  6. Find Your Own Numbers
  7. Known Problems (Open on 11 November 2026)
  8. Common Mistakes
  9. Sources
  10. See Also

See also: Qwen3-Next-80B-A3B-Instruct layer_types Explained.

Bottom Line

The MoE cache is a GPU cache for experts that live in system RAM. It is off by default. It can double the output speed of a large mixture-of-experts model on one fast card, and it can slow down a dual-GPU rig.

FlagWhat it doesDefaultFirst build
--moe-cache-mib NSize of the GPU cache for experts kept in RAM, in MiB0 (off)b11480 (7 Oct 2026)
--moe-cache-cpu-share FShare of cache misses the CPU computes, 0 to 1, once the cache is full0.00b12191 (7 Nov 2026)
-cmoe, --cpu-moeKeeps all expert weights in RAM. The cache needs this, -ncmoe or -ot.offolder
-ncmoe N, --n-cpu-moe NKeeps the experts of the first N layers in RAMoffolder
scripts/moe-cache-tune.pyStarts the server 6 times and prints the best pair of flagsn/ab12191

Neither cache flag has a short form. Both are marked experimental in llama.h.

Three facts decide whether it helps you:

  1. It speeds up output, not prompt reading. The cache fills only on batches of 32 tokens or fewer.
  2. The stable release does not have all of it. llama.cpp v0.9.0 (4 November 2026) has --moe-cache-mib only. The CPU share and the tuning script need a rolling build, b12191 or newer.
  3. Hit rate and PCIe speed set the result. The author measured 2.2 times on an RTX 5090 at an 89% hit rate. One tester with two cards measured a slow-down at 47% and 58%.

Where the mechanism points at hardware, it is the VRAM left over after the layers and the PCIe link. See the cards this matters for.

How the Cache Works

A mixture-of-experts model uses a few experts for each token. That is why you can keep the experts in RAM and the rest of the model on the GPU. Our MoE offload flags guide covers that static split.

The static split has a cost. Every expert in RAM runs on the CPU. The MoE cache changes that:

StepWhat happens
Loadllama.cpp reserves the cache on the GPU, in slots. Layers with the same expert layout share one cache.
A token needs an expert that is in the cache (a hit)The GPU runs it. No copy.
A token needs an expert that is not in the cache (a miss)llama.cpp uploads it from RAM to the GPU over PCIe, then runs it.
The cache is fullIt evicts a slot. The policy is ClassLRU: 8 frequency classes, with a score that halves every 128 tokens.
The cache is full and --moe-cache-cpu-share is above 0That share of the misses runs on the CPU and is not cached. The least-used misses go to the CPU.
A batch is larger than 32 tokensIt reads the cache but does not fill it.

The rule for the last row is in the source: large batches “use most experts of a layer, so they gain little from the cache and would evict the experts used in generation”.

Which layers the cache acts on. Only a layer that sits on a GPU while all of its experts sit in host memory. So you need -ngl high enough to put the layer on the card, plus -cmoe, -ncmoe or -ot to keep its experts in RAM. If no layer qualifies, llama.cpp warns: “no layer has all of its experts in host memory, MoE cache is disabled”.

The smallest cache. The cache must hold the experts of one token. Below that, llama.cpp stops with “MoE cache is too small to hold the experts of one token”.

Which Build Has What

ChangePull requestMergedFirst build
The cache, --moe-cache-mib#298877 Oct 2026b11480
SLRU eviction#3063719 Oct 2026not checked
ClassLRU eviction#312336 Nov 2026b12170
--moe-cache-cpu-share and the tuning script#309667 Nov 2026b12191
No cache on the draft model in llama-speculative#314978 Nov 2026b12201
The CPU part no longer waits for cached experts#318888 Nov 2026b12206

llama.cpp v0.9.0 sits at build b12110. It has the first row only. The newest build release on 11 November 2026 is b12292. If your llama-server --help does not list --moe-cache-cpu-share, your build is older than b12191.

Measured Results

Every number in this section is from the llama.cpp pull request threads. None is ours. The numbers do not transfer between machines: the CPU, the RAM speed and the PCIe link all change them.

The author’s benchmark (pull request #29887). Qwen3.8-Flash-Next Q4_0, 93.7 GiB with 65.4 GiB of experts, EPYC 7742 with 16 threads, PCIe 4.0 x16, 32,768 context.

GPUConfigExperts in VRAM (layers + cache)OutputSpeed-upHit rate
RTX 4090--fit, no cache16.5 + 0.0 GB25.0 t/s1.00xn/a
RTX 4090--fit --moe-cache-mib 654410.4 + 6.4 GB39.4 t/s1.57x72%
RTX 4090-cmoe --moe-cache-mib 110000.0 + 10.7 GB40.7 t/s1.62x77%
RTX 5090--fit, no cache24.5 + 0.0 GB30.8 t/s1.00xn/a
RTX 5090--fit --moe-cache-mib 654417.9 + 6.4 GB54.5 t/s1.77x77%
RTX 5090-cmoe --moe-cache-mib 190000.0 + 18.6 GB67.8 t/s2.20x89%

Read the last row. The fastest setup puts no whole expert layer on the card. All experts stay in RAM, and 18.6 GB of VRAM holds the cache. A cache of the hot experts beat a static split of whole layers.

Where the cache was slower (community reports, same thread).

Tester, dateHardwareModelWith cacheWithoutHit rate
paulp83, 7 Oct2x RTX 5090, PCIe 4, Threadripper PRO 3975WXGLM-5.3-Flash UD-IQ3_XXS14.23 t/s (11,000 MiB)17.75 t/s47%
paulp83, 7 OctSame, two-GPU layoutSame21.50 t/s (15,000 MiB)24.08 t/s58.4%
Volunteer-1, 7 Oct2x RTX 3090, PCIe 4 x8not stated11.89 t/s (18,000 MiB)18.05 t/snot stated
LeoBorcherding, 7 OctRadeon AI PRO R9700 32GB, WindowsQwen3.8-Flash-Next IQ1_M11.9 t/s (8,000 MiB)11.8 t/s85.3%

LeoBorcherding wrote: “At 85% hits the cache breaks even with the CPU path here”. With a 16,000 MiB cache and 94.4% hits, the same card reached 23.2 t/s. These tests ran in October, before ClassLRU and the CPU share. They show the rule, not today’s exact numbers: a low hit rate on a slow link costs more than the CPU path.

ClassLRU (pull request #31233). The author measured +6% output on Qwen3.8-Flash-Next and +7% on GLM against the older SLRU policy, with 8% fewer uploads. Hit rates in the description: SLRU 86.5%, ClassLRU 87.6%, and 93.8% for the theoretical best policy. The gain is against SLRU, not against a run with no cache.

What the CPU Share Changes

With a share of 0, every miss waits for an upload. With a share above 0, the CPU computes part of the misses from the copy in RAM. That helps most when the cache is small.

The author’s example (pull request #30966). Qwen3.8-Flash-Next IQ4_NL, 64,800 MiB of experts in host memory, -ngl 999 -fa on -cmoe -t 8 -c 128000. The description names no GPU or CPU.

CacheShare 0Share 0.5Share 0.95
6,464 MiB24.2 t/s (73.3% hits)29.6 t/s47.6 t/s
19,392 MiB65.5 t/s (93.5% hits)66.4 t/s54.1 t/s

A small cache wants a high share. A large cache wants a share near 0. At 19,392 MiB the 0.95 share was 17% slower than share 0.

Community reports on 8GB and 11GB cards (same thread, builds before the merge):

Tester, dateCardModelNo cacheSmall cache: share 0 / 0.95Larger cache: share 0 / 0.95
MichaelDietzel, 23 OctRTX 2080 Ti 11GBQwen3.6-35B-A3B UD-Q6_K_XL42.11 t/s2,752 MiB: 23.5 / 51.96,784 MiB: 50.2 / 64.5
marceldev89, 24 OctRTX 3070 8GBCyber-Tiel-Coder-35B-A3B UD-Q4_K_Sabout 35 t/s1,728 MiB: 32.0 / 48.83,136 MiB: 41.0 / 62.4

On the RTX 2080 Ti, a 2,752 MiB cache at share 0 was slower than no cache (23.5 against 42.11 t/s). The same cache at share 0.95 was faster (51.9). On small cards the share is not optional.

One tester (sasa7812, 26 October) reported the opposite on an R9700 on PCIe 5 x16 with Vulkan: any share above 0 made output about 15% slower. A fast link makes uploads cheap.

Pinned memory matters. The llama.cpp docs state that the experts in RAM are pinned with -lm none, -lm mlock and -lm dio, and not with the default mmap. Pinned experts upload at the full speed of the link, “so the CPU share often does not help then”.

Find Your Own Numbers

Use a build at b12206 or newer. Then run the tuning script with your normal server command after --:

python3 scripts/moe-cache-tune.py -- build/bin/llama-server -m model.gguf -cmoe -t 8 -c 32768

What the script does, from the llama.cpp docs and the script:

  • It starts the server 6 times: two cache sizes, each at shares 0, 0.5 and 0.95.
  • The small size is 10% of the experts. The large size is 30% of the experts, or what fits on the card.
  • It prints a measured table, a machine: line with the upload speed and the CPU speed, and a predicted table.
  • It ends with recommended: --moe-cache-mib N --moe-cache-cpu-share F. The rule is the lowest share within 5% of the fastest result.
  • If every expert fits on the card, it tells you to drop -cmoe.

To check before the run if your model fits on your card, enter your VRAM and system RAM in the local model calculator. If the model fits on the GPU, you do not need -cmoe or the cache.

Options: --max-mib N sets the largest cache, --out DIR sets the run folder, --markdown prints Markdown tables. The run takes a few minutes, and most of that is model loading.

To check by hand, add -lv 4 to your server command. At exit llama.cpp prints a line that starts with llama_moe_cache: and gives hits, misses, misses on the CPU, the hit rate and the MiB uploaded. Compare the output speed and the hit rate with and without the cache. If the hit rate is low and the speed drops, raise the cache size or the share, or turn the cache off.

A starting command for one 24GB or 32GB card and a large MoE model:

llama-server -m model.gguf -ngl 999 -cmoe -fa on -lm none \
  --moe-cache-mib 6544 --moe-cache-cpu-share 0 -c 32768

6,544 MiB is the size the author used for a model with 65.4 GiB of experts, close to the 10% rule. Use 10% of your own model’s expert size, then run the tuner.

Known Problems (Open on 11 November 2026)

IssueBackendProblem
#32041WindowsThe tuning script crashes with ValueError: Unsupported signal: 2 and leaves llama-server running
#31911ROCm, with a draft modelThe script under-reports free VRAM. It capped the cache at 1,691 MiB where 5,696 MiB runs
#31675ROCm, RX 6800 XT--moe-cache-mib aborts at load at 2,048, 4,096 and 6,144 MiB
#31510SYCL, 2x Arc Pro B60A 40,000 MiB cache stalls; 15,000 MiB completes
#31421Metal, M3 MaxDefault weight repacking disables the cache for Q4_0 experts; the tester needed -nr

Two more limits from the source: -sm tensor stops with “MoE cache does not support tensor parallelism”, and there is no cache flag for a draft model. The source accepts any GPU backend. We found no official list of supported backends.

An open pull request (#32076, 11 November) removes sync points. Its author expects a large gain on Vulkan and Windows and about 10% on CUDA on Linux. It is not merged.

Common Mistakes

  1. Setting --moe-cache-mib with all experts on the GPU. The cache then has nothing to act on. It needs -cmoe, -ncmoe or -ot.
  2. Expecting faster prompt reading. Large batches do not fill the cache.
  3. Using v0.9.0 and typing --moe-cache-cpu-share. That flag is in b12191 and newer.
  4. Copying a cache size from another machine. The 4090 and 5090 rows above came from a PCIe 4.0 x16 slot. An x8 slot or a riser changes the result.
  5. Leaving the share at 0 on an 8GB or 11GB card. On two such cards a small cache at share 0 was slower than no cache.

Sources

  • llama.cpp pull requests #29887 (cache, merged 2026-10-07), #31233 (ClassLRU, 2026-11-06), #30966 (CPU share and script, 2026-11-07), #31497 and #31888 (2026-11-08): descriptions, benchmark tables and thread comments, read 2026-11-11 through the GitHub API
  • llama.cpp master: common/arg.cpp (flag names, defaults, help text), docs/moe-cache.md, src/llama-moe-cache.cpp (batch limit, eviction, log lines, error text), scripts/moe-cache-tune.py, include/llama.h; read 2026-11-11
  • llama.cpp releases: v0.9.0 (2026-11-04, build b12110) and build b12292 (2026-11-11); first-build tags from git tag --contains
  • Issues #32041, #31911, #31675, #31510, #31421 and pull request #32076; read 2026-11-11
  • Community measurements are quoted with the tester’s name and date. They are community-reported, not verified by OpenClaw DC.

See Also

Before you buy a card for MoE models, check the tested hardware list for current prices by tier.

Was this guide useful?

Read next

Can I Run Nanbeige4.3 33B Locally? (2026): Yes, on 24GB
Nanbeige4.3 33B is a dense 33B agent model. Exact GGUF sizes, why its KV cache is 3.25x Qwen3.8 27B's, what fits 24GB and 32GB cards and Macs, and measured DGX Spark speeds.
Can I Run Flint Locally? (2026): Yes, on a 24GB Card
Recursive's Flint is a 39.8B MoE with 2.5B active. Byte-exact GGUF sizes from 10.57 GiB to 74.16 GiB, the 28 KB/token cache math, and which quant fits 16GB, 24GB, 32GB GPUs and 32-64GB Macs.
Can I Run Sage-A1.5 Locally? (2026): Yes, on a 24GB GPU
Sage-A1.5 is a 35B Qwen3.6-based MoE with about 3B active. Byte-exact GGUF sizes from 12.34 to 66.19 GiB, the 20 KB/token cache math, and which quant fits 16-32GB GPUs and 32-64GB Macs.
llama.cpp mmap vs mlock (2026): --load-mode none, mlock and mmap+mlock Explained
What each llama.cpp --load-mode does: auto, none, mmap, mlock, mmap+mlock and dio. Which old --no-mmap and --mlock command each one replaces, when to turn mmap off, and how to read the mode from the load log. Checked against llama.cpp master on 2026-11-28.