llama.cpp Native --n-cpu-moe Hybrid GPU+DDR5 MoE Launcher (12GB–24GB VRAM) (launch-llama-cpp-n-cpu-moe.sh)
Audits free GPU VRAM via nvidia-smi, keeps 100% of attention layers and Q8_0 KV cache on GPU (-ngl 99 -fa), and offloads exact N MoE expert layers to dual-channel DDR5 RAM via --n-cpu-moe.
llama.cpp Native --n-cpu-moe Hybrid GPU+DDR5 MoE Launcher (12GB–24GB VRAM)
Audits free GPU VRAM via nvidia-smi, keeps 100% of attention layers and Q8_0 KV cache on GPU (-ngl 99 -fa), and offloads exact N MoE expert layers to dual-channel DDR5 RAM via --n-cpu-moe.
#!/usr/bin/env bash # Tinker AI — Mainstream 12GB–24GB GPU + Dual-Channel DDR5 MoE Offload Launcher (Guide #40) set -euo pipefail MODEL="./models/Qwen3-30B-A3B-Q4_K_M.gguf" NCMOE="16" THREADS="12" CTX="32768" echo "=== [1/3] Checking GPU Free VRAM & PCIe Link State ===" if command -v nvidia-smi >/dev/null 2>&1; then nvidia-smi --query-gpu=name,memory.total,memory.free,pcie.link.gen.current,pcie.link.width.current --format=csv fi echo "=== [2/3] Verifying llama-server Supports Native --n-cpu-moe ===" ./build/bin/llama-server --help 2>&1 | grep -E -- "--n-cpu-moe|-ncmoe" | head -n 2 echo "=== [3/3] Starting Hybrid MoE Server (-ngl 99 --n-cpu-moe $NCMOE, Attention+KV on GPU, $NCMOE Expert Layers in DDR5) ===" ./build/bin/llama-server \ -m "$MODEL" \ -ngl 99 \ --n-cpu-moe "$NCMOE" \ -fa -ctk q8_0 -ctv q8_0 \ -c "$CTX" -t "$THREADS" \ --host 0.0.0.0 --port 8080
Customizable Parameter Reference for launch-llama-cpp-n-cpu-moe.sh
This SH artifact exposes 4 template variables compiled client-side in your browser.
| Template Token | Parameter Description | Verified Default | Example Format |
|---|---|---|---|
{{MOE_GGUF_PATH}} | MoE GGUF Model Path (30B-A3B or 80B-A3B) | ./models/Qwen3-30B-A3B-Q4_K_M.gguf | ./models/Qwen3-30B-A3B-Q4_K_M.gguf |
{{N_CPU_MOE_LAYERS}} | MoE Expert Layers on CPU (--n-cpu-moe N) | 16 | 16 |
{{CPU_THREADS}} | Physical CPU Threads (-t) | 12 | 12 |
{{CTX_TOKENS}} | Context Window (-c) | 32768 | 32768 |
Verified Environment for "Running 30B & 80B MoE Models on a 12GB–24GB Consumer GPU + Dual-Channel DDR5 PC: Native llama.cpp --n-cpu-moe Benchmark & RTX 5070 SUPER (18GB) / 5080 SUPER (24GB) Sizing"
Measured on: AMD Ryzen 9 9900X + 64GB Dual-Channel DDR5-6400 CL30 (~84 GB/s read) + NVIDIA RTX 4070 (12GB) / RTX 5060 Ti (16GB) / RTX 5070 Ti (16GB) / RTX 4090 (24GB) | Spec-estimate rows: NVIDIA RTX 5070 SUPER (18GB GDDR7 192-bit · ~672 GB/s) & RTX 5080 SUPER (24GB GDDR7 256-bit 32 Gbps · ~1,024 GB/s)
All GGUF weights and `--n-cpu-moe` tensor splits run locally across PCIe and system RAM with zero external API calls.
- The RTX 4070 (12GB), RTX 5060 Ti (16GB), RTX 5070 Ti (16GB), and RTX 4090 (24GB) rows in Table 1 are lab-measured on our Ryzen 9 9900X + DDR5-6400 testbench; the **RTX 5070 SUPER (18GB)** and **RTX 5080 SUPER (24GB)** rows are **SPEC-DERIVED ESTIMATES** based on leaked 3GB (24Gb) GDDR7 module specs and are explicitly labeled `[Spec-Est.]`.
- `--n-cpu-moe N` only helps **sparse Mixture-of-Experts (MoE)** models (`Qwen3-30B-A3B`, `Qwen3-Next-80B-A3B`, `DeepSeek-V3/R1`). On dense models (`Qwen3-32B`, `Llama-3.3-70B`), every parameter is active on every token, so offloading to dual-channel DDR5 (~84 GB/s) still drops decode speed into single digits.
3-Step Verification Checklist After Deploying launch-llama-cpp-n-cpu-moe.sh
- Verified `llama-server --help | grep n-cpu-moe` confirms native `--n-cpu-moe` (`-ncmoe`) support (`llama.cpp` b4800+ / 2026 build).
- Confirmed system DDR5 RAM is running in Dual-Channel mode with XMP/EXPO enabled (e.g., DDR5-6000/6400, not stock JEDEC 4800).
- Set `-t` to physical CPU core count (e.g., `-t 8` or `-t 12`, excluding hyperthreads) so DDR5 bandwidth is not wasted on thread contention.