How to serve 134 GB of model weights with 24 GB VRAM / 64 GB RAM
How oom-inference serves roughly 134 GB of text-model weights across a 24 GB 4090, 64 GB of host RAM and NVMe.
Inference Demo
No further weight quantisation: the NVFP4 release on one 24 GB card
| Request | Input tokens | First token | Decode |
|---|---|---|---|
| Read an incident report | 21,878 | 6.95 s | 45.4 tok/s |
| Rewrite a source file | 23,723 | 7.33 s | 46.3 tok/s |
1. Why does capacity matter
The text model's weights come to 134 GB. A 4090 and 64 GB of RAM hold 88 GB between them. The usual fix is to quantise further until the model fits, which costs quality. I wanted to run the published NVFP4 release as it is and make up the difference with NVMe.
The tiers are far from equal. VRAM is where the GPU computes at full bandwidth, host RAM sits behind PCIe, and NVMe is slower again. So the job is keeping the weights each token needs in the fastest tier, and keeping disk reads rare on the hot path.
2. How I got NERDsniped
I started reading about the work that FlashML were doing with FreeToken to enable running larger models on consumer hardware by tiering experts between GPU & CPU. This got me thinking about extending that rationale to experts on disk.
oom-inference is my attempt at making that work for Qwen 3.8 Flash Next.
3. How does the tiering work?
For every layer in the MoE our router picks 10/512 experts to use for a token. That means that most experts are idle & depending on the workload you may only trigger a subset of experts for a session.
| Key | Part |
|---|---|
| 1 | The router scores the token and picks 10 of the layer's 512 routed experts. |
| 2 | The expert pool. Heavy squares are the experts selected for this token; faint ones sit idle. Their positions are illustrative. |
| 3 | The shared expert runs for every token whatever the route, and its output joins the routed experts'. Attention and the other dense layers also run for every token. |
So the expert is the unit of caching: the weights are split into one ~2.7 MB record per expert, exactly what a routing decision asks for.
Expert records are read with O_DIRECT through io_uring, bypassing the page cache, so the engine alone decides what stays in VRAM and pinned RAM. Experts that keep recurring move up to VRAM; one-off routes can stay on the host.
The PLE tables are different. Their rows depend only on the token IDs, so each step reads exactly the rows it needs through the normal page cache, with no tiering.
More context == Slower Experts
The KV cache competes for the same VRAM. It starts small and grows with the sequence, taking space back from the expert cache as it goes. A short prompt leaves more experts in VRAM; a long one costs decode speed, not capacity.
The full window works: a 255k-token prompt ran on the 4090 at 1,171 tok/s prefill and 22.8 tok/s decode, and found a needle placed at 10%, 50% and 90% depth.
4. Prefilling layer by layer
A GPU that holds the whole model reads a long prompt in one pass. Here each layer's experts have to be copied in first, so a single pass leaves the GPU idle while the copy engine works.
Instead the prompt is split into chunks and run one layer at a time: each layer runs over every chunk, and the union of their experts is fetched once. While one layer computes, the experts the next layer's router predicts are copied in, a few records at a time so the current layer's own copies never queue behind them.
5. Guessing ahead
Every decode step reads the dense weights and fetches experts anyway, so checking 8 guessed tokens costs far less than producing 8 one at a time. Guesses come from the model's own MTP head, or from prompt lookup: if the last few tokens appeared earlier, guess that whatever followed them comes next.
Lookup shines on file edits, which repeat big chunks of their input: output rose 22–40% in our experiments. On prose it costs a few percent.
When lookup supplies the guesses, the MTP head misses those steps and falls behind, so we now catch it up first. That took the demo from 43.4 to 45.6 tok/s.
6. Keeping the quality
The weights are RadixArk's NVFP4 release, byte for byte: 4-bit routed experts, BF16 dense weights and FP8 n-gram tables. The aim was an engine that loses nothing on top of that quant. I measured it two ways: against reference logits wherever a reference exists, and on benchmarks against the quant's published scores.
Logits. Hugging Face's own model code, run on CPU, is the reference. The final logits must sit at least as close to an FP32 run as the reference's own BF16 run does. The rounding floor for faster settings comes from two exact runs that differ only in prefill chunk size: they already disagree by a KL of about 0.03 (90% top-1) on a 32k-token document, because expert routing is discrete. The demos use all four of these settings:
--kv-cache k8v6Default8-bit keys and 6-bit values in the KV cache. 19% decode About 3x less KV memory; decode +19% at long context About 1,400 more expert slots at 95k tokens rounding noise Inside the model's own rounding noise--dense fp8Opt-inDense weights stored as FP8, one scale per 128 weights. 23% decode step Verify step 35–37 ms against 43–50 ms at 32k–95k About 1,660 more expert slots KL 0.10–0.13, 86–88% top-1 About 3x the rounding floor--expert-precision bf16Opt-inPrefill expert activations rounded to BF16 once, not split into three terms. 14% prefill Warm 32k prefill 16.2 s to 14.0 s KL 0.058, 92.1% top-1 About at the rounding floor--attention-precision bf16Opt-inPrefill attention on BF16 tensor cores; decode stays FP32. 16% prefill attention Prefill attention 1.51 s to 1.27 s per 32k prompt KL 0.051, 92.6% top-1 Inside the rounding floorBenchmarks. On the full GSM8K set, run with the settings RadixArk published, the 4090 scores the same as their unquantised and NVFP4 runs:
| GSM8K, all 1,319 problems | Score |
|---|---|
| oom-inference, defaults, 4090 | 97.73 (95% CI ±0.80) |
| RadixArk, unquantised BF16 | 97.12–97.50 |
| RadixArk, NVFP4 on SGLang | 97.27 |
--dense fp8 --expert-precision bf16 scores the same as the defaults on the same questions: 97.00 against 97.33 on 300 GSM8K problems, 77.5 against 77.0 on 200 MMLU-Pro questions and 98.1 against 98.5 on 95k-token retrieval, all inside the noise.
GPQA-Diamond (graduate-level science, thinking on) is partway through: 88.1 on the first 118 of 198 questions (95% CI ±5.8), against Qwen's 91.7 for the unquantised model. That interval still covers Qwen's number, and the first 118 rows of the file may not be a fair sample, so it settles nothing yet. AIME26 hasn't run.
7. Serving agents
Agents tend to re-send the same long document, so we save the model's state partway through a prompt and pick up from there.
With continuous batching, requests running together share the dense-weight reads and expert fetches, so total throughput climbs up to about four at once.
| Requests at once | Total tok/s, 8 streams | Decode tok/s per request | First token p50 / max | Total tok/s, 1 stream | First token p50 / max, 1 stream |
|---|---|---|---|---|---|
| 1 | 43.6 | 53.4 | 0.55 / 0.55 s | 43.4 | 0.55 / 0.55 s |
| 2 | 48.0 | 31.3 | 0.64 / 1.3 s | 42.6 | 0.64 / 3.6 s |
| 4 | 54.9 | 16.9 | 2.1 / 2.8 s | 41.5 | 6.7 / 9.9 s |
| 8 | 47.3 | 7.1 | 3.7 / 5.9 s | 39.9 | 13.4 / 23.1 s |
The server speaks the OpenAI and Anthropic APIs, including streaming and tool calls.
8. What didn't work
| Idea | Result |
|---|---|
| Draft width growing from one to three tokens while recent drafts were kept | Tied the demo (46.4 against 46.3 tok/s) and lost 3 to 7% on file edits. Fixed two- and three-token drafts ran the demo at 45.6 and 42.8 tok/s |
--kv-placement host |
Identical output and 9% faster decode at 95k, but 4% slower at 32k and slower at every length once --dense fp8 frees the VRAM anyway |
| A larger host tier | Cut disk reads 19% but didn't fix the prefill stall; the copy-engine queue did |
| Grouping adjacent prefill tokens to share key tiles | A key in a 4-token group's union is seen by about 1.2 of them, so shared tiles mostly compute masked-out scores |
| Smaller residual rings (32 or 64 rows) | Same speed as 256 on edit workloads |
9. How does it compare?
Published runs on a 96 GB RTX PRO 6000, where every expert fits in VRAM, hit 60–190 tok/s. The 4090 does 45.
| Published configuration | Speculation | Decode |
|---|---|---|
| vLLM, primitive-ai NVFP4, 8k input / 512 output, cache-free | Off | 74.4 tok/s |
| SGLang, NVFP4 + W4 PLE, paired report, 512 output | Off | 97.9 tok/s |
| Same SGLang report, tuned candidate | MTP + other tuning | 144.6 tok/s |
| SGLang, later tuned stack, four workloads, 8,192 output | MTP | 179.4–192.7 tok/s |
| llama.cpp, UD-Q4_K_XL, 22.7k prompt | Off | 59.7 tok/s |
| oom-inference research replay, 4090 | MTP + lookup | 45.4 tok/s |
Should you buy a 4090 for this? Probably not, API inference is cheap. But if you already have one, a 125B model at home is now practical.
To try it, download the converted model and run oominf serve --model <dir> (quickstart).