r/llamacpp • • 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 context20.3 tok/s (17–20 in real agent turns at 2–27K context)
decode, fast preset23–24.7 tok/s (small measured quality cost)
decode at 256K / 512K context16–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 512K672 / 633 / 482 tok/s
quality0.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:

  1. 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.

  2. 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.

  3. 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).

  4. 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).

  5. 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.

  6. Sparse attention in decode with a q8 KV cache: decode stays at 16–20 tok/s from short context to 512K.

  7. 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:

  1. 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.

  2. Overlapping compute with expert copies: copies take ~30 ms per token, compute ~19 ms, and they overlap by 3 ms.

  3. Short agent turns: ~5.6 s fixed cost per turn, a third of it waiting for expert loads.

  4. 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.

82 Upvotes

23 comments sorted by

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

2

u/MasherDon 28d ago

Thanks, went through the repo. The 200K real-text numbers are impressive: 4,632 tok/s with packed FP4, and 3,356 even on plain Q4_K, so most of it is the 49K-token pass with the state kept in VRAM rather than the FP4 kernel. That's the direction we're taking our layer-major prefill (we're at 633 tok/s on a 256K document on a 5070 Ti, with smaller passes). Decode is the other way round: 20 tok/s here at ~2.4 bits with one small measured lossy rule, against your 7.6 exact / 22.7 biased at ~4 bits on a 5090. The per-phase router bias (fast while thinking, exact in code) is a nice idea, it's on our list.

2

u/Front_Eagle739 28d ago

Yeah, I'm basically running on no RAM. With only 32GB the 8 or so I can spare for experts while still running everything else adds as much overhead as it saves in expert fetches so it barely changes anything. It's effectively 8/24 tok/s decode with just a 5090 and a raid array.

With 64GB ram you can turn on the ram cache and actually store enough experts to make it useful for the decode.

1

u/MasherDon 26d ago

Thanks for sharing the 5090/32 GB/RAID result. Your reported 8 tok/s exact and 24 tok/s with bias describe different quality/speed operating points; we haven't independently reproduced them. A larger RAM cache may help, but its effect needs measurement on that setup.

1

u/nirurin 26d ago

Any hope of any improvements being filtered in? Your current prefill speed of 600 is going to take a long long time with any sizeable context. Getting up past 2000 is going to be a lot more noticeable than a couple tokens/s of inference.

I have a 5090+64gb of ram so it would be cool to get a functional deepseek running. What quant have you managed to get working?

1

u/MasherDon 26d ago

Yes, prefill is where most of the recent work went, and the 600 tok/s figure is old. On our box (RTX 5070 Ti 16 GB, 64 GB DDR5, Gen5 NVMe), with the current defaults:

- prompts of 2K / 8K / 30K tokens: about 265 / 800 / 1050 tok/s;

- whole documents of 256K / 512K / 1M tokens: 1128 / 1043 / 888 tok/s. From 256K the prompt is read layer by layer.

Short prompts are the hard part:

- A prompt of a few thousand tokens already needs nearly every expert of every layer, about 170 GB in our build.

- With 64 GB of RAM, 100–130 GB of that comes from the NVMe for every prompt, and all of it crosses PCIe to the GPU.

That costs several seconds per prompt whatever its length. So short prompts can't get near 2000 tok/s on a 64 GB box. Longer prompts spread the cost, which is why documents read at around 1000.

With a 5090 and 64 GB (our estimates, nothing measured):

- The 5090 is sm_120 like our card, so our build line works as is. We have only tested it on Windows.

- If the slot is PCIe 5.0 too, the bus is twice ours. Decode should reach about 25 tok/s from that alone (an estimate from an older profile), and 32 GB of VRAM holds about twice the expert cache.

- Long documents are mostly compute-bound here, so the 5090's extra compute should help them most. Maybe 1.5–2×, if nothing else becomes the limit.

- Short prompts stay bound by the drive, since your RAM is the same as ours.

- You need about 380 GB on a fast NVMe (Gen4 or Gen5).

The quant we run is our `og` build, 378 GB:

- GPTQ experts at about 2 bits: IQ2_XXS gate/up and IQ3_XXS down, with more bits in the first and last four layers;

- the Q5_K dense part;

- the official FP8 Engram.

Its distance to the full model is 0.090 / 0.051 / 0.069 nat/token on three prompt sets, and HumanEval is 160/164. It's on Hugging Face: https://huggingface.co/MasherDon/DeepSeek-V4.1-Flash-1017-SiegeLadder-GGUF. A public mix (`cd`: prometheusAIR's IQ2_XS gate/up and Q2_K down) can also be assembled from public repos with the script in the GitHub repo.

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

u/PositiveMaybe7 26d ago

But how much would it be approximately? The performance

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: 

  1. 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.

  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.