# Run a 120B MoE on an 8-24GB GPU with llama.cpp --n-cpu-moe

Moving MoE experts into system RAM can make a model five times faster, or noticeably slower. Both are true. With Qwen3.8 Flash Next now running on 8GB and 12GB cards, here is what the flag moves, where your RAM becomes the limit, and which speed tricks quietly change the answers.

Updated Nov 25, 2026 · By Ari Vale

This page has referral links. As an Amazon Associate we earn from qualifying purchases.

Our Vast referral code: 623346 (link: https://cloud.vast.ai/?ref_id=623346). New users get no bonus from it; we earn 3% of what referred users spend (Vast's referral program docs: https://docs.vast.ai/guides/reference/referral-program?ref_id=623346).

llama.cpp's `--n-cpu-moe N` keeps the MoE expert weights of the first N layers in system RAM, so a mixture-of-experts model bigger than your GPU still runs: `llama-server -m model.gguf -ngl 99 --n-cpu-moe 30`. The rule is simple: use the **lowest N that fits**, because a lower N keeps more experts on the GPU and is faster. `--cpu-moe` does the same for every layer at once. The flag moves weights, it does not shrink them, so your RAM plus VRAM must still hold the model: gpt-oss-120b needs about 62.7 GB, which means 64 GB of RAM beside an 8 to 12 GB card, not 32 GB (see the RAM + VRAM table below).

```bash
# 120B-class MoE on a 12-24 GB card: everything on the GPU except the experts of the first 30 layers
llama-server -m gpt-oss-120b-MXFP4.gguf -ngl 99 --n-cpu-moe 30 -c 16384
# out of memory? raise N by 2-4. loads with VRAM to spare? lower N. no flag at all = let --fit decide
```

> **Inkling 2 Mini bug, read November 22, 2026**
>
> **Running Inkling 2 Mini? Don't offload its looped layers yet.** llama.cpp [issue #32710](https://github.com/ggml-org/llama.cpp/issues/32710) (open when we read it on Nov 22, 2026) reports that putting the experts of layers 6-17, the layers the model runs three times, on the CPU can turn the output into "GGGG" until you restart. Both `--cpu-moe` and `--n-cpu-moe` hit this, because `--n-cpu-moe N` offloads the first N layers. It was reproduced on CUDA and Vulkan builds b12600 to b12613. Experts of layers 18-23 on the CPU are fine, so the workaround is `-ot "blk\.(1[89]|2[0-3])\.ffn_.*_exps.*=CPU"` instead of either flag; `--no-op-offload` or `-ub 16` also avoid it, but run slower. Which file fits which card is in our [Inkling 2 Mini local guide](https://aliteq.com/can-you-run-inkling-2-mini-locally). 

> **Updated November 1, 2026**
>
> **14 November:** llama.cpp's README now lists `--moe-cache-cpu-share F` (default 0.00), the share of MoE-cache misses the CPU computes from RAM instead of uploading to the GPU, and `--moe-cache-mib` is now split across GPUs like the layers. We added the copyable command at the top and a RAM + VRAM table for 120B-class MoE models. We first wrote this explainer in early October around Qwen3 30B-A3B and gpt-oss. On 1 November we re-read llama.cpp's flag reference, added Qwen3.8 Flash Next as the new headline example, the flags that matter for it (`--lazy-mode`, `--load-mode`, `--moe-cache-mib`), the RAM-bandwidth limit, the October quality warnings from Reddit, and a short section on other offload engines. The 5× measurement and the V-shaped curve below are unchanged: the mechanism has not moved.

There's a result that circulates in local-LLM threads and sounds like nonsense: someone moves *more* of their model off the GPU and onto the CPU, and it gets nearly five times faster. Not five percent. Five times. Every instinct says that's backwards: system RAM is slower than VRAM, so shifting work to it should hurt.

The measurement is real. It traces to a merged llama.cpp pull request with the full `llama-bench` output attached. But the explanation people give for it is usually wrong, and acting on the folklore version makes a setup slower, not faster. In October the same confusion moved to a much bigger model, Qwen3.8 Flash Next, which people now run on 8GB and 12GB cards by pushing most of it into RAM and onto the SSD.

`--n-cpu-moe N` (short `-ncmoe`) tells llama.cpp to keep the MoE expert weights of the first N layers in system RAM, so a model bigger than your VRAM can still load. Adding that offload normally makes an MoE model **slower**, not faster, because RAM bandwidth then sets the speed. The famous 5× speedup only happens when the model didn't fit in VRAM in the first place. Qwen3.8 Flash Next (125B total, 6B active) is the model that made this flag mainstream in October 2026.

- Performance against offload depth is a **V shape**: catastrophic while overcommitted, best at the smallest value that genuinely fits, then a slow decline as you push further.
- The flag moves **routed expert weights only**. Attention, KV cache, the router, shared experts and norms all stay put. It changes where weights live, not which experts the model uses.
- Recent llama.cpp auto-sizes offload by default (`--fit on`), so try no MoE flag first.
- For Flash Next, the 28.8 GB n-gram table can stay on disk with `--lazy-mode on`, per llama.cpp's docs and the ISTA-DASLab quant card.
- Speed tricks in some newer engines that bias or skip experts **change the outputs**. `--n-cpu-moe` does not.

## What the flag actually does

`--n-cpu-moe N` does one specific, narrow thing. For layers 0 through N-1, it overrides the buffer type for tensors matching this pattern:

```regex
\.ffn_(up|down|gate|gate_up)_(ch|)exps
```

![The llama.cpp server README row for --n-cpu-moe](https://media.aliteq.com/media/local-ai/llamacpp-n-cpu-moe-flag-2026-11-01.jpg)
llama.cpp's own documentation for the flag, captured Nov 1, 2026.

Those are the **routed expert weights**: the big stacks of per-expert feed-forward matrices that make an MoE model large. Nothing else moves. Attention weights stay where `-ngl` put them. So does the KV cache, the router that picks which experts to use (`ffn_gate_inp`), any shared experts (`_shexp`), the layer norms and the embeddings.

> **Why this particular split is clever**
>
> In a mixture-of-experts model the routed experts are most of the weight but only a fraction of the work per token: the router picks a handful and ignores the rest. Attention is the opposite: small, but touched by every single token. So this flag moves the bulky, rarely-touched part to slow memory and keeps the small, hot part on the fast device. That's a good trade, and it's why the flag exists.

You can see the shape of it in our [model catalogue](https://aliteq.com/cost-to-run). On Qwen3-30B-A3B, the routed experts account for roughly 95% of the parameters, while only about 3.3B are active for any given token. Qwen3.8 Flash Next takes this to an extreme: its [model card](https://huggingface.co/Qwen/Qwen3.8-Flash-Next) lists 125B parameters with 6B activated, and 512 experts per layer with 10 routed plus 1 shared active. Each token touches 10 of 512 routed experts, about 2%.

> **Last verified: November 1, 2026**
>
> Flag names and help text below were read in llama.cpp's server README on the master branch on November 1, 2026 (newest build tag b12032; newest versioned release v0.8.0, October 28, 2026). The `--fit` internals were read in common/fit.cpp on October 4, 2026. Older builds may lack `--fit`, `--n-cpu-ffn`, `--lazy-mode` or `--moe-cache-mib`.

## --cpu-moe vs --n-cpu-moe vs -ot

All three flags do the same kind of thing: they tell llama.cpp to keep certain weight tensors in system RAM. They differ only in how much you control. `--cpu-moe` moves every MoE expert weight. `--n-cpu-moe N` moves them for the first N layers only. `-ot` lets you write the pattern yourself.

### The MoE offload flags in llama.cpp (help text read Nov 1, 2026)

|   | Official help text | What it does | Environment variable |
| --- | --- | --- | --- |
| --cpu-moe (short: -cmoe) | keep all Mixture of Experts (MoE) weights in the CPU | Every layer's routed experts | LLAMA_ARG_CPU_MOE |
| --n-cpu-moe N (short: -ncmoe) | keep the Mixture of Experts (MoE) weights of the first N layers in the CPU | Layers 0 to N-1 only | LLAMA_ARG_N_CPU_MOE |
| -ot / --override-tensor | override tensor buffer type | Any tensor whose name matches your regex | LLAMA_ARG_OVERRIDE_TENSOR |
| --moe-cache-mib N | GPU cache size in MiB for the MoE experts kept in the CPU (default 0, disabled) | Nothing moves; a VRAM cache for RAM-resident experts | LLAMA_ARG_MOE_CACHE_MIB |

Under the hood, the first two are shortcuts for the third. `--cpu-moe` adds one override with the pattern shown above. `--n-cpu-moe 3` adds three overrides, one per layer, of the form `blk\.0\.ffn_(up|down|gate|gate_up)_(ch|)exps`, then `blk\.1…` and `blk\.2…`. So these two commands do the same thing:

```bash
llama-server -m model.gguf --n-cpu-moe 3
llama-server -m model.gguf -ot "blk\.(0|1|2)\.ffn_(up|down|gate|gate_up)_(ch|)exps=CPU"
```

Which one should you use? Use `--n-cpu-moe` almost always. It has one knob, and that knob maps straight onto the V-shaped curve below. Use `--cpu-moe` when the model is far too big for your card and you want the simplest possible start; that is the same as setting `--n-cpu-moe` to the layer count. Reach for `-ot` only when you need a pattern the shortcuts can't express, like pinning specific layers to a second GPU. The text after the `=` must be a buffer type your build knows. If it isn't, llama.cpp prints the list of available buffer types and stops.

The README now also lists `--moe-cache-mib N`, which reserves a slice of VRAM as a cache "for the MoE experts kept in the CPU". It is off by default, and with several GPUs it is split among them like the layers. Since mid-November a companion flag, `--moe-cache-cpu-share F` (0 to 1, default 0.00), sets what share of cache misses the CPU computes from the RAM copy instead of uploading the expert to the GPU once the cache is full. It is llama.cpp's own answer to "keep the hot experts on the GPU": the experts still live in RAM, and the cache holds some of them in VRAM. llama.cpp's docs do not say how it picks what to cache, so treat it as something to measure, not a default. Unlike the expert-biasing tricks covered further down, a cache only changes where a weight is read from, not which experts the model uses.

Two more flags matter once experts are in RAM. The KV cache can be stored at lower precision with `-ctk` / `-ctv` (the README lists types including q8_0, q5_0, q5_1, q4_0 and iq4_nl), which frees VRAM for more expert layers; a smaller cache type is a quality trade, so q8_0 is the cautious start. `-fa, --flash-attn [on|off|auto]` defaults to auto.

If you searched for the phrase "number of layers for which to force MoE weights onto CPU", that is this same N. It counts layers from the start of the model, not experts. N = 0 moves nothing. N equal to the model's layer count is the same as `--cpu-moe`. That phrase is LM Studio's label for its slider; [our LM Studio MoE offload guide](https://aliteq.com/lm-studio-moe-offload-expert-weights-cpu) covers the app side, and [our Ollama MoE guide](https://aliteq.com/ollama-moe-offload-cpu) explains why Ollama has no such setting.

## Normally, more offload is slower

This is the part the folklore skips. When the model already fits on your GPU, increasing `--n-cpu-moe` degrades throughput steadily and predictably. A llama.cpp contributor published a clean sweep of it while working on [CUDA graph support for this path](https://github.com/ggml-org/llama.cpp/pull/18934):

### Token generation as offload increases (tg128), model fits comfortably

|   | ncmoe 8 | ncmoe 16 | ncmoe 32 | ncmoe 64 |
| --- | --- | --- | --- | --- |
| GLM-4.5-Air 106B IQ4_XS | 60.84 t/s | 48.25 t/s | 32.84 t/s | 25.08 t/s |
| gpt-oss 120B MXFP4 | 95.96 t/s | 70.42 t/s | 44.80 t/s | 40.87 t/s |

Monotonic decline, both models. Every layer you push to the CPU is a layer whose expert weights are now read from [system RAM](https://aliteq.com/how-much-ram-do-you-need-for-local-ai) instead of out of VRAM. That's the behaviour physics predicts, and it's what you should expect by default.

> If more offload is making you faster, something is already wrong. The speedup is a symptom, not a feature.

## So where does the 5× come from?

From a different situation entirely: one where the baseline was broken. The measurement comes from [the pull request that added `--n-cpu-moe` to llama-bench](https://github.com/ggml-org/llama.cpp/pull/15952), where contributor jacekpoplawski ran a 13.70 GiB model on a [12 GB card](https://aliteq.com/best-local-llm-12gb-vram):

### Qwen3-30B-A3B-Instruct-2507 Q3_K_M (13.70 GiB) on a 12 GB RTX 5070, Windows

|   | Generation (tg128) | Prefill (pp512) |
| --- | --- | --- |
| -ngl 99 alone | 11.09 t/s | 378.46 t/s |
| -ngl 99 --n-cpu-moe 12 | 54.04 t/s | 1,253.62 t/s |
| Change | 4.87× | 3.31× |

Look at the model size against the card. **13.70 GiB does not fit in 12 GB.** That's the entire story.

On Windows, NVIDIA's driver has a feature called System Memory Fallback. When a CUDA allocation won't fit in VRAM, rather than failing it silently backs the allocation with host RAM and pages it over PCIe on demand. Your model "loads". It runs. It runs *terribly*, because the driver is now shuttling weights across the bus with no idea which ones matter.

The 11 t/s baseline isn't GPU inference. It's a driver frantically paging. When you then set `--n-cpu-moe 12`, you're not adding a penalty: you're **taking control of a decision the driver was already making badly**. You tell it exactly which tensors live in host memory, everything else fits properly in VRAM, and the thrashing stops. Hence 54 t/s.

> **This is why the advice gets mangled**
>
> "I increased --n-cpu-moe and got 5× faster" is true and reproducible, and it still doesn't mean what it sounds like. The person wasn't discovering that CPU offload is fast. They were escaping a failure mode. Anyone whose model already fits, following that advice, just makes their setup slower, exactly as the sweep above shows.

**Your model is bigger than your VRAM?** Or skip the offloading: rent a card that holds the whole model. That 13.70 GiB Qwen3-30B-A3B file fits a 24GB RTX 3090 with room for context, so there's no N to tune at all. Vast.ai is a marketplace, so it's the cheapest by the hour; pick a verified host and compare it with your own setup. [Yes, rent a 24GB card for an hour](https://cloud.vast.ai/?ref_id=623346) (Referral link: we earn a commission if you buy.) Live RTX 3090 prices on Vast.ai, from and typical: https://aliteq.com/vast-ai-pricing

## The actual shape: a V, not a slope

Put both findings together and the real curve has three regions.

1. **Too little offload**: the model overcommits VRAM. On Windows you get driver paging and catastrophic throughput. This is the left arm of the V.
2. **The knee**: the smallest N where everything genuinely fits in VRAM. This is the fastest configuration, and it's what you're looking for.
3. **Too much offload**: every extra layer sends more expert weight through slow RAM for no benefit. Slow, steady decline. The right arm.

Which reframes the tuning problem completely. You're not looking for "how much can I offload"; you're looking for **the least you can get away with**. Start at zero, increase until it fits without overcommitting, stop. Every step past that costs you.

## Your RAM, not the flag, sets the speed

Once expert weights live in host memory, their read speed is your memory bandwidth. That is the part people underestimate. When a user on r/ollama asked why a 27B model on a 24GB card with 64GB of RAM was ["so much slower than I imagined"](https://www.reddit.com/r/ollama/comments/1xfxbss/), the top advice was to keep the model fully in VRAM, because system RAM is 10 to 20 times slower. In [a 1 November r/LocalLLaMA thread](https://www.reddit.com/r/LocalLLaMA/comments/1xl0oqz/) where offloaded experts on two Radeon AI PRO R9700 cards hung on long tasks, a reply made the same point: once you offload, system-RAM bandwidth and the CPU become the bottleneck.

A rough way to see the ceiling, our arithmetic: each new token reads the chosen experts from wherever they live. For Qwen3.8 Flash Next at IQ2_XS, Strata's model notes put the expert weights at 35.5 GB, and the router picks 10 of 512 per layer, so a token reads about 10 / 512 × 35.5 ≈ 0.7 GB of expert data if every expert sat in RAM. Dual-channel DDR4-3200 moves about 51 GB/s in theory (3,200 MT/s × 8 bytes × 2 channels), which caps that case near 70 tokens per second before attention, the CPU's own compute or anything else costs a millisecond. Real numbers land well below such ceilings. Every expert layer you keep on the GPU lowers the RAM read, which is why the knee of the V matters.

Two more consequences:

- **Dual-channel desktop DDR5 is a different machine from quad-channel or server memory.** The same `--n-cpu-moe` value behaves very differently across them. Any specific speed someone quotes you is a number from their motherboard, not yours.
- **Prompt processing suffers differently from generation.** A critic in [the r/LocalLLaMA thread about Flash Next on an 8GB card](https://www.reddit.com/r/LocalLLaMA/comments/1xebdzl/) noted that around 70 tokens per second of prompt processing means minutes before the first token in an agent harness that sends long prompts. If you use coding agents, measure prefill, not only generation.

## Qwen3.8 Flash Next: the new headline example

Qwen3.8 Flash Next is why this flag is everywhere again. Per its model card and config.json (read November 1, 2026), it has 48 layers, 512 experts per layer (10 routed plus 1 shared active), hybrid attention with full attention on every fourth layer, a native context of 262,144 tokens, and something new: a 51B-parameter **n-gram embedding** that the card says is "more amenable to offloading than Mixture-of-Experts (MoE)". Its licence is qwen-community-1.0, a custom licence rather than Apache.

That gives you two piles to move off the card, not one:

1. **The experts go to RAM.** Same as any MoE model: `--n-cpu-moe N`, `--cpu-moe`, or let `--fit` place them.
2. **The n-gram table can stay on disk.** In the ISTA-DASLab GGUF repo it is a separate 28.8 GB second shard, read one row per token. llama.cpp's `--lazy-mode on` reads such tensors "from disk on demand instead of keeping them resident (requires mmap)".
3. **Attention, the shared expert and the KV cache stay on the GPU.** Only 12 of the 48 layers keep a full KV cache, so long context is cheap for a model this size.

The ISTA-DASLab card's own example command uses `-lm mmap --lazy-mode on -ngl 99` and says this "removes 28.8 GB from the resident footprint". Both flags are in llama.cpp's README: `-lm, --load-mode` (values auto, none, mmap, mlock, mmap+mlock, dio; default auto) and `-lzm, --lazy-mode` (on, auto, off; auto turns it on only for tensors larger than 4 GiB). A minimal start on a current build, letting `--fit` place the experts:

```bash
# Qwen3.8 Flash Next, ISTA-DASLab IQ2_XS: --fit places experts, n-gram table read from disk
llama-server -m IQ2_XS/Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS-00001-of-00002.gguf \
  -c 32768 -lm mmap --lazy-mode on
```

Give llama.cpp the first shard; per the ISTA card it loads the split automatically, and both shards must be downloaded. If you would rather set the expert count yourself, add `--n-cpu-moe N` and the fit step steps aside. Per-card starting values and the RAM each quant needs are in [our list of the best MoE models for a 12GB or 16GB GPU](https://aliteq.com/best-moe-models-for-12gb-16gb-gpu), and the full walkthrough is in [how to run Qwen3.8 Flash Next locally](https://aliteq.com/run-qwen3-8-flash-next-locally). The [cost-to-run page for Flash Next](https://aliteq.com/cost-to-run/qwen3.8-flash-next) shows the memory per quant.

What people report on small cards (their numbers, not ours):

- **8GB VRAM, 32GB RAM, Q2, Strata:** up to 900 tokens/s prompt processing and 30 tokens/s generation, per [the most-upvoted October post](https://www.reddit.com/r/LocalLLaMA/comments/1xft2ae/) (910 votes). Strata splits the model across VRAM, RAM and SSD. The poster found it better than any Qwen 3.6 35B-A3B fine-tune or Qwen 3.8 27B they tried.
- **[RTX 3060 12GB](https://aliteq.com/gpus/rtx-3060-12gb), 16GB DDR4, IQ2_XS (the 68 GB GSQ-RCO build), Betelgeuse engine:** 22 tokens/s sustained, "without dropping a single expert", per [its author](https://www.reddit.com/r/LocalLLaMA/comments/1xk8s6z/).
- **8GB GPU, 24GB RAM, about 3.5 bits per weight (Flash-Next Coder), llama.cpp, 262K context:** most experts in RAM and the n-gram table on disk, per [this thread](https://www.reddit.com/r/LocalLLaMA/comments/1xebdzl/).

Two tips from that last thread are worth knowing, and both are the thread's claims, not documented behaviour. A commenter reported about 50% faster prompt processing with `--load-mode none` instead of mmap. `none` is a documented value ("no special loading mode"), but the README also says lazy mode "requires mmap", so that trade presumably keeps the 28.8 GB n-gram table in RAM: only worth it if you have the RAM to spare. The author also said CUDA struggled at 8GB and suggested trying a Vulkan build if loading fails. llama.cpp's server README does not cover that case, so treat it as one user's workaround.

## Run gpt-oss-120b or Qwen3.8 Flash Next on 32 GB RAM + a 12 GB GPU

`--n-cpu-moe` moves weights to RAM; it does not shrink them. So the first question is whether your **system RAM plus VRAM** holds the whole model with room for the operating system. The memory figures below come from our [VRAM calculator](https://aliteq.com/tools/vram-calculator) engine (weights + KV cache at the default context, read Nov 14, 2026); the "works on" column is our arithmetic: RAM + VRAM at least the total plus about 6 GB for Windows or a desktop Linux.

|   | Memory needed | Works on (RAM + VRAM) | 32 GB RAM + 12 GB GPU? |
| --- | --- | --- | --- |
| Qwen3-Coder 30B-A3B (Q4_K_M) | 19.5 GB | 16 GB + 8 GB card | Yes, with room for long context |
| GLM-4.5-Air 106B (Q3_K_M) | 51.9 GB | 48 GB + 12 GB card | No, short by ~14 GB |
| gpt-oss-120b (MXFP4, official) | 62.7 GB | 64 GB + 8-12 GB card | No, short by ~25 GB |
| Qwen3.8 Flash Next (IQ2_XS) | 35.5 GB experts in RAM, 28.8 GB n-gram table on disk | 48 GB + 8-12 GB card (Strata's rule: RAM at least experts + ~10 GB) | Only with SSD streaming (slow), per the reports above |

So "I ran a 120B MoE on my 32 GB" is true in two cases: a **32 GB GPU** ([RTX 5090](https://aliteq.com/gpus/rtx-5090)) with 32 GB or more of RAM beside it, or a setup that leaves part of the model memory-mapped on the SSD, which works but runs far slower. For gpt-oss-120b specifically, [gpt-oss-120b hardware requirements](https://aliteq.com/gpt-oss-120b-hardware-requirements) lists the GPUs and Macs that hold it whole, and [the best GPU for gpt-oss-120b](https://aliteq.com/cost-to-run/gpt-oss-120b#best-gpu) ranks them with live rental prices. If you only need it now and then, [renting vs buying a GPU](https://aliteq.com/rent-vs-buy-gpu-ai-cloud-vs-local) works out where an hourly card beats a RAM upgrade.

**The 64 GB step from the table: G.Skill Flare X5 DDR5 64GB (2x32GB) 6000 CL30** A 64GB (2x32GB) DDR5-6000 CL30 kit with an AMD EXPO profile, per G.Skill. By the table above, 64 GB of RAM beside an 8 to 12 GB card holds gpt-oss-120b whole, with no SSD streaming. Best for: A DDR5 desktop that runs big MoE models with --n-cpu-moe and is short on system RAM.. [Check price on Amazon](https://www.amazon.com/dp/B0CGQ3KS8X?tag=aliteqofficia-20) (Referral link: we earn a commission if you buy.)

**Too slow on RAM? Run the whole 120B model on one GPU** When most experts sit in desktop RAM, generation speed is capped by memory bandwidth. gpt-oss-120b needs about 62.7 GB, so an 80GB A100 holds every weight on the GPU with no N to tune. Runpod runs it in its own Secure Cloud datacenters with one-click templates; stop the pod when you're done. [Rent an 80GB A100 by the hour](https://console.runpod.io/signup?ref=nuninlts) (Referral link: we earn a commission if you buy.) Live A100 SXM prices on Runpod, from and typical: https://aliteq.com/runpod-pricing

## What if the model doesn't fit in RAM either?

**Then --n-cpu-moe can't help, and SSD streaming is the next step.** Moving experts to RAM only works while VRAM plus RAM hold the whole file. [Magnitude](https://aliteq.com/magnitude-run-big-moe-models-from-ssd), a free engine relaunched on November 24, 2026, adds a third tier: the least-used experts stay on your NVMe SSD and get prefetched before they're needed. Its authors ran DeepSeek V4.1 Flash's 249 GB 2-bit file at 10 to 17 tokens a second on an RTX 5090 with 64 to 128 GB of RAM. It only works for mixture-of-experts models, and one early user measured it slower than llama.cpp on an RTX 5080, so if your model already fits in VRAM plus RAM, the flag on this page is still the thing to tune.

## Three reasons this may not apply to you

**You're probably on a build that fixes this automatically.** llama.cpp's `--fit` is on by default (`-fit, --fit [on|off]`, "default: 'on'" in the README). It auto-sizes offload to what will actually fit, which largely prevents anyone from landing in the overcommit regime in the first place. This advice increasingly matters for older builds, manually forced configurations, and non-CUDA backends. The next section shows how `--fit` and `--n-cpu-moe` interact.

**On Linux you'd probably have seen an error instead.** Stock CUDA on Linux doesn't do the silent host-memory fallback unless you opt in with `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1`. Without it, an overcommitted model usually just fails to allocate and tells you so. A loud failure beats a quiet 5× slowdown.

**Your model may simply fit.** A dense model or a small MoE that fits whole on the card gains nothing from this flag; [Qwen3-Coder](https://aliteq.com/can-you-run-qwen3-coder-locally) 30B-A3B at Q4, for example, sits whole on [a 24GB card](https://aliteq.com/best-local-llm-24gb-gpu-qwen-gemma-gptoss). For 16GB cards, r/LocalLLaMA's [October ranking thread](https://www.reddit.com/r/LocalLLaMA/comments/1x3gpyi/) put the dense Qwen3.8 27B first; see [our 16GB guide](https://aliteq.com/best-local-llm-16gb-vram) for what fits without offload.

## How to pick N on a current llama.cpp build

On a current build, try no MoE flag at all first. The default `--fit on` already does a version of `--n-cpu-moe` for you. If you then add `--n-cpu-moe` yourself, `--fit` stops placing weights and your N is final. So a manual value only helps when it beats the automatic one.

Here is what the fit code does, read in `common/fit.cpp` on October 4, 2026. It only adjusts settings you did not set yourself. It aims to leave a safety margin of 1,024 MiB free on each GPU (change it with `--fit-target`). It may shrink the context first, but never below 4,096 tokens (change it with `--fit-ctx`); both defaults match the README on 1 November. For a MoE model it then fills the GPU with the small, hot tensors first, with all expert weights in RAM. After that it moves expert weights back onto the GPU while they still fit. That is the knee of the V, found for you.

The catch is in the same file. If you set `-ngl`, `--n-cpu-moe`, `--cpu-moe` or `-ot` yourself, the fit step logs "failed to fit params to free device memory" and leaves weight placement to you. It can still have trimmed the context before that point. So you have two sane workflows:

1. **Let --fit do it.** Run with no offload flags, read the log, and check speed with llama-bench. This is the right default for most people.
2. **Tune by hand.** Start at `--n-cpu-moe 0` and raise it one step at a time until the model loads with headroom, then stop. llama-bench accepts `--n-cpu-moe` too, so you can sweep several values in one run (PR #15952).
3. **Never** keep raising N once it fits. That is the slow right arm of the V.

A dense model has no expert tensors, so `--n-cpu-moe` does nothing for it. Since August 27, 2026 (PR #26622) llama.cpp has a sibling for that case: `--n-cpu-ffn N` (short `-ncffn`), which the README describes as keeping "the dense FFN weights of the first N layers in the CPU". The [gpt-oss-20b on an 8GB or 12GB card walkthrough](https://aliteq.com/gpt-oss-20b-8gb-12gb-gpu-moe-offload) shows the MoE version on a real model.

## Quality: what the speed tricks cost

`--n-cpu-moe`, `--cpu-moe` and `-ot` only change *where* weights are stored. The router still picks the same experts, so the model computes the same thing, only slower or faster. October's arguments were about two other things that do change answers.

**Low quants.** The Flash Next packs that fit desktop RAM are 2-bit and 3-bit, and that is contested. In [one r/LocalLLM thread](https://www.reddit.com/r/LocalLLM/comments/1xkjlwc/) the poster called everything up to IQ3 terrible, and a reply said "No model is great below Q4". In [another](https://www.reddit.com/r/LocalLLM/comments/1x4rer4/), replies reported a Q3_S Flash Next beating Qwen3.8 27B at FP8. The quantizer's own card reports IQ2_XS and IQ3_XXS scoring close to the BF16 model on AIME25, GPQA-Diamond and LiveCodeBench v6; those are the vendor's benchmarks, not independent ones. Test on your own tasks before you trust a 2-bit build.

**Engines that swap or skip experts.** Some newer engines add speed options that route tokens toward experts already on the GPU, or skip lower-ranked experts that are not. An engine developer [measured two such flags](https://www.reddit.com/r/LocalLLaMA/comments/1xkbbqi/) and found both change outputs; a commenter's takeaway was "q8 to q3 is less of a hit than enabling bias & tail skip". llama.cpp's README lists no flag of that kind (read November 1, 2026). If an engine offers one, it should be opt-in, and you should compare answers with it off.

**Sampling defaults.** In [a thread asking why Flash Next disappointed](https://www.reddit.com/r/LocalLLaMA/comments/1x7uf15/) (UD-Q4_K_XL on four [RTX 3090s](https://aliteq.com/gpus/rtx-3090), losing to Qwen3.8 27B at Q8 on a coding task), the top reply said Strata "defaults to greedy decoding instead of Qwen's recommended sampling parameters". Strata's current documentation (DETAILS.md) says requests that leave sampling out get the model card's values and that greedy decoding happens only when you ask for temperature 0, so that complaint likely describes an older version; set sampling explicitly either way. Qwen's card recommends temperature 1.0, top_p 0.95, top_k 20 for thinking mode, and temperature 0.7, top_p 0.80, top_k 20 with presence_penalty 1.5 for instruct mode.

## Other offload engines (community projects)

llama.cpp is the stable option. October also brought engines built around Flash Next. All of these are young; pin a version and keep llama.cpp as your fallback.

- **Strata** ([GitHub](https://github.com/Niko1221/Strata)): describes itself as "Qwen3.8-Flash-Next on any consumer hardware", MIT-licensed, version 0.2.9 on its release files (1 November). Its model notes say Flash Next fits when "RAM is at least the experts plus about 10 GB", that reading experts from the SSD when RAM is short "works and is much slower", and that a bigger graphics card "does not lower the RAM needed". Reddit users have reported [quality changes between versions](https://www.reddit.com/r/LocalLLaMA/comments/1x5cdht/) and breaking changes.
- **Lean-QwenFlash**: streams experts from an NVMe SSD. Its author [reported about 20 tokens/s](https://www.reddit.com/r/LocalLLaMA/comments/1xev6bo/) for a 16GB VRAM plus 8GB RAM setup, with the published numbers measured on an [RTX 4090](https://aliteq.com/gpus/rtx-4090); a top commenter called its KL-divergence quality check "a joke" because the test corpus was tiny.
- **Betelgeuse**: the 12GB RTX 3060 result above, from [its author](https://www.reddit.com/r/LocalLLaMA/comments/1xk8s6z/), who said an earlier version that pruned experts was scrapped because it hurt quality.
- **ik_llama.cpp** ([GitHub](https://github.com/ikawrakow/ik_llama.cpp)): a "llama.cpp fork with additional SOTA quants and improved performance". Its README lists Qwen-3.8-Flash-Next support and DFlash 2, and supports `--cpu-moe` and `--n-cpu-moe`; it warns not to use `-rtr` for hybrid CPU/GPU inference with experts left on the CPU.

One mainline addition also helps offloaded setups: llama.cpp **v0.8.0** (October 28, 2026) lists "probabilistic DFlash2 drafts" for speculative decoding (`--spec-type` includes `draft-dflash`). A small drafter proposes tokens and the main model checks them. [One r/LocalLLaMA user](https://www.reddit.com/r/LocalLLaMA/comments/1xjlgm4/) reported about 17% faster generation on average on an M5 Max (18% on code, 3% slower on prose).

![The image that ran at the top of an earlier version of this guide](https://media.aliteq.com/media/2026/07/nvidia-dgx-spark.jpg)
The image that ran with an earlier version of this guide.

Qwen3-Next 80B-A3B is a good candidate for this trick; what it takes to hold it is in [Qwen3-Next 80B-A3B locally](https://aliteq.com/run-qwen3-next-80b-a3b-locally).

This guide is part of our [How much VRAM do you need to run an AI model](https://aliteq.com/how-much-vram-do-you-need-to-run-ai-models) guide. Related guides: [Out of memory at long context](https://aliteq.com/kv-cache-quantization-explained), [How to quantize a local LLM to GGUF and what you lose at Q4, Q6 or Q8](https://aliteq.com/how-to-quantize-local-llm-gguf), [Qwen3.8 27B NVFP4, how much VRAM it needs and which GPU runs it](https://aliteq.com/qwen3-8-27b-nvfp4).

The same idea, experts in system RAM and the busy parts on the GPU, is how Strata runs [Tencent's 220B Hy4 Flash on 64 GB of RAM plus an 8 GB GPU](https://aliteq.com/can-you-run-hy4-flash-locally).

## Quick answers

**Q: What is the llama.cpp --n-cpu-moe command?**

A: llama-server -m model.gguf -ngl 99 --n-cpu-moe 30 keeps the expert weights of the first 30 layers in system RAM and everything else on the GPU. Raise the number if loading runs out of VRAM, lower it if VRAM is left over; lower is faster.

**Q: Can I run a 120B MoE model on 32 GB of RAM?**

A: Not whole on a 12 GB card. gpt-oss-120b needs about 62.7 GB of RAM plus VRAM at its official MXFP4 release, so plan on 64 GB of RAM with an 8 to 12 GB GPU, or a 32 GB GPU with at least 32 GB of RAM. Less than that only works with part of the model memory-mapped from the SSD, which is much slower.

**Q: What value of --n-cpu-moe should I use?**

A: The smallest one where the model fits in VRAM without overcommitting. Start at 0 and increase until it loads cleanly, then stop, because every further step costs throughput. On a current build, first try no flag at all and let --fit choose.

**Q: What is the difference between --cpu-moe and --n-cpu-moe?**

A: --cpu-moe (short -cmoe) keeps every layer's MoE expert weights in system RAM. --n-cpu-moe N (short -ncmoe) does the same for the first N layers only. Setting N to the model's layer count gives the same result as --cpu-moe. Both are shortcuts for an -ot (--override-tensor) rule.

**Q: What does ncmoe mean in llama.cpp?**

A: -ncmoe is the short form of --n-cpu-moe, the number of layers whose MoE expert weights stay in CPU memory. Its environment variable is LLAMA_ARG_N_CPU_MOE. llama-bench accepts the same flag with a comma-separated list, so you can compare several values in one run.

**Q: How do I run Qwen3.8 Flash Next on a small GPU with llama.cpp?**

A: Use a 2-bit or 3-bit GGUF, keep the experts in RAM (let --fit place them, or set --n-cpu-moe), and keep the 28.8 GB n-gram table on disk with -lm mmap --lazy-mode on, as the ISTA-DASLab card shows. You need enough system RAM for the expert weights; our 12GB and 16GB MoE guide gives the numbers.

**Q: Does --n-cpu-moe change the model's answers?**

A: No. It only changes where the expert weights are stored, not which experts the router picks. Flags in some other engines that bias routing toward GPU-resident experts or skip lower-ranked experts do change outputs.

**Q: Does --n-cpu-moe help dense (non-MoE) models?**

A: No. It targets routed expert tensors, and a dense model doesn't have any. For dense models use -ngl, or --n-cpu-ffn N (short -ncffn, added August 27, 2026), which keeps the dense FFN weights of the first N layers in RAM.

**Q: Why did my throughput get worse after following this advice?**

A: Almost certainly because your model already fitted. You've moved expert weights from VRAM to system RAM for no reason, and RAM bandwidth now limits every token. Reduce the value, or remove the flag and let a recent llama.cpp size it for you.

**Q: Does the KV cache move to the CPU too?**

A: No. The flag only overrides tensors matching the routed-expert pattern. The KV cache stays where it was, which matters at long context, because a large KV cache can push you back into overcommit even when the weights fit.

If you want to know whether your model fits before you start guessing at flags, the [interactive VRAM calculator](https://aliteq.com/tools/vram-calculator) and our [cost-to-run pages](https://aliteq.com/cost-to-run) compute the weight and KV-cache requirement per quantisation from each model's own configuration, so you can see which term is pushing you over the edge. If it still doesn't fit, [live cloud GPU prices](https://aliteq.com/cloud-gpu) show what a bigger card costs by the hour, and [Runpod vs Vast vs Lambda](https://aliteq.com/runpod-vs-vast-vs-lambda-cheapest-gpu-cloud) compares where to rent it.

## Related guides

- [Best MoE models for a 12GB or 16GB GPU](https://aliteq.com/best-moe-models-for-12gb-16gb-gpu): which models are worth offloading, a starting N per card and the RAM each needs.
- [How to run Qwen3.8 Flash Next locally](https://aliteq.com/run-qwen3-8-flash-next-locally): the full setup for the model this page uses as its example.
- [LM Studio's MoE offload setting](https://aliteq.com/lm-studio-moe-offload-expert-weights-cpu): the same flag as a slider in a desktop app.
- [Ollama and MoE offload](https://aliteq.com/ollama-moe-offload-cpu): what Ollama does with experts without a setting.
- [gpt-oss-20b on an 8GB or 12GB card](https://aliteq.com/gpt-oss-20b-8gb-12gb-gpu-moe-offload): the flag applied to one popular model.
- [gpt-oss-120b hardware requirements](https://aliteq.com/gpt-oss-120b-hardware-requirements): the RAM, VRAM and Macs that hold the 120B model.
- [Best local LLM for 16GB VRAM](https://aliteq.com/best-local-llm-16gb-vram): what fits on a 16GB card without any offload.
- [Interactive VRAM calculator](https://aliteq.com/tools/vram-calculator): drag the context slider and watch the KV cache fill the card.
- [RTX 5090 vs two RTX 3090s](https://aliteq.com/multi-gpu-local-ai): one fast card or two big ones.
- [Is the DGX Spark worth it?](https://aliteq.com/dgx-spark-worth-it-local-llm): whether a big unified-memory box is right for you.

## Sources

- [llama.cpp tools/server/README.md, flag reference (primary docs, master, read Nov 14, 2026)](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md)
- [Hugging Face (OpenAI), gpt-oss-120b model card and file list (MXFP4 release, 65.2 GB); ggml-org/gpt-oss-120b-GGUF file list (gpt-oss-120b-MXFP4.gguf), read Nov 14, 2026](https://huggingface.co/openai/gpt-oss-120b)
- [llama.cpp common/arg.cpp, flag definitions (source code, read Oct 4, 2026)](https://github.com/ggml-org/llama.cpp/blob/master/common/arg.cpp)
- [llama.cpp common/fit.cpp, the --fit logic (source code, read Oct 4, 2026)](https://github.com/ggml-org/llama.cpp/blob/master/common/fit.cpp)
- [llama.cpp release v0.8.0, Oct 28, 2026 (release notes, read Nov 1, 2026)](https://github.com/ggml-org/llama.cpp/releases/tag/v0.8.0)
- [llama.cpp PR #26622, add --n-cpu-ffn option (merged Aug 27, 2026, read Oct 4, 2026)](https://github.com/ggml-org/llama.cpp/pull/26622)
- [llama.cpp PR #15952, llama-bench: add --n-cpu-moe support (jacekpoplawski)](https://github.com/ggml-org/llama.cpp/pull/15952)
- [llama.cpp PR #18934, ggml-cuda: enable cuda-graphs for n-cpu-moe (am17an)](https://github.com/ggml-org/llama.cpp/pull/18934)
- [Hugging Face (Qwen), Qwen3.8-Flash-Next model card and config.json (read Nov 1, 2026)](https://huggingface.co/Qwen/Qwen3.8-Flash-Next)
- [Hugging Face (ISTA-DASLab), Qwen3.8-Flash-Next GSQ-RCO GGUF model card (third-party quants, read Nov 1, 2026)](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF)
- [Strata, GitHub README and docs/MODELS.md (community project, read Nov 1, 2026)](https://github.com/Niko1221/Strata)
- [ik_llama.cpp, GitHub README (community fork, read Nov 1, 2026)](https://github.com/ikawrakow/ik_llama.cpp)
- [LM Studio 0.3.23 release notes (vendor blog, read Oct 4, 2026)](https://lmstudio.ai/blog/lmstudio-v0.3.23)
- [llama.cpp issue #32710, Inkling 2 Mini output turns to GGGG when experts of looped layers 6-17 are offloaded to the CPU, CUDA and Vulkan builds b12600-b12613 (open, read Nov 22, 2026)](https://github.com/ggml-org/llama.cpp/issues/32710)

---

Canonical: https://aliteq.com/n-cpu-moe-llama-cpp-what-it-actually-does

This page has referral links. As an Amazon Associate we earn from qualifying purchases.
