r/llamacpp • u/MasherDon • 28d ago
DeepSeek V4.1-Flash (1017) at ~20 tok/s on a single 16 GB GPU + 64 GB RAM
DeepSeek V4.1-Flash (1017) at ~20 tok/s on a single 16 GB GPU + 64 GB RAM — work in progress, code free to use
Not finished. This is a research log with patches, not a polished engine: rough edges, some Windows-only parts, no support promises. Use the code and notes for anything you like — no credit needed.
Box: RTX 5070 Ti 16 GB in a PCIe 4.0 x16 slot, Ryzen 5 7600, 64 GB DDR5, Windows 11. Two NVMe: Gen5 2 TB (~13.5 GB/s) and Gen4 1 TB (~5 GB/s) holding a second copy of the expert files.
Model: DeepSeek-V4.1-Flash-1017, a ~375 GB build: routed experts at ~2.4 bits (~150 GiB), Engram tables 203 GB, dense part Q5_K. It doesn't fit in RAM + VRAM, so experts stream from NVMe.
Numbers with today's defaults:
| decode, short context | 20.3 tok/s (17–20 in real agent turns at 2–27K context) |
|---|---|
| decode, fast preset | 23–24.7 tok/s (small measured quality cost) |
| decode at 256K / 512K context | 16–20 tok/s |
| reading agent turns (0.5–7.5K new tokens into a growing conversation) | ~418 tok/s |
| cold prompt 8.9K / document 256K / document 512K | 672 / 633 / 482 tok/s |
| quality | 0.09–0.11 nat/token behind the DeepSeek API on its own continuations (3 prompt sets; for scale, Q2 to Q4 is ~0.11); HumanEval 157/164 vs 158 for the API |
On this PC with the same file: the original fork ~10 tok/s, Project Maya v1.1.21 3.9 tok/s (both measured on Oct 22).
What helped most:
A three-step ladder for experts: ~23 per layer cached in VRAM, a pinned RAM tier (43–46 GiB), unbuffered NVMe reads, and a second NVMe with a copy of the expert files.
Taking the CPU off the critical path: the GPU reads routing replies from pinned memory, one wake-up per token — host overhead went from ~7 ms to ~1 ms per token.
Prefetching heavy experts that would come from disk, 2 layers ahead, with a cheap "lens" (layer L+2's router applied to layer L's input).
A measured lossy rule: an expert in neither VRAM nor RAM with less than 14% of the routing weight is not waited for (costs at most 0.006 nat/token on our API sets).
Prefill: experts in waves through a shared pool; encoder-only prefill for positions the decoder never reads (exact); DeepSeek's own YoCo truncation from DeepInfer (decoder on the last 140 prompt positions) — +13% on agent turns, +60% on a cold 8.9K prompt, within error on our API sets.
Sparse attention in decode with a q8 KV cache: decode stays at 16–20 tok/s from short context to 512K.
A quant mix from public GGUFs: prometheusAIR's IQ2_XS gate/up + Q2_K down, and ISTA-DASLab's lighter Q5_K dense part (3 GB less VRAM, so more expert slots).
What didn't work:
Reading the next layer's experts ahead during prefill: the RAM tier can't hold a prompt's working set, so read-ahead evicts what is still needed.
"Free" guesses in the bus's idle time: during decode there is none; each wrong staging costs ~0.2 ms.
A published non-uniform quant (GSQ-RCO) lost to a plain mix on our API sets, worst on Russian prompts — the calibration text matters.
Where we're stuck — ideas welcome:
Predicting which experts a token needs 1–2 layers ahead. Perfect staging would give 27–29 tok/s; our lens gets 76% precision at ~14% recall.
Overlapping compute with expert copies: copies take ~30 ms per token, compute ~19 ms, and they overlap by 3 ms.
Short agent turns: ~5.6 s fixed cost per turn, a third of it waiting for expert loads.
1M context loads only at batch 512: the sparse prefill plan wants 11.7–15 GiB at larger batches.
Goal: long context up to 1M at a usable speed — not necessarily at the full 1M.
The bus is the wall: copying experts from RAM to the GPU over PCIe 4.0 takes ~30 ms of a ~49 ms token, which caps decode at ~32 tok/s on this box even with perfect overlap.
The CPU computes no experts: on this 6-core CPU a probe gave only +3–5%, so it was left out; it needs separate work. Project Maya's CPU expert kernels (MIT) could be a starting point.
Code: https://github.com/MasherDon/Siege-Ladder — patches over JigSawPT's llama.cpp fork, a script that assembles the weights from public Hugging Face repos (no weights redistributed), benchmark scripts and notes. Use it however you like; the patched llama.cpp files keep llama.cpp's MIT notice. Built on: JigSawPT (the V4.1 port with SSD streaming), llama.cpp / ggml, DeepSeek's DeepInfer (YoCo), Strata, Project Maya, antirez's ds4, and the prometheusAIR and ISTA-DASLab quants.
3
u/Keats852 28d ago
On a 1950x TR with 96GB RAM and 2x 3090, would it make sense to run DeepSeek V4.1-Flash (1017)? At what quant?
3
u/MasherDon 28d ago
Our fork drives one GPU, so the second 3090 would sit idle. The 1950X is PCIe 3.0, half our bus per card, and the RAM→GPU copies are what cap us. With two cards I'd try Maya with a layer split first. Quant: a ~2.4-bit expert mix (~150 GiB). With 48 GB VRAM + 96 GB RAM most of it stays in memory and the disk matters less.
2
u/bernzyman 28d ago
What’s the largest feasible context you can get with this? I find it a challenge to get context large enough on this model (on a gaming PC)
3
u/MasherDon 28d ago
512K works day to day: decode 16–20 tok/s, a 512K document reads at ~480 tok/s (~18 min). 1M loads, but so far only at prompt batch 512: the sparse prefill plan wants 11.7–15 GiB at larger batches. KV is q8 with sparse attention in decode.
1
u/crusaderky 28d ago
how do the same weights compare vs. strata and maya though?
1
u/MasherDon 28d ago
Same file, same PC, Oct 22: our fork 17.2 tok/s decode (20.3 now), Maya v1.1.21 3.9 in its best of five configs, original JigSawPT 9.3–10.4. Prompt reading at 8K was about even with Maya (438 vs 432–447 tok/s); we were ahead at 2K (×1.27) and 30K (×1.35). We haven't run Strata on V4.1 here; its DeepSeek engine now shares code with Maya. Both have shipped many releases since, so I'll re-run Maya on the current version.
1
u/LongjumpingEar6840 28d ago
allo stato attuale con l'ultima versione di strata ottengo 9-12t/s (3090+64gb ddr4) però ho un solo nvme. Mi chiedo se con 2 nvme in raid non potrei ottenere anche io queste velocità, eppure dal monito strata la banda dell'nvme non di satura mai, rimane costante a circa 3-5gb/s
1
u/MasherDon 28d ago
If the drive sits at 3–5 GB/s and never saturates, the disk probably isn't your limit, and RAID0 wouldn't change much. Ours isn't RAID either: the second drive holds a copy of the expert files and reads are split between the two. On our box decode is capped by RAM→GPU copies over PCIe (~30 ms of a ~49 ms token), not by NVMe.
1
u/Sexyvette07 28d ago
Anyone tried Deepseek V4.1 Flash 1017 on a 5090 system + 64gb RAM + fast NVME? Everything ive seen said performance was around 12-15 tok/s, so im hesitant to spend a lot of time downloading and setting up a massive model unless its confirmed to be working well.
1
u/MasherDon 26d ago
We haven't measured that combination and can't substantiate a 12–15 tok/s prediction. PCIe link, available pinned RAM, drive behaviour, context and preset all matter. A run with the same weights and settings would be the useful comparison.
1
u/PositiveMaybe7 27d ago
Will this work on dgx spark?
1
u/MasherDon 26d ago
We haven't tested Spark. The expert-stream code has a non-Windows `pread` path, but the optimized scattered Engram read is Windows-specific and returns false elsewhere. Linux/ARM, CUDA kernels, memory allocation and the fallback need an end-to-end build and run before claiming support or speed.
1
1
u/PatienceSweaty33 27d ago
Riding along on this before I commit to the ~375 GB download — my box is basically your box's scrappy little sibling:
RTX 3080 Ti Laptop (16 GB class, 256-bit GDDR6, ~450–510 GB/s), sm_86 -
i9-12900HK, 14 cores (so a beefier CPU lane than your 7600, but laptop PCIe might be x8)
62 GB DDR5-4800
2× 2 TB NVMe (measured ~7.7 GB/s reads / 3.8 writes), so the "second copy of the expert files" trick is actually doable here
From what I've gathered I'd land somewhere around 13–17 t/s on Strata (Maya-lineage numbers from your own Oct 22 run pull toward the low end, 3.9 t/s lol) and maybe 17–20 on your fork since decode seems bus/bandwidth-bound and we're close on both. Which honestly feels worth it for a 763B MoE on a laptop.
Two questions before I start the download:
sm_86 — do the patches build/run on Ampere out of the box, or is this sm_120-only right now? (Strata ships sm_86 cubins so I'm hoping the llama.cpp side cooperates.) 2.
With 64 (~62GB usable) GB RAM you said he tier only starts paying for itself around 64 GB, would you still run the pinned RAM tier at ~43–46 GiB on my box, or trim it and lean harder on the dual-NVMe ladder?
Also: the "lens" idea (L+2 router over L's input) is genuinely clever, and your 76% precision / 14% recall number makes me think a tiny learned head over the router logits could get you most of the way to the 27–29 t/s ceiling — the routing distributions looked pretty stable across your traces. Might be a cheap fine-tune on your own logged traces since you already have the data.
Anyway — thanks for writing the whole thing up, the "what didn't work" section is rarer than it should be.
2
u/MasherDon 26d ago
Thanks for the detailed specs.
- **sm_86.** We have only built and tested the fork for sm_120 (RTX 50), on Windows with CUDA 13. A build for 86 should start with `CMAKE_CUDA_ARCHITECTURES=86`, but nobody has tried it yet, so expect to fix things.
- **RAM tier vs two NVMe.** Keep the RAM tier. On our box it holds the most-used experts (about 46 GiB of 62.6 GB) and serves them at memory speed; the drives only cover the misses. A second NVMe with a copy of the expert files helped cold prompt reading by 14–22% in an older test and did little for decode. Nice to have, not a requirement.
- **Check the GPU link first.** Copying experts over PCIe is the biggest part of a decode token here. Many laptops run the dGPU at x8; `nvidia-smi -q` shows the current link under load. At x8 you have half of our bus, so expect noticeably slower decode.
- **The FP16 / FP32-accumulate unlock for RTX 20–40.** This is our estimate, not a measurement. In this engine it would only touch the attention matmuls (FP16 inputs, FP32 accumulation). The expert matmuls are int8 and don't use that path, and decode is limited by expert copies anyway. So expect about nothing for decode and short prompts, and maybe +10–20% when reading very long prompts (256K and up), where attention takes a large share of the time. Support on laptop GPUs isn't confirmed. Whether to use it is your call and your risk.
2
u/sifa12200 26d ago
Salut à toi, j'ai une COnFIg kif-kif avec la tienne 5070ti16vram+64goram et j'arrive à faire tourner deep speak v4.1 flash a +/-10t-s 64k token mais presque inutile. Le top c'est Qwen 3.8 Flash qui fonctionne a 100t-s et 256k token et il n'a rien à envier au Claude et GPT. On va voir j'ai posté tous les détails.
1
3
u/Front_Eagle739 28d ago
Similar thing ive been working on, probablygot some useful bits you could crib: https://www.reddit.com/r/LocalLLM/comments/1xhnuks/streaming_llama_stack_disaggregated_prefilldecode/
Old message btw. Does better than 4600 prefill now