MoE VRAM Calculator: Run 30B-120B Models on 8-24GB
95.0% of Qwen3-30B-A3B's parameters sit in expert tensors you can push to system RAM, which is why a 12GB card runs it at -ncmoe 22 and gpt-oss-20b needs only -ncmoe 3. Every general VRAM calculator — including our own — multiplies total parameters by bit width and tells you those cards are hopeless. For Mixture-of-Experts models that is the wrong formula. This one splits the model the way llama.cpp actually loads it.
Offload the experts of the first 22 of 48 layers
11.99 GB in VRAM · 8.08 GB in system RAM · 26 layers fully on GPU
llama-cli -m qwen3-30b-a3b-Q4_K_M.gguf -ngl all -ncmoe 22 -c 8192Bandwidth ceiling, not a benchmark
Per token this configuration reads 1.533 GB over VRAM at 360 GB/s and 0.505 GB over system RAM at 89.6 GB/s. Only 6.25% of each layer's experts are touched, which is the whole reason offloading them is survivable.
These are memory-bandwidth upper bounds. They ignore compute, kernel launch overhead, PCIe transfers and prompt processing, so real llama.cpp throughput lands below them — treat the ratio between the two as the useful signal and measure the absolute number with llama-bench.
Architecture from Qwen/Qwen3-30B-A3B config.json + unsloth/Qwen3-30B-A3B-GGUF. Overhead is a flat 0.7 GB allowance for the CUDA context and llama.cpp compute buffers.
The Formula, and Why It Checks Out
An MoE model has two memory tiers: a small dense core that must sit on the GPU, and a large pile of expert feed-forward tensors that can live anywhere. Everything the calculator does follows from splitting the parameter count between them.
Expert parameters (offloadable):
layers x num_experts x 3 x hidden_size x moe_intermediate_sizeDense residual (pinned to the GPU):
total_parameters - expert_parametersKV cache at fp16:
layers x context x 2 x num_key_value_heads x head_dim x 2 bytesThe x 3 is gate, up and down projections — the three matrices in a SwiGLU expert. Every input comes from the model's own config.json, and the arithmetic is checkable: run it on Qwen3-30B-A3B and you get 28.99B expert parameters against the 30.53B total that the GGUF metadata reports, leaving 1.54B for attention, embeddings and routers. On gpt-oss-20b it gives 19.11B of 20.91B. On gpt-oss-120b, 114.66B of 116.83B. Those residuals are the right size for the attention stacks these models have, which is the sanity check that the split is real rather than curve-fitted.
| Model | Layers | Experts (active) | Expert params | Dense residual | Read per token |
|---|---|---|---|---|---|
| Qwen3-30B-A3B | 48 | 128 (8) | 28.99B of 30.53B | 1.54B (5.0%) | 6.25% of experts |
| gpt-oss-20b | 24 | 32 (4) | 19.11B of 20.91B | 1.80B (8.6%) | 12.5% of experts |
| gpt-oss-120b | 36 | 128 (4) | 114.66B of 116.83B | 2.17B (1.9%) | 3.13% of experts |
Architecture from each model's config.json on Hugging Face; total parameter counts from the GGUF metadata of the corresponding quantised repos, read 18 August 2026. The concept behind the sparsity is covered in Mixture of Experts explained — this page is the hardware half of that story.
Bits Per Parameter, Measured From Real Files
Q4_K_M is not 4 bits per parameter — on Qwen3-30B-A3B it works out to 4.86. K-quants mix precisions per tensor, and MXFP4 releases keep attention in higher precision than the experts. Rather than assume a nominal width, the calculator divides real published file sizes by real parameter counts.
| File | Size | Effective bits/param |
|---|---|---|
| Qwen3-30B-A3B Q3_K_M | 14.71 GB | 3.85 |
| Qwen3-30B-A3B Q4_K_M | 18.56 GB | 4.86 |
| Qwen3-30B-A3B Q8_0 | 32.48 GB | 8.51 |
| gpt-oss-20b MXFP4 | 12.11 GB | 4.63 |
| gpt-oss-120b MXFP4 | 63.39 GB | 4.34 |
Sizes from the Hugging Face file listings for unsloth/Qwen3-30B-A3B-GGUF, ggml-org/gpt-oss-20b-GGUF and ggml-org/gpt-oss-120b-GGUF on 18 August 2026. More on how the formats differ in our quantization format comparison.
The Two Flags That Do the Work
-ncmoe N is the dial and -cmoe is the sledgehammer. Both are documented in the llama.cpp CLI reference, verbatim: -cmoe, --cpu-moe — “keep all Mixture of Experts (MoE) weights in the CPU”; -ncmoe, --n-cpu-moe N — “keep the Mixture of Experts (MoE) weights of the first N layers in the CPU”. They are current, not folklore: both appear in the reference as of release b10472 (17 August 2026).
# Qwen3-30B-A3B Q4_K_M on a 12GB card
llama-cli -m Qwen3-30B-A3B-Q4_K_M.gguf -ngl all -ncmoe 22 -c 8192
# gpt-oss-20b on a 12GB card — barely any offload needed
llama-cli -m gpt-oss-20b-MXFP4.gguf -ngl all -ncmoe 3 -c 8192
# Very little VRAM: push every expert to the CPU
llama-cli -m Qwen3-30B-A3B-Q4_K_M.gguf -ngl all -cmoe -c 8192
# Measure it properly instead of trusting any calculator
llama-bench -m Qwen3-30B-A3B-Q4_K_M.gguf -ngl 99 --n-cpu-moe 18,22,26,30Note the pairing: you still pass -ngl all. The point of -ncmoe is that all layers go to the GPU and only the expert tensors within the first N of them are held back — which is why it beats the old approach of simply reducing -ngl. Reducing -ngl strands whole layers, attention included, on the CPU. The equivalent hand-rolled version is an -ot, --override-tensor regex, which is what people used before these flags existed and is still there if you need finer control.
What the Calculator Says for the Common Cards
At 8K context, a 24GB card holds Qwen3-30B-A3B Q4_K_M outright, and a 12GB card runs it with 8 GB of experts in system RAM. These are the calculator's own outputs, reproduced so you can see the shape before you touch a slider.
| Model / quant | 8GB | 12GB | 16GB | 24GB |
|---|---|---|---|---|
| Qwen3-30B-A3B Q4_K_M | -ncmoe 33 | -ncmoe 22 | -ncmoe 12 | fits, no offload |
| Qwen3-30B-A3B Q3_K_M | -ncmoe 29 | -ncmoe 15 | -ncmoe 1 | fits, no offload |
| gpt-oss-20b MXFP4 | -ncmoe 11 | -ncmoe 3 | fits, no offload | fits, no offload |
| gpt-oss-120b MXFP4 | -ncmoe 33 (57 GB RAM) | -ncmoe 31 (54 GB RAM) | -ncmoe 29 (50 GB RAM) | -ncmoe 24 (41 GB RAM) |
8K context, fp16 KV cache, 0.7 GB runtime overhead allowance. The gpt-oss-120b row is the honest one: the flag value barely moves with VRAM because the constraint is the ~57 GB of MXFP4 experts you need somewhere. If you do not have 64 GB of system RAM, that model is not a candidate no matter which card you own — see the hardware hub for what actually holds it.
What This Calculator Does Not Know
It computes memory exactly and speed approximately, and you should treat those two outputs very differently.
- The tokens-per-second figures are bandwidth rooflines, not benchmarks. They divide the bytes read per token by the memory bandwidth on each side of the split. They ignore compute, kernel launch overhead, PCIe transfers and prompt processing, so real throughput lands below them. We publish the ceiling because the ratio between offload settings is what you are choosing between; for the absolute number, run
llama-benchon your own box. - Prompt processing behaves differently from decode. During prefill every expert can be touched, so an offloaded model is disproportionately slower on long prompts than the per-token figures suggest. If you feed it 8K-token documents, measure prefill separately.
- The KV cache assumes fp16 and no cache quantization. Quantizing the KV cache changes the fixed cost materially at long context; the calculator does not model it.
- Overhead is a flat 0.7 GB allowance. Real runtime overhead varies by backend, batch size and driver. If you are within a few hundred megabytes of your VRAM limit, the calculator is telling you it is tight — not that it will work.
- Unified-memory machines break the model entirely. On Apple Silicon and Strix Halo there is no VRAM/RAM split to optimise, so
-ncmoeis not the lever it is on a discrete card.
When to Use a Different Tool
Use this page only for Mixture-of-Experts models. For a dense model — Llama, Mistral, Gemma, the Qwen3 dense line — the classic parameters-times-bits arithmetic is correct, and the general VRAM calculator is the right tool. If you are still deciding which size class to target, the model size picker works backwards from your hardware, and our 12GB VRAM model picks covers what runs well on the most common card tier. For running any of this through Ollama rather than llama.cpp directly, start with the complete Ollama guide. Model-specific detail lives on the gpt-oss and Qwen3-Coder pages.
Frequently Asked Questions
How much VRAM does Qwen3-30B-A3B need?
Far less than "30B x 4 bits" implies, if you offload correctly. The Q4_K_M GGUF is an 18.56 GB file, but 28.99B of its 30.53B parameters live in expert FFN tensors that llama.cpp can hold in system RAM. What must stay on the GPU is only the attention stack, embeddings and routers — about 0.94 GB at Q4_K_M — plus the KV cache (~0.81 GB at 8K context) and roughly 0.7 GB of runtime overhead. That means a 24GB card holds the whole thing, a 12GB card runs it with -ncmoe 22, and even 8GB works at -ncmoe 33 provided you have the system RAM to hold ~12 GB of experts.
What is the difference between -cmoe and -ncmoe in llama.cpp?
They are documented together in the llama.cpp CLI reference: "-cmoe, --cpu-moe" keeps all Mixture of Experts weights in the CPU, while "-ncmoe, --n-cpu-moe N" keeps the MoE weights of the first N layers in the CPU. -cmoe is the sledgehammer — it is the same as -ncmoe set to your layer count, and it is what you use when you have very little VRAM. -ncmoe is the dial, and it is almost always the better choice, because every layer you keep on the GPU is a layer whose active experts get read at VRAM bandwidth instead of DDR bandwidth. Both take a corresponding LLAMA_ARG_ environment variable if you prefer to set them once.
Can I run gpt-oss-20b on a 12GB or 8GB GPU?
On 12GB, yes, and it barely needs any offload: -ncmoe 3 is enough at 8K context, because the model is only 24 layers and its attention stack is about 1.04 GB. On 8GB you need -ncmoe 11, which puts roughly 5 GB of experts in system RAM. On a 16GB card the whole 12.11 GB MXFP4 file fits with room for context. gpt-oss also alternates sliding-attention layers with a 128-token window against full-attention layers, so its KV cache is unusually cheap — about 0.20 GB at 8K, against 0.81 GB for Qwen3-30B-A3B at the same context.
Why is my "params x bits" VRAM estimate wrong for MoE models?
Because it answers a different question. Params x bits tells you how much memory the weights occupy in total, which is still true for MoE. What it does not tell you is where those bytes have to live or how many of them get read per token. In Qwen3-30B-A3B, 95.0% of the parameters are expert FFN weights, and only 8 of 128 experts fire per token — 6.25% of each layer. So the weights that must sit in fast VRAM are a tiny fraction of the file, and the weights that get streamed from system RAM per token are a tiny fraction of the experts. General VRAM calculators, including our own, use total parameters and will tell you a 12GB card is hopeless for this model. It is not.
How many layers of experts should I offload before it stops being worth it?
There is no cliff — the cost is linear, which is the useful news. Each offloaded layer moves exactly one layer's worth of active expert bytes from VRAM bandwidth to system RAM bandwidth, so tokens per second declines smoothly as you raise -ncmoe. The right value is simply the smallest N that fits, which is what the calculator returns. The real knee is set by the bandwidth ratio: on a 360 GB/s card with DDR5-5600 (89.6 GB/s), a byte read from system RAM costs roughly four times what it costs from VRAM, so every layer you can keep resident is worth keeping. Verify the absolute numbers on your own box with llama-bench — the calculator gives bandwidth ceilings, not measurements.
Sources
- Qwen/Qwen3-30B-A3B config.json — 48 layers, hidden 2048, 128 experts, 8 per token, moe_intermediate_size 768, 4 KV heads, head_dim 128
- openai/gpt-oss-20b config.json and gpt-oss-120b config.json — 24 / 36 layers, hidden 2880, 32 / 128 experts, 4 per token, alternating sliding_attention with a 128-token window
- llama.cpp CLI reference — the
-cmoe / --cpu-moeand-ncmoe / --n-cpu-moe Ndefinitions quoted above, release b10472 (17 August 2026) - Hugging Face file listings for unsloth/Qwen3-30B-A3B-GGUF, ggml-org/gpt-oss-20b-GGUF and ggml-org/gpt-oss-120b-GGUF — quantised file sizes and GGUF parameter counts
- Wikipedia GeForce RTX 30 / 40 / 50 series specification tables — published memory-bandwidth figures used in the roofline estimate
Free to use — just keep the attribution link. Works on any site.
<iframe src="https://localaimaster.com/embed/moe-vram-calculator" width="100%" height="560" style="border:1px solid var(--line);border-radius:12px;max-width:680px" title="MoE VRAM Calculator — Local AI Master" loading="lazy"></iframe>
<p style="font:13px/1.5 system-ui,sans-serif;max-width:680px;margin:6px 0 0"><a href="https://localaimaster.com/tools/moe-vram-calculator">MoE VRAM Calculator</a> by <a href="https://localaimaster.com">Local AI Master</a></p>Know what to actually run on it
All 561 chapters — running local models, RAG, agents, fine-tuning — plus the Python Lab and every course added later.
Ready to Go Beyond Tutorials?
25 structured courses with hands-on chapters - build RAG chatbots, AI agents, and ML pipelines on your own hardware.
Was this helpful?
Go from reading about AI to building with AI
25 structured courses. Hands-on projects. Runs on your machine. Start free.
Written by the Local AI Master Team
The team behind Local AI Master
We build Local AI Master around practical, testable local AI workflows: model selection, hardware planning, RAG systems, agents, and MLOps. The goal is to turn scattered tutorials into a structured learning path you can follow on your own hardware.
Related Guides
Continue your local AI journey with these comprehensive guides
Mixture of Experts Explained
What MoE is and why sparse activation works.
VRAM Calculator
The dense-model calculator, for everything that is not MoE.
Model Size Picker
Match parameter count to your hardware.
Best Ollama Models for 12GB VRAM
Model picks for the most common card tier.
Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide
No spam. Unsubscribe with one click.