In this series / On this page· 6 of 9

When the Experts Don't Fit: Paging MoE Weights onto a 16 GB GPU

Compute the bytes each decode token moves when an MoE outgrows VRAM, streamed, CPU-side or paged, and choose K against your KV cache.

21 min readUpdated

On a 16 GB card, SGLang's --cpu-offload-gb 18 runs Qwen3-30B-A3B FP8 at 2.9 tok/s; Paged Experts runs the same model on the same card at 87.7. The weights, the card and the kernel are the same: what changes is how many bytes cross PCIe per token, and you can compute that for your own model and link before you launch anything.

Why an MoE almost fits

Expert weights are most of an MoE's bytes, and a decode token reads only a few of them. Qwen3-30B-A3B has 128 experts in each of its 48 layers and routes each token to 8 of them. In the GPTQ int4 checkpoint the experts weigh 14.95 GB and everything else (attention, embeddings, router) 1.74 GB. The experts alone fill a 16 GB card, yet one token touches 8 / 128 = 6% of them per layer.

Count per token, the way the roofline counts decode: bytes moved. If every one of the 384 routes (8 × 48 layers) missed and had to come from host memory, the token would still move only 384 × 2.43 MB = 0.93 GB, not 15 GB.

The same arithmetic for four current checkpoints:

Checkpoint Layers × experts, top-k Per expert One slot (× layers) All routed experts Everything else Every route missed
Qwen3-30B-A3B GPTQ int4 48 × 128, 8 2.43 MB 117 MB 14.95 GB 1.74 GB¹ 0.93 GB
Qwen3-30B-A3B FP8 48 × 128, 8 4.72 MB 227 MB 29.00 GB 3.45 GB 1.81 GB
gpt-oss-20b MXFP4 (card) 24 × 32, 4 13.24 MB 318 MB² 10.17 GB 3.60 GB 1.27 GB
Qwen3.6-35B-A3B FP8 40 × 256, 8 3.15 MB 126 MB 32.22 GB 5.24 GB 1.01 GB

"One slot" is the GPU memory one more resident expert costs across every MoE layer: the unit K counts. Qwen3.6's shared expert runs for every token, so it sits in "everything else", on the GPU.

¹ Plus 233 MB of GPTQ zero points and g_idx, unpaged because Marlin never reads them: 14.95 + 1.74 + 0.23 = 16.92 GB, the whole checkpoint. ² Checkpoint bytes. Marlin pads gpt-oss's 2880-wide dimensions to 2944 or 3072 at load (PR #45787), so its GPU slot is somewhat larger.

expert_paging.py prints these and every other number here from config.json and the safetensors headers (range requests, no weights, standard library):

$ python3 expert_paging.py --model qwen3-30b-int4 --k 92
# … (excerpt)
48 MoE layers x 128 routed experts, top-8
per expert 2.43 MB; one slot (x 48 layers) 117 MB; all routed experts 14.95 GB (13.92 GiB); everything else 1.74 GB; not paged (GPTQ qzeros, g_idx) 233 MB
decode, every route a miss: 384 x 2.43 MB = 0.93 GB per token -> 14.8 ms on PCIe 5.0 x16 (67.4 tok/s ceiling)
KV cache 98,304 B per token, BF16: one slot = 1,188 KV tokens

--link-gbps takes your measured host-to-device rate instead.

Three ways to run it, counted in bytes

Every engine that runs an MoE larger than VRAM picks one of three answers to "what crosses the link each token?": every offloaded weight, only activations, or only the experts the GPU is missing.

Horizontal bars on a linear scale, bytes per decode token for Qwen3-30B-A3B FP8 on a 16 GB card over PCIe 5.0 x16. SGLang --cpu-offload-gb 18: 19.3 GB. vLLM UVA reads with the same 18 GiB of experts on the host: 1.21 GB. Paging with K = 40 and no reuse between tokens: 1.25 GB. Paging with K = 40, upper bound from the measured 10.5 ms ITL: 0.60 GB. llama.cpp --n-cpu-moe 27: kilobytes of activations over the link, with a separate dashed ochre bar of 1.08 GB read from host DRAM by the CPU.Horizontal bars on a linear scale, bytes per decode token for Qwen3-30B-A3B FP8 on a 16 GB card over PCIe 5.0 x16. SGLang --cpu-offload-gb 18: 19.3 GB. vLLM UVA reads with the same 18 GiB of experts on the host: 1.21 GB. Paging with K = 40 and no reuse between tokens: 1.25 GB. Paging with K = 40, upper bound from the measured 10.5 ms ITL: 0.60 GB. llama.cpp --n-cpu-moe 27: kilobytes of activations over the link, with a separate dashed ochre bar of 1.08 GB read from host DRAM by the CPU.

Figure 1: streaming moves about 16 times more bytes per token than any design that moves only routed experts; reuse between tokens halves paging again.

Stream the weights. SGLang's --cpu-offload-gb moves modules to host memory until the budget is reached, then, on every forward, copies each offloaded module's whole state back to the GPU (offloader.py). Routing doesn't matter: 18 GiB offloaded means 19.3 GB per token. vLLM v0.33.0's UVA (unified virtual addressing) backend pins the experts on the host and hands the kernel a GPU view of that memory (uva.py): the kernel reads only the routed experts, in place, over PCIe. Since PR #62054, an expert that several requests in a batch route to is read once per step, not once per request. Nothing is cached: an expert used by ten tokens in a row is read ten times. The PR's launch line, without its numactl prefix (--cpu-offload-params experts offloads only expert parameters):

$ vllm serve Qwen/Qwen3-30B-A3B-Instruct-2507-FP8 \
    --max-model-len 4096 \
    --gpu-memory-utilization 0.90 \
    --offload-backend uva \
    --cpu-offload-gb 16 \
    --cpu-offload-params experts

Compute the experts on the CPU. llama.cpp's --n-cpu-moe N (where llama.cpp fits) keeps the experts of the first N layers in system RAM and runs them there; only activations, kilobytes per layer, cross the link. Host memory bandwidth and CPU compute set the speed: with 27 of 48 layers on the CPU (the PR's best FP8 setting), the CPU reads 27 × 8 × 5.01 MB = 1.08 GB of Q8_0 experts from DRAM per token. KTransformers runs the same split with AMX kernels and is integrated in SGLang (--kt-weight-path, --kt-num-gpu-experts).

Page the experts into GPU slots. SGLang's Paged Experts, opt-in since v0.5.23, keeps K of the E experts per layer in a K-slot table on the GPU and all E in pinned host memory (page-locked: the OS can't move it, so the GPU can copy from it directly). Each step, the experts the step routes to that aren't resident are copied into the least recently used slots, then the layer's own fused-MoE kernel runs on the GPU (residency.py). Bytes per token are misses × expert size, and an expert reused by the next token costs nothing. Results don't change: the PR reports bit-identical logprobs for BF16 and FP8.

The same idea exists elsewhere, at different stages:

Design Where Bytes over the link per decode token What bounds speed
Stream all offloaded weights SGLang --cpu-offload-gb Offloaded bytes Link
Stream routed experts, no cache vLLM v0.33.0 --offload-backend uva --cpu-offload-params experts; its LFRU cache (LRU weighted by frequency, --moe-expert-cache-size) is still open as #37190 Routed experts in offloaded layers Link
Experts computed on the CPU llama.cpp --n-cpu-moe / --cpu-moe, KTransformers Activations Host DRAM bandwidth, CPU compute
Page misses into GPU slots SGLang --enable-paged-experts (v0.5.23); llama.cpp --moe-cache-mib (#29887, merged 7 October, batches of up to 32 tokens) Missed experts Link × miss rate
Page misses from SSD SGLang --load-format expert_pack, experimental, DeepSeek-V4-Flash and Kimi-K3 only Missed experts, from NVMe: 1.7 to 2.0 GB per token for DeepSeek-V4-Flash at a 46 to 54% hit rate, about 2 tok/s on an RTX 5090 (LMSYS) SSD bandwidth × miss rate

The 30x, recomputed

The release notes credit Paged Experts with "12x to 30x faster single-stream decode than --cpu-offload-gb on a 16 GB card". All numbers below are from the PR's tables: an RTX 5070 Ti (16 GB, PCIe 5.0 x16) and an RTX 4070 Laptop (8 GB, PCIe 4.0 x8), Qwen3-30B-A3B, ShareGPT prompts with 256 output tokens, one request, ITL (inter-token latency, the decode time per output token; see Prefill vs. Decode) at p50.

The streaming rows measure the link. Divide the offloaded bytes (SGLang counts --cpu-offload-gb in GiB) by the ITL:

--cpu-offload-gb 3,  int4, 5070 Ti:   3.22 GB / 60.1 ms = 53.6 GB/s   (85% of PCIe 5.0 x16's 63.0)
--cpu-offload-gb 18, FP8,  5070 Ti:  19.33 GB / 341 ms  = 56.7 GB/s   (90%)
--cpu-offload-gb 10, int4, laptop:   10.74 GB / 833 ms  = 12.9 GB/s   (82% of PCIe 4.0 x8's 15.75)

Streaming runs at the link's practical rate, so its ITL is predictable to within a few percent: offloaded GiB divided by your link.

The ratio splits into sparsity and reuse. Suppose paging had no reuse at all, each route missing with probability 1 − K/E. FP8 at K = 40 would then page 384 × (1 − 40/128) = 264 experts, 1.25 GB per token: 15.5 times less than the 19.3 GB that streaming moves. That 15.5x comes from sparsity alone, from moving only routed experts. The measured ITL ratio is 341 / 10.5 = 32x, so reuse must at least halve the page-ins. If all of the 10.5 ms went to copies at 56.7 GB/s, a token could page at most 126 experts, 33% of its routes, against 69% with no reuse (at the full 63 GB/s: 140, still about half of 264). The real number is lower, since the GPU also computes in those 10.5 ms.

Row Resident K/E No-reuse page-ins Streaming / no-reuse bytes Measured ITL ratio Page-ins, at most
FP8, 16 GB, K = 40 31% 264 of 384 15.5x 32x 126 (33%)
int4, 8 GB laptop, K = 26 20% 306 of 384 14.4x 30x 149 (39%)
int4, 16 GB, K = 92 72% 108 of 384 12.3x 12.5x 112 (29%)

The int4 row on the 16 GB card is explained by sparsity alone: with 72% of the experts resident, random routing would already miss only 28% of the time, so it can't show reuse. The FP8 and laptop rows can, and they show that routing is far from uniform, and LRU exploits it: at least a factor of two.

Against llama.cpp, the gap is the honest number. The 30x compares paging with SGLang's own weakest path, and the PR says so. Against tuned llama.cpp (best --n-cpu-moe, byte-matched IQ4_XS and Q8_0), the two are close when most experts fit (int4, 16 GB) or when the link is slow (the laptop): 205.7 against 194.4 tok/s for int4 on the 16 GB card (--n-cpu-moe 3), 30.6 to 32.9 against 23.0 to 32.4 on the laptop (--n-cpu-moe 32). Paging wins clearly in one case: FP8 on a fast link, 87.7 against 45.2 tok/s (--n-cpu-moe 27). There the CPU reads 1.08 GB per token from DRAM at a 22.1 ms ITL, while paging copies at most 0.6 GB over a 57 GB/s link.

The same arithmetic predicts vLLM. With 16 GiB of Qwen3-30B-A3B FP8's 27 GiB of experts on the host, 59% of the 384 routes per token read host memory: 1.07 GB per token. On PCIe 4.0 x16 that caps decode at 25 to 26 tok/s at the 85-90% of the link the streaming rows reach (29 at the theoretical 31.5 GB/s), and UVA's in-place reads aren't bulk copies, so they may not reach even that. PR #62054 measured about 20.7 output tok/s at one request on an RTX 4090 (instruct model, 128 output tokens, prefill included), below that ceiling as it should be. With about the same experts on the host, UVA's reads (1.21 GB per token at 18 GiB) are paging with a fixed K and no reuse (1.25 GB at K = 40): everything Paged Experts gains over vLLM v0.33.0 comes from reuse.

Choosing K

K is the one knob, and it trades against the KV cache. --paged-experts-num-resident is required in v0.5.23: the server refuses to start without it, or with K below the router's top-k (method.py); the PR body's auto-sizing isn't in the release.

Each slot is context you don't have. The K slots count as model weights in SGLang's memory accounting, so K and the KV cache come out of the same --mem-fraction-static budget. One slot costs per-expert bytes × MoE layers: 117 MB for the int4 model. Qwen3-30B-A3B's KV cache costs 96 KiB per token in BF16 (48 layers × 4 KV heads × 128 dimensions × 2 × 2 bytes), so one slot is 1,188 tokens of context, and one FP8 slot (227 MB) is 2,305.

One stacked bar for a 16 GB card running Qwen3-30B-A3B GPTQ int4 at K = 92: other weights 1.74 GB, 92 expert slots of 117 MB each (10.7 GB), KV cache for 10,240 tokens 1.0 GB, the rest headroom. The last slot, next to the KV cache, is outlined and reads one slot: 117 MB = 1,188 KV tokens. A note below reads: decode graphs captured up to 92 // 8 = 11 requests.One stacked bar for a 16 GB card running Qwen3-30B-A3B GPTQ int4 at K = 92: other weights 1.74 GB, 92 expert slots of 117 MB each (10.7 GB), KV cache for 10,240 tokens 1.0 GB, the rest headroom. The last slot, next to the KV cache, is outlined and reads one slot: 117 MB = 1,188 KV tokens. A note below reads: decode graphs captured up to 92 // 8 = 11 requests.

Figure 2: at K = 92, the experts take almost two thirds of the card; every slot you give back buys about 1,200 tokens of context.

The starting point for a 16 GB card, after the SGLang doc's usage and its K = 92 example:

$ python -m sglang.launch_server \
    --model-path Qwen/Qwen3-30B-A3B-GPTQ-Int4 \
    --enable-paged-experts \
    --paged-experts-num-resident 92 \
    --mem-fraction-static 0.88 \
    --max-total-tokens 10240

If the server runs out of memory for the KV cache at startup, lower K. For gpt-oss-20b, add --moe-runner-backend marlin: its MXFP4 experts are paged only on the Marlin runner. The PR's follow-up ran it at K = 16 of 32 on the same card at 107.7 output tok/s at one request.

Keep K at least top_k × your concurrent requests. A decode step whose routed entries fit the slots (tokens × top_k ≤ K) is decided and paged on the GPU, inside the CUDA graph. SGLang caps decode graph capture at K // top_k requests (method.py). Above it, steps run without a graph, planned on the host, and may need several waves of K experts each. Both of the PR's concurrency losses sit there:

  • On the laptop, K = 26 caps the graph at 3 requests. Four requests route up to 32 entries per layer, more than 26 slots: 11 to 12 tok/s, against 32 to 41 (two runs) for llama.cpp --n-cpu-moe 32.
  • FP8 on the 16 GB card gives 84 tok/s at 4 requests with K = 40 (cap 5) and 31 with K = 24 (cap 3). llama.cpp --n-cpu-moe 27 gives 55.

Prefill pays a toll up front. A long prefill touches nearly every expert in every layer, so it pages in up to all E − K non-resident experts once: 36 × 48 × 2.43 MB = 4.2 GB for int4 at K = 92, about 74 ms at 56.7 GB/s (the PR says about 80 ms), and 19.9 GB, about 350 ms, for FP8 at K = 40. A short prompt touches fewer and pays less: FP8's measured time to first token (TTFT) on ShareGPT prompts is 284 ms. Still, llama.cpp (same settings as above) keeps the lower TTFT on short prompts: 68 against 89 ms (int4), 235 against 284 ms (FP8), 719 against 928 ms (laptop). On a 2,048-token prompt the toll is amortized and the GPU's faster compute wins: 267 against 344 ms, 443 against 984 ms, 1,441 to 1,538 against 2,586 ms.

Gotchas

The whole expert set is page-locked. The host store holds all E experts of every layer in pinned memory: 15 GB for the int4 model, 29 GB for FP8, 32 GB for Qwen3.6-35B-A3B FP8. Under WSL2, pinned memory is capped at about half of system RAM, so the PR's 54 GB laptop can pin about 27 GB: enough for the int4 store, not for the FP8 one.

Some setups are refused at startup: more than one GPU, speculative decoding, and fused shared experts. Qwen3.6-35B-A3B has a shared expert and needs --disable-shared-experts-fusion; its hybrid attention with paging is untested.

Formats depend on the runner. BF16, FP8 (block or channel) and INT8 run on Triton; 4-bit and FP4 checkpoints run on Marlin (a library of 4-bit GEMM kernels), and gpt-oss's MXFP4 needs --moe-runner-backend marlin (doc). Per-tensor FP8 is rejected.

Unified memory removes both the gain and the cost. Without a PCIe hop between host and GPU memory, as on the DGX Spark (whose SM121 GPU the PRs didn't test), a page-in and --cpu-offload-gb both read the same DRAM, and none of this arithmetic applies.

Measure your own reuse. Your prompts decide where you land between no reuse and the PR's bounds, and routing depends on the model and the prompts, not on the card. Start SGLang unpaged wherever the model fits, with --enable-return-routed-experts, and send /generate requests with "return_routed_experts": true: each response's meta_info.routed_experts is base64 of int32 expert ids, tokens × layers × top_k. Save the responses one JSON per line and replay them through SGLang's LRU:

$ python3 expert_paging.py --trace responses.jsonl --k 26 --k 40 --k 92

It prints misses per decode token at each K; times the expert size, divided by your link, that is your decode ceiling. The replay assumes Qwen3-30B-A3B's shape (48 layers, 128 experts, top-8): for another model pass --layers, --experts and --top-k (24, 32 and 4 for gpt-oss-20b), or the miss rates are wrong.

Verdict

  • The model fits with room for your context: don't page.
  • Most experts fit (K/E above about 70%) and the link is fast: paging and tuned llama.cpp are within 6% on decode. Pick the engine for its other features.
  • The link is slow (PCIe 4.0 x8): their ranges overlap on the laptop; the same call.
  • Most experts live on the host and the link is fast (PCIe 5.0 x16): page. Set K to at least top_k × your concurrent requests (8 × 4 = 32 for Qwen3-30B-A3B at four requests), then give the rest to the KV cache.
  • Several concurrent requests and K below top_k × concurrency: use llama.cpp's CPU experts, or a lower precision that raises K.
  • Never stream MoE experts with --cpu-offload-gb: decode runs at your link divided by the offloaded GiB. On vLLM v0.33.0, UVA is the only expert offload that reads only routed experts (the prefetch backend copies whole layers); its ceiling is your link divided by the routed offloaded bytes.

Next, run the numbers for gpt-oss-20b: 32 experts of 13 MB per layer make K = 16 half the experts, 5.1 GB, and expert_paging.py --model gpt-oss-20b prints the rest.

Sources

  1. Model LibraryQwen3-30B-A3B Architecture
  2. Model Librarygpt-oss-20b Architecture
  3. Quantization in PracticeQuantizing Mixture-of-Experts Models

Inference Notes

Once a week: what changed in serving AI models, and what it means if you build, run or pay for them, in about five minutes.

Read past issues