V4.1 Flash support and ~10 t/s Flash Q2 decode on a cheap dual-socket Xeon. Interested in a PR?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- backend, performance
Direzione di ricerca
The proposal describes CPU paths in ds4.c, five new ds4_deepseek41_cpu*.inc files, and their tests; read those files and the correctness and performance checks first. The work is a 184-commit proof of feasibility that still needs cleanup, reviewable commits, and long-context tuning. Done means the maintainers agree on an upstream shape and the resulting changes meet the stated readability and correctness bar.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I forked DS4 and used a coding agent to find out how far its CPU backend can go on Intel x86-64: a V4.1 Flash CPU path plus a performance series for V4 and V4.1, with correctness kept as the first constraint. The result, a working proof of feasibility, is public at https://github.com/10sephus/ds4/tree/cpu-perf-pr (the 184 commits on top of current main: https://github.com/10sephus/ds4/compare/main...cpu-perf-pr). Before polishing it into a PR, I would like to know whether this direction interests you.
Why a CPU box. A 128 GB DGX Spark costs more than €6,000 today, and a 128 GB M5 Max Mac costs more still (about €7,000 as a Mac Studio, €7,700 as a MacBook Pro); neither fits V4.1 Flash Q2 (152 GiB of main weights; its 189 GiB of Engram tables stay on disk) resident in memory on a single box. Refurbished multi-socket Cascade Lake servers with 192 GB of DDR4 hold all 152 GiB resident at a fraction of the price, scale to terabytes of RAM, and reach memory bandwidths from 85% to 2x a single Spark (decode is bandwidth-bound, while the extra AVX-512 cores on 4-socket boxes also scale prefill; I have only measured the 2-socket DDR4-2400 box so far, and the current NUMA pool handles two nodes and turns itself off on more, so a 4-socket R840 would first need it extended to four):
| Platform | Channels & RAM config | Max RAM (slots) | Peak bandwidth | Price, Italy, incl. VAT (Oct 2026) |
|---|---|---|---|---|
| 1× NVIDIA DGX Spark | Unified 128 GB LPDDR5x | 128 GB (fixed, SSD-streamed on V4.1) | 273 GB/s | > €6,000 |
| 2× NVIDIA DGX Spark (RoCE TP) | 2 × 128 GB LPDDR5x | 256 GB (fixed) | 2 × 273 GB/s | > €12,000 |
| Apple M5 Max (Mac Studio / MacBook Pro) | Unified 128 GB | 128 GB (fixed, SSD-streamed on V4.1) | 614 GB/s | ~€7,000 / ~€7,700 |
| 2S Xeon Cascade Lake (Dell R640, measured) | 12 ch DDR4-2400 (12 × 16 GB = 192 GB) | up to 3 TB (24 slots) | 230 GB/s | €1,000–1,500 |
| 2S Xeon Cascade Lake (Dell R640) | 12 ch DDR4-2933 (12 × 16 GB = 192 GB) | up to 3 TB (24 slots) | 282 GB/s | ~€1,300–1,800 |
| 4S Xeon Cascade Lake (Dell R840) | 24 ch DDR4-2933 (24 × 8 GB = 192 GB) | up to 6 TB (48 slots) | 563 GB/s | ~€2,200 |
Measured (dual Xeon Gold 6230, 2x20 cores, DDR4-2400, 40 threads, the starting point at 32, its pool's maximum, --warm-weights, speed-bench/promessi_sposi.txt, greedy; best of several runs on a shared host whose load average varied from 25 to 60 on 80 CPUs), against the numbers in docs/PERFORMANCE.md, docs/DGX_SPARK.md, and QA_BEFORE_RELEASES.md:
| Model, protocol | This CPU path | Start of the series | 1× DGX Spark (128 GB) | 2× DGX Spark (RoCE TP) | M5 Max (128 GB) |
|---|---|---|---|---|---|
| V4 Flash Q2, prefill 2048 tokens | 107 t/s | 1.1 t/s | 826 t/s | 790 t/s | |
| V4 Flash Q2, 128 generated tokens after 2048 | 9.6 t/s | 0.66 t/s | 18.05 t/s | 39.35 t/s | |
| V4 Flash Q2, decode at short context | 10.6 t/s | 1.9 t/s | 19.5–19.7 t/s | 26.0 t/s | |
| V4.1 Flash Q2, prefill 512 tokens (resident) | 50 t/s | 0.43 t/s | 88–100 t/s (SSD, 3.2K prompt) | 209 t/s (1K) / 411 t/s (32K) | |
| V4.1 Flash Q2, decode at short context (resident) | 9.0 t/s | 0.41 t/s | 9.3 t/s (SSD, after a 3.2K prompt) | 21.8 t/s (1K) / 18.0 t/s (32K) |
"Start of the series" is the series' first commit on the same machine: upstream's CPU code plus the V4.1 CPU path, which upstream main does not have. Upstream main itself measured 1.5-1.7 t/s of V4 decode at short context there. Decode is about half of one Spark's at short context on V4 Flash Q2; at long contexts the gap widens, because long-context attention and the indexer are not tuned yet. On V4.1 Flash Q2 it is close to one SSD-streamed Spark's (whose 9.3 t/s comes after a 3.2K prompt), while the Xeon keeps all 152 GiB resident in RAM, at a fraction of the price. Prefill is where the GPU keeps its 8x. A V4 decode token reads 9.5 GB of weights, so the path sits near the box's memory bandwidth.
Correctness. The V4 logits are bitwise identical to the scalar CPU code this replaces, checked after every step with teacher-forced logit dumps (frontiers 16 to 3072). The build passes the correctness checks the Metal and CUDA backends are held to: ds4_test --logprob-vectors against the official DeepSeek continuations (all 5 vectors, zero mismatches) and the local golden vector captured on Metal (top-1 equal, top-20 overlap 20/20), so it produces the same model within floating-point rounding; like any two backends it is not bit-identical to Metal or CUDA, and a long greedy run can pick a different token at a near tie. On the 100 official V4 Flash continuations it scores 0.393 NLL per token with 86.2% greedy top-1 agreement; there is no recorded Metal or CUDA score on that fixture, and I would gladly run the comparison against one. V4.1 Q2 routed experts use the CUDA path's Q8_K activation arithmetic. On the 100 short official V4.1 continuations in gguf-tools/quality-testing they score 0.421 NLL per token with 90.0% API top-1 agreement: within 0.001 of the Metal scores shipped with that fixture (from a Q2 GGUF of the same size), and -0.0006 (CI includes 0) from this branch's exact F32-activation path. Every kernel has a scalar oracle in the unit tests (gcc and clang, AVX-512, AVX2-only and scalar builds).
Shape. 184 commits, +16.6k / -2.4k lines: +6.4k / -2.4k in ds4.c's CPU paths, five new ds4_deepseek41_cpu*.inc files (4.2k lines) and 5.8k lines of tests; 43 of the commits record their own before/after measurement. Vision, speculative decoding and SSD expert streaming are not implemented for --cpu.
What still needs work before a PR. This is a proof of feasibility: it works and it is verified, but it is not shaped for upstream yet, and I know it needs a polishing pass:
- leftover code from earlier iterations, and a few small fixes found in review;
- tests that can be shorter, and a history to squash or split into reviewable pieces;
- long contexts: long-context attention and the indexer are not tuned yet, so decode and prefill slow down with context much more than on the GPUs;
- it is tuned and measured on one Cascade Lake host only: the Metal and CUDA builds compile, but I have not run them on a Mac or a Spark.
Given the README's point that the project is a working template rather than a cover of every setup, I see three options and would follow your preference:
- one PR with the whole series, squashed into a few logical commits if you prefer;
- a sequence of PRs: the V4.1 CPU port with its tests first, then the x86 kernels, the scheduling and the NUMA placement as separately reviewable and separately measured pieces;
- no upstream merge: I keep it as a public branch that other CPU users can take from.
If you are interested, I will fix the points above and polish the code to the bar AGENT.md sets (small, readable, no leftover code), in whichever shape you prefer.
- Lingua principale
- C
- Stelle
- 24.4k
- Fork
- 2.4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di antirez/ds4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
antirez/ds4#1189 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
antirez/ds4#1173 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
antirez/ds4#1032 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
DBMS_UTILITY.FORMAT_ERROR_STACK exceeds the 2000-byte limitForse già presa @coder999o l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
CI: LFC/ANTLR caches still use the old lfc/ paths, so the ANTLR jar is downloaded on every runForse già presa @NicoBiernat l’ha presa oggi. Apertabug CI
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
lf-lang/reactor-uc#443 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jeremyevans/aqualung#67 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
ly05010419/MacNativeGames#2442 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Life-Framework/Life-Framework#5378 ·
I maintainer di solito rispondono entro 1 giorno