V4.1 Flash Q4 SSD streaming on Metal: which of these bit-exact decode speedups would you take as PRs?
We (Argonaut Labs) keep a fork of ds4 for DeepSeek V4.1 Flash Q4 (518 GB GGUF) with Metal SSD streaming on an M5 Max with 128 GB: https://github.com/argonautlabsai/ds4-argodrive. It is pinned at bd66c40. Before we rebase onto main and open pull requests, we would like to know which of the changes below you would consider, if any, so we send only those, one per PR, following CONTRIBUTING.md and AGENT.md: default on, no permanent flags, tests under tests/, before/after ds4-bench sweeps with commands, machine, quant and failures recorded.
Measurement
One interleaved session, 512-token prompt from speed-bench/promessi_sposi.txt, greedy, 200 generated tokens. Output SHA-256 identical to upstream on every arm. Decode GPU clock held at 1,620 MHz, zero swap growth. "Steady" excludes the first decode step. Upstream is bd66c40 built with the same toolchain (Apple clang 14.0.3, macOS 26.4 SDK) with its automatic cache (3,688 experts); the fork locks 4,600 experts. This is against the pinned commit, not current main; we will re-measure against main next.
| Same machine, same model file | Decode tok/s | Prefill tok/s |
|---|---|---|
| upstream bd66c40, internal SSD | 10.18 | 17.96 |
| fork, internal SSD only | 18.66 | 30.98 |
| fork, plus one NVMe replica over Thunderbolt 5 | 21.05 | 36.88 |
| fork, plus two NVMe replicas | 22.25 | 42.41 |
Upstream is the median of six arms, each fork rung the median of two; ranges stay within 0.2 tok/s. Arms, CSVs and the verification script are in the ladder package.
Candidates, each bit-exact
Router ids through a GPU-written mailbox, shared expert encoded before the commit. A small kernel after the router writes the selected ids, a checksum and a sequence number into a shared buffer. The CPU commits without waiting, polls the mailbox, checks the expert cache and starts the miss reads while the GPU runs the shared expert. It falls back to the blocking readback after 50 ms; the qualification arms recorded 8,000 polls and no fallback. +6.6% steady decode, ABAB, two pairs.
Missing-expert reads from byte-identical replica copies on additional drives, weighted per drive (10:6:6 decode, 10:5:5 prefill here). 18.66 to 22.25 above. This would be a new option such as
--ssd-streaming-replica PATH; without a replica nothing changes. On one SSD it is a no-op, so it is not itemized against upstream.Post-MoE flush and eviction pre-scan. Commit a layer's routed MoE right after it is encoded when the layer waited for expert reads; rank eviction candidates while the CPU waits on the mailbox and re-validate each one at use. +1.5% at pp512/tg512, BAAB (package).
Small fusions that keep the rounding boundaries. A V4.1 single-token router fast path (same 512-wide bitonic selection network and tie rules; other shapes use the original path) plus four small fusions: +2.2 to +2.8% (notes). Three BF16 rounding passes folded into the kernels that produce their inputs, a pointer-keyed pipeline-state cache and a getenv cache: about +1.5% together (notes). Exact-output fixtures exist in the fork.
Read path. Nine persistent reader threads with split reads, the resident experts' down projection overlapped with missing-expert reads, asynchronous Engram row reads, a 32-token hotness decay. This is where most of the single-SSD gain comes from. It is measured against our earlier fork states, not itemized against upstream; we would measure it during the rebase.
Not proposed: the 4,600-expert locked cache (+3% here, machine-specific memory policy), keepalive settings and split ratios.
Question
Which of these, in which order? "None" is a useful answer too; we keep them in the fork.
Source: antirez/ds4