[PR #3589] [Engine] DeepSeek V4-Flash (deepseek4) as a second model family #4702

Open
opened 2026-11-07 15:38:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3589
Author: @JUNQINGV587
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: dsv4-mvp-rebase


📝 Commits (10+)

  • 93e79b4 dsv4: DeepSeek V4-Flash (deepseek4) as a second model family
  • 610761b dsv4: pay the prefill pass's phase bill where it is spent (attn classes, MoE host/GPU/cold-io split)
  • 5b760ea dsv4: stream the prefill's missing expert blobs from a pinned read-ahead pool (1.49x on 128 tokens)
  • 41b903a [Engine] dsv4: --dsv4-prefill-chunk W prefills a long prompt as W-row passes in one process
  • 3a1c2f6 [Engine] dsv4: chunked prefill is bit-identical to the single pass
  • 1b6c7dc [Engine] dsv4: size a chunked prefill's workspace by the chunk, not the prompt
  • 05f35af [Engine] dsv4: STRATA_DSV4_PFTIME host-path sub-phase counters
  • 7a97528 [Engine] dsv4: global heat eviction for the expert cache (4k prefill +15%)
  • 7529b45 [Engine] dsv4: issue the predictive expert read-ahead at the layer head
  • 7c40fd3 [Engine] dsv4: account attention GPU time per launch category (M1)

📊 Changes

34 files changed (+15376 additions, -8 deletions)

View changed files

📝 CMakeLists.txt (+45 -1)
➕ docs/DSV4.md (+96 -0)
📝 include/strata/artifact/gguf_reader.hpp (+166 -0)
📝 include/strata/artifact/model_family.hpp (+12 -1)
📝 include/strata/core/expert_cache.hpp (+17 -0)
➕ include/strata/dsv4/attn.hpp (+169 -0)
➕ include/strata/dsv4/comp.hpp (+188 -0)
➕ include/strata/dsv4/engine.hpp (+14 -0)
➕ include/strata/dsv4/geometry.hpp (+84 -0)
➕ include/strata/dsv4/layout.hpp (+294 -0)
📝 include/strata/kernels/cpu/expert_layout.hpp (+5 -0)
📝 include/strata/kernels/cpu/native_expert.hpp (+7 -4)
📝 src/core/expert_source.cpp (+12 -0)
➕ src/dsv4/dsv4_attn.cu (+1317 -0)
➕ src/dsv4/dsv4_attn_test.cpp (+510 -0)
➕ src/dsv4/dsv4_attn_time.h (+157 -0)
➕ src/dsv4/dsv4_comp.cu (+1621 -0)
➕ src/dsv4/dsv4_comp_test.cpp (+485 -0)
➕ src/dsv4/dsv4_engine.cu (+1715 -0)
➕ src/dsv4/dsv4_main.cpp (+5 -0)

...and 14 more files

📄 Description

Problem

A DeepSeek V4-Flash checkpoint cannot be loaded at all today: gguf_reader.hpp accepts only qwen4exp, so
the file is rejected before anything else happens. The model differs from Qwen3.8-Flash-Next in the parts
that decide the engine's shape — hash routing on the first layers, MLA attention with a 128 window plus
compressed slots picked by the DSA indexer, 256 experts top-6 on a 4096 hidden / 2048 intermediate geometry —
so it needs its own loader, geometry and kernels rather than a new branch in the Qwen path.

Issue: #479 (V4-Flash support request). This follows the reopen instructions from #1518 being closed by the
0.2.0-beta tracker reset: it is rebased onto main (011c9e60), its checks were re-run on this tree, and the
title carries the area prefix.

What this adds

A second model family, additive to the default path:

  • src/dsv4/ — engine, MoE path, attention + compressor kernels, and a CPU reference forward
    (dsv4ref.cpp, binary strata-dsv4ref) that the engine's dumps are compared against.
  • include/strata/dsv4/ — geometry, layout, attention/compressor interfaces.
  • generate.cpp — one switch (STRATA_HAVE_DSV4) that reads the GGUF header's architecture and hands
    deepseek4 files to dsv4::run; strata-dsv4 is the same entry point on its own command line.
  • tools/nvfp4_convert_dsv4.py — conversion through the pinned llama.cpp (it already knows deepseek4 and
    writes compress_ratios; the script patches the ModelOpt NVFP4 naming and merges per-expert tensors).
    tools/iq_pack.py packs the result as usual; the pack format is unchanged (36-byte NVFP4 blobs).
  • docs/DSV4.md — what is supported, the conversion commands, and the limits.

The Qwen gate and its kernels are untouched. The only shared-file edits are the family switch, two widened
activation constants in native_expert.hpp for the wider V4 geometry, and one extra overload in
expert_layout.hpp; all three keep the Qwen path's behaviour.

Limits (deliberate)

  • No MTP/DSpark draft head. Measured on this pool: the block verify costs c(5) ≈ 2.76 forwards per
    round for ~2.4 accepted tokens, and the draft layer is another 2.7-10.9 GiB of resident experts.
  • v5 (Hadamard-folded) packs are refused at start-up — the CPU native path rotates activations, this
    engine's CUDA GEMV does not, so such a pack would silently compute wrong numbers.
  • Context capped at 65536 (compressor slots are sized from ctx/128); prompts longer than the 128-token
    window are prefill-chunked by the caller.
  • NVFP4 only; IQ2/IQ4 packs of this family are not converted or tested.

Validation

Environment: this branch on 011c9e60, containers with CUDA 13.0.2, sm_89 (2×L20, 96 GiB VRAM, 125 GiB RAM),
Release build, model DeepSeek-V4-Flash-0731-NVFP4 (164 GB GGUF → 145.13 GiB expert pool, 57.5 % resident).

Passed (commands and logs available on request; dumps are compared file by file):

check result
golden prompts, prefill argmax + 3 decode steps vs CPU reference MATCH (9544 / 734 / 260 / 4654)
multi-row verify R=2..6 vs single-row decode, dumps 0 files differ (bit-identical)
long context, start_pos=130, window wrapped 0 files differ
compute-sanitizer --tool memcheck 0 errors
Qwen3.8-Flash-Next NVFP4 on the same binary 109.24 / 96.99 / 116.94 t/s (this box's band: 88.5-117.1)

Throughput on the same machine: ~30 t/s for one decode stream (33 ms/pass), ~47 t/s with six rows in one
forward (127 ms/pass).

Not run: GPUs other than sm_89 (no sm_120/HIP/SYCL), Windows, single-GPU 24 GB, IQ2/IQ4 packs, MTP.

Size

~11 k lines, mostly new files under src/dsv4 (dsv4_moe.cu 2051, dsv4ref.cpp 1575, dsv4_comp.cu
1193, dsv4_attn.cu 1119). Happy to split it into loader/geometry, attention and MoE PRs if that is
easier to review.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3589 **Author:** [@JUNQINGV587](https://github.com/JUNQINGV587) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `dsv4-mvp-rebase` --- ### 📝 Commits (10+) - [`93e79b4`](https://github.com/Niko1221/Strata/commit/93e79b4e79861b364b8dac0dbc002dc56d391f1f) dsv4: DeepSeek V4-Flash (deepseek4) as a second model family - [`610761b`](https://github.com/Niko1221/Strata/commit/610761bb8ebedc5015fae24c9b8d7249c4bcd97b) dsv4: pay the prefill pass's phase bill where it is spent (attn classes, MoE host/GPU/cold-io split) - [`5b760ea`](https://github.com/Niko1221/Strata/commit/5b760ea7b90e3a1c3d10b87dcac1ceb4a5df3bd7) dsv4: stream the prefill's missing expert blobs from a pinned read-ahead pool (1.49x on 128 tokens) - [`41b903a`](https://github.com/Niko1221/Strata/commit/41b903a2497b9d7653ee08fa8ff3d9f427862cd4) [Engine] dsv4: --dsv4-prefill-chunk W prefills a long prompt as W-row passes in one process - [`3a1c2f6`](https://github.com/Niko1221/Strata/commit/3a1c2f6e2a8581a371670cdfc2030386c9042062) [Engine] dsv4: chunked prefill is bit-identical to the single pass - [`1b6c7dc`](https://github.com/Niko1221/Strata/commit/1b6c7dc67acc65501eb110c59a58534c5efef8ec) [Engine] dsv4: size a chunked prefill's workspace by the chunk, not the prompt - [`05f35af`](https://github.com/Niko1221/Strata/commit/05f35af0612a39d22382014b85f3a0442b62a6e6) [Engine] dsv4: STRATA_DSV4_PFTIME host-path sub-phase counters - [`7a97528`](https://github.com/Niko1221/Strata/commit/7a9752882839d80fddd9153149fc48c84e771c47) [Engine] dsv4: global heat eviction for the expert cache (4k prefill +15%) - [`7529b45`](https://github.com/Niko1221/Strata/commit/7529b4501e2e848c68eb8cc6d3cad98ac3e71ed0) [Engine] dsv4: issue the predictive expert read-ahead at the layer head - [`7c40fd3`](https://github.com/Niko1221/Strata/commit/7c40fd37c0c06775cf0a7f0ce5e565fc853396bc) [Engine] dsv4: account attention GPU time per launch category (M1) ### 📊 Changes **34 files changed** (+15376 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+45 -1) ➕ `docs/DSV4.md` (+96 -0) 📝 `include/strata/artifact/gguf_reader.hpp` (+166 -0) 📝 `include/strata/artifact/model_family.hpp` (+12 -1) 📝 `include/strata/core/expert_cache.hpp` (+17 -0) ➕ `include/strata/dsv4/attn.hpp` (+169 -0) ➕ `include/strata/dsv4/comp.hpp` (+188 -0) ➕ `include/strata/dsv4/engine.hpp` (+14 -0) ➕ `include/strata/dsv4/geometry.hpp` (+84 -0) ➕ `include/strata/dsv4/layout.hpp` (+294 -0) 📝 `include/strata/kernels/cpu/expert_layout.hpp` (+5 -0) 📝 `include/strata/kernels/cpu/native_expert.hpp` (+7 -4) 📝 `src/core/expert_source.cpp` (+12 -0) ➕ `src/dsv4/dsv4_attn.cu` (+1317 -0) ➕ `src/dsv4/dsv4_attn_test.cpp` (+510 -0) ➕ `src/dsv4/dsv4_attn_time.h` (+157 -0) ➕ `src/dsv4/dsv4_comp.cu` (+1621 -0) ➕ `src/dsv4/dsv4_comp_test.cpp` (+485 -0) ➕ `src/dsv4/dsv4_engine.cu` (+1715 -0) ➕ `src/dsv4/dsv4_main.cpp` (+5 -0) _...and 14 more files_ </details> ### 📄 Description ## Problem A DeepSeek V4-Flash checkpoint cannot be loaded at all today: `gguf_reader.hpp` accepts only `qwen4exp`, so the file is rejected before anything else happens. The model differs from Qwen3.8-Flash-Next in the parts that decide the engine's shape — hash routing on the first layers, MLA attention with a 128 window plus compressed slots picked by the DSA indexer, 256 experts top-6 on a 4096 hidden / 2048 intermediate geometry — so it needs its own loader, geometry and kernels rather than a new branch in the Qwen path. Issue: #479 (V4-Flash support request). This follows the reopen instructions from #1518 being closed by the 0.2.0-beta tracker reset: it is rebased onto `main` (`011c9e60`), its checks were re-run on this tree, and the title carries the area prefix. ## What this adds A second model family, **additive to the default path**: - `src/dsv4/` — engine, MoE path, attention + compressor kernels, and a CPU reference forward (`dsv4ref.cpp`, binary `strata-dsv4ref`) that the engine's dumps are compared against. - `include/strata/dsv4/` — geometry, layout, attention/compressor interfaces. - `generate.cpp` — one switch (`STRATA_HAVE_DSV4`) that reads the GGUF header's architecture and hands `deepseek4` files to `dsv4::run`; `strata-dsv4` is the same entry point on its own command line. - `tools/nvfp4_convert_dsv4.py` — conversion through the pinned llama.cpp (it already knows `deepseek4` and writes `compress_ratios`; the script patches the ModelOpt NVFP4 naming and merges per-expert tensors). `tools/iq_pack.py` packs the result as usual; the pack format is unchanged (36-byte NVFP4 blobs). - `docs/DSV4.md` — what is supported, the conversion commands, and the limits. The Qwen gate and its kernels are untouched. The only shared-file edits are the family switch, two widened activation constants in `native_expert.hpp` for the wider V4 geometry, and one extra overload in `expert_layout.hpp`; all three keep the Qwen path's behaviour. ## Limits (deliberate) - **No MTP/DSpark draft head.** Measured on this pool: the block verify costs `c(5) ≈ 2.76` forwards per round for ~2.4 accepted tokens, and the draft layer is another 2.7-10.9 GiB of resident experts. - **v5 (Hadamard-folded) packs are refused at start-up** — the CPU native path rotates activations, this engine's CUDA GEMV does not, so such a pack would silently compute wrong numbers. - Context capped at 65536 (compressor slots are sized from `ctx/128`); prompts longer than the 128-token window are prefill-chunked by the caller. - NVFP4 only; IQ2/IQ4 packs of this family are not converted or tested. ## Validation Environment: this branch on `011c9e60`, containers with CUDA 13.0.2, sm_89 (2×L20, 96 GiB VRAM, 125 GiB RAM), Release build, model `DeepSeek-V4-Flash-0731-NVFP4` (164 GB GGUF → 145.13 GiB expert pool, 57.5 % resident). Passed (commands and logs available on request; dumps are compared file by file): | check | result | |---|---| | golden prompts, prefill argmax + 3 decode steps vs CPU reference | MATCH (9544 / 734 / 260 / 4654) | | multi-row verify R=2..6 vs single-row decode, dumps | 0 files differ (bit-identical) | | long context, start_pos=130, window wrapped | 0 files differ | | `compute-sanitizer --tool memcheck` | 0 errors | | Qwen3.8-Flash-Next NVFP4 on the same binary | 109.24 / 96.99 / 116.94 t/s (this box's band: 88.5-117.1) | Throughput on the same machine: ~30 t/s for one decode stream (33 ms/pass), ~47 t/s with six rows in one forward (127 ms/pass). Not run: GPUs other than sm_89 (no sm_120/HIP/SYCL), Windows, single-GPU 24 GB, IQ2/IQ4 packs, MTP. ## Size ~11 k lines, mostly new files under `src/dsv4` (`dsv4_moe.cu` 2051, `dsv4ref.cpp` 1575, `dsv4_comp.cu` 1193, `dsv4_attn.cu` 1119). Happy to split it into loader/geometry, attention and MoE PRs if that is easier to review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4702
No description provided.