Two second-hand RTX 3090 cards, 48GB VRAM in total.
Trying to run a MoE model with billions of active parameters inside VRAM yields an immediate CUDA out of memory error.
Keep the backbone on the GPU and offload cold experts to system RAM. Can it start? Yes.
What happens during inference? Token generation collapses to 2 or 3 tokens per second. The CPU runs at 100%, while GPU utilization sits idle at 3%.
Inspect nvidia-smi first, then measure bus bandwidth. The bottleneck rarely lies in compute kernels. It is almost always trapped in weight transfers across the PCIe bus.
All benchmark data stems from the open-source GitHub playbook at https://github.com/alesha-pro/inference-optimization-playbook.
The test hardware rig is specific. Ubuntu 22.04 LTS. Four RTX 3090 GPUs locked at 300W power limits. Motherboard slots wired to PCIe 3.0 x16, paired with 8-channel DDR4-2133 memory. NVIDIA driver version 580.12 and CUDA 12.8. The software layer runs patched llama.cpp commit 1cd7102 alongside a custom-built maya-ik2 r5 engine. Testing against DeepSeek, Qwen, and Hunyuan, the team ran 115 hypotheses to produce 97 controlled benchmarks.
The true value of this repository is not the speedup charts, but its transparent catalog of failed attempts. Many tricks widely praised across online forums turn out to be net negative in real offloaded pipelines.
The Physical Bottlenecks of Weight Offloading
Why does MoE hybrid offloading crawl like a snail? Look at the physical numbers.
Every time a MoE model outputs a token, its gating router picks a small subset of experts. In cloud clusters with thousands of GPUs, all experts remain memory-resident in VRAM with near-zero latency. On consumer desktop motherboards, PCIe bandwidth is congested.
Whenever an activated expert is missing from VRAM, it must be fetched across PCIe from host memory. Calculate the cost:
- A single quantized expert weight spans 150MB to 300MB
- A single token typically activates 4 to 8 experts
- In worst-case queries hitting cold experts, every step shifts 1.2GB of weights across the bus
- Standard PCIe 3.0 x16 real-world transfer throughput tops out around 12GB to 14GB per second
What does this imply?
Pure data transfer caps inference speed under ten tokens per second. If multiple GPUs fight over shared memory controllers, bus contention doubles the delay.
Where should engineering effort actually go?
Four Low-Level Fixes That Deliver Real Speedups
Across 97 controlled runs, only four architectural changes produced generational speedups.
1. Ditch Paged Memory, Use Pinned Host RAM for Direct DMA Transfers
Standard userland programs store memory in pageable virtual memory. To ship weights to the GPU, the driver must first copy pages into an internal locked bounce buffer before launching DMA. This redundant copy eats half of dual-channel memory bandwidth.
The fix is straightforward. Lock expert weights into pinned host RAM at startup using OS page-locking primitives, preventing the kernel from swapping them to disk.
What are the measured gains?
On a 4-card DeepSeek V4.1 Flash setup with prompt chunking, 32K context prefill speed jumped from 430 to 2,199 tokens per second. A fivefold improvement gained solely by cutting CPU memory copies.
2. Discard Pipeline Layer Splits, Switch to Tensor Parallelism
Partitioning layers across cards is an intuitive choice: GPU 1 takes the first ten layers, GPU 2 takes the next. What happens in an offloaded setup? Severe pipeline bubbles.
Downstream GPUs sit idle while upstream cards wait for memory transfers. Workloads desynchronize, causing over 40% idle pipeline stall time.
The team scrapped layer splits on GLM-5.3-Flash at 2.05bpw and switched to full tensor parallelism. Each GPU holds one quarter of every expert weight matrix, triggering concurrent DMA fetches and matrix multiplication simultaneously, followed by lightweight all-reduce steps.
On 4 GPUs, decode speed rose smoothly from 48.3 to 67 tokens per second. Power curves aligned across all cards with zero idle bubbles.
3. Compute Cold Experts on CPU While Hot Experts Run on GPU
If pulling cold experts over PCIe burns valuable bus bandwidth, why not let multi-core CPUs evaluate them directly in host memory?
On a 2-GPU Hunyuan Hy4 Flash setup, the team rewrote the execution scheduler:
┌───────────────────────────────┐
│ Router Token Selection │
└───────┬───────────────┬───────┘
│ │
[Hits Resident VRAM] [Hits Host Memory]
│ │
▼ ▼
┌───────────────┐┌───────────────┐
│ GPU VRAM Cores││ CPU Host Cores│
│ Parallel GEMM ││ Local In-RAM │
└───────┬───────┘└───────┬───────┘
│ │
▼ ▼
┌───────────────────────────────┐
│ Hidden State Barrier │
└───────────────────────────────┘
When 6 out of 8 chosen experts reside in VRAM and 2 in RAM, the runtime no longer moves weights. The 6 VRAM experts run on GPU tensor cores, while the 2 cold experts run concurrently on host CPU threads. After compute, only lightweight activation vectors traverse the bus.
During code generation tasks, Hunyuan decode speed surged from 24.6 to 70.4 tokens per second.
4. Single-Graph Dispatch: Collapse Thousands of Kernels into One CUDA Graph
Once an entire model fits inside a 24GB card, kernel launch latency replaces bus bandwidth as the chief bottleneck.
Taking Inkling 2 Mini as an example, its 24-layer MoE architecture features 3,072 expert slots. Under default llama.cpp runtimes, every single token step incurs 1,404 driver-level kernel launches. Even when kernels execute in microseconds, launch queues throttle generation at 57 tokens per second.
The solution is clean. In the custom maya-ik2 r5 engine, the team captured the entire MoE dispatch and residual aggregation graph into a single executable CUDA Graph, cutting launches to 781.
Without altering quantization precision, token decode speed doubled from 57 to 112 tokens per second.
Placebo Tuning Myths Debunked by Hard Data
Alongside the wins came documented failures. The playbook records several techniques that delivered zero benefit or severe regression.
1. Can Static Expert Profiles Be Reused Across Tasks?
Many optimization tools claim that running a benchmark to generate an expert frequency rank and pinning the top 20% in VRAM guarantees an 80% cache hit rate.
Is that accurate?
The numbers tell a different story. In MiniMax tests, an expert profile built from one specific query achieved 90% hits on that exact query. Moving to a different question within the same domain caused cache hits to drop to 64%. Random expert placement without any profiling scored 61%.
Unless a model exhibits strong global routing skew, static profiles offer no real advantage over random assignment.
2. Are Custom Distilled Draft Models a Guaranteed Win?
The theory of speculative decoding is sound: a tiny model drafts tokens quickly, while the main model verifies them in batches. Many teams spend days training small drafters on proprietary codebases.
What was the actual result?
Across 3 open-source models, custom-trained small drafters yielded negligible speed gains.
Draft models require extremely high acceptance rates. Minor sampling divergences trigger cascading rejections, and the rollback penalty wipes out batch verification savings.
3. Do Micro-Benchmark Wins Translate to Long-Context Workloads?
Many developers tune parameters using short 128-token sequences. An attention cache tweak showed a 27% speedup on short sequences. Tested inside an 8K debugging context, it suffered numerical overflow by turn four, dragging overall throughput down by 2%. Short synthetic tests rarely survive real production sessions.
Four-Card Benchmark Reference Matrix
Verified benchmarks on Ubuntu 22.04 with 4x RTX 3090, PCIe 3.0 x16, and 8-channel DDR4-2133:
| Model Architecture and Quant | Parallel Hardware Split | Core Optimization Action | Baseline Speed | Tuned Speed |
|---|---|---|---|---|
| DeepSeek V4.1 Flash Offloaded | 4x RTX 3090 + Host RAM | Pinned RAM DMA plus prompt chunking | 32K Prefill: 430 tok/s | 32K Prefill: 2,199 tok/s |
| Hunyuan Hy4 Flash Offloaded | 2x RTX 3090 + Host RAM | Cold experts on CPU, hot on GPU | Code Decode: 24.6 tok/s | Code Decode: 70.4 tok/s |
| GLM-5.3-Flash 2.05bpw | 4x RTX 3090 | Full tensor parallelism over layer splits | Decode: 48.3 tok/s | Decode: 67.5 tok/s |
| Inkling 2 Mini Resident VRAM | 1x RTX 3090 300W | Single CUDA Graph collapsing 781 launches | Initial: 57.0 tok/s | Tuned: 128.7 tok/s |
| Qwen3.8-Flash-Next Offloaded | 2x RTX 3090 + Host RAM | Native DFlash2 paired speculative drafter | Baseline | Net Gain: +45% |
Actionable Troubleshooting Guide
When running large MoE architectures on consumer cards, start with these terminal diagnostics:
# Monitor GPU throughput and real-time PCIe bus traffic
nvidia-smi dmon -s et -d 1
# Verify physical PCIe link speed negotiates at full 16x width
sudo lspci -vv -s $(lspci | grep -i nvidia | head -n 1 | awk '{print $1}') | grep LnkSta:
# Inspect CPU NUMA node topology to prevent cross-node memory contention
numactl --hardware
# Allocate static hugepages for locked memory buffers
sudo sysctl -w vm.nr_hugepages=1024
First, watch the bus. If PCIe usage hovers above 90%, the bottleneck is data transfer. Check whether hugepages are enabled and verify that weight matrices are locked in host RAM via pinned memory.
Second, analyze routing skew. If routing is evenly distributed, avoid manual hot expert lists. Configure tensor parallelism across cards, or execute cold experts directly on CPU threads.
Third, test against real workloads. Evaluate settings with multi-turn logs and complex prompt histories.
Is the pipeline truly stable? Only configurations that maintain consistent throughput without overflow across deep contexts qualify as dependable production setups.