[PR #530] [CLOSED] DeepSeek: opt-in full zero-copy routes and no CPU wait #585

Closed
opened 2026-10-29 21:27:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/530
Author: @handmade0octopus
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: pr/ds4-zc-all


📝 Commits (1)

  • 51f5be8 DeepSeek: opt-in full zero-copy routes and no CPU wait

📊 Changes

5 files changed (+125 additions, -22 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 docs/SETTINGS.md (+2 -0)
📝 src/ds4/ds4_model.cu (+69 -22)
📝 src/ds4/ds4_pcie.hpp (+15 -0)
➕ tests/ds4_pcie_test.cpp (+37 -0)

📄 Description

Summary

Add two opt-in DeepSeek decode settings for experts with pinned, device-readable RAM copies:

  • DS4_STREAM_ZC_ALL: an ordinary one-token route whose non-VRAM picks all have pinned copies streams the whole route instead of using the measured partial split.
  • DS4_STREAM_ZC_NOWAIT: when every possible non-VRAM expert in such a layer is pinned, skip the empty CPU response and its wait.

The baseline PCIe-lane allocation and expert placement happen first and are never overridden by these settings. The experiment becomes active only after a real pinned copy exists. Persisted device lane=off, DS4_STREAM_ZC=0, no RAM copy, zero pinning, forced routing, and stream-hold mode therefore retain the original behavior. A host-side regression test covers those gates.

DSpark T > 1 verify windows keep their original, separate eligibility. Uncovered routes and the whole-step CPU-only/fallback A/B arms stay on the original path. Both settings are off by default; neither skips an expert or route nor adds an approximation.

Motivation

On Windows with pinned expert copies, the measured lane split can leave ordinary one-token routes partially on the CPU even when every pick is device-readable. Full pinned coverage lets the existing zero-copy path serve that route without staged reads. Once the whole layer is covered, there is no CPU result for that arm to wait for.

Measurements

Test system: Windows 11, RTX 4090 D 48 GiB, Ryzen 5 3600, 128 GiB RAM; DeepSeek-V4.1-Flash IQ1_M.

Fresh engine per run, matched greedy code/prose prompts, 384 generated tokens per prompt, frozen learned inputs, and engine-reported decode timing. Each control and candidate used the same binary, with only the candidate setting toggled, avoiding recalibration from the binary-timestamped lane-calibration key. The first non-DSpark prompt includes whole-step A/B warm-up; the second is the steady measurement.

DSpark mode Same-build control code / prose ZC-all code / prose ZC-all + no-wait code / prose
none 19.37 / 23.77 t/s 19.97 / 24.90 t/s 19.99 / 25.16 t/s
on 30.08 / 28.95 t/s 37.23 / 32.47 t/s 38.01 / 32.44 t/s

Mean code/prose throughput changes from the same-build control:

  • ZC-all: +4.0% non-DSpark, +18.1% DSpark-on.
  • Full candidate: +4.7% non-DSpark, +19.4% DSpark-on.

Separate fresh-engine sustained runs of the full candidate generated 1,024 tokens for each of code and prose: 22.59 / 24.46 t/s non-DSpark and 36.01 / 33.06 t/s DSpark-on. Both parent-pipe/QUIT shutdowns exited cleanly with no engine left behind. These are single-machine opt-in results, not a claim for every GPU, quant, or pinning layout.

Correctness and fallback coverage

  • Full-mask routing requires per-pick zc_ok; no-wait uses the stronger layer-wide coverage predicate because the device decides before the host returns the route mask.
  • No-wait rejects forced routing, whole-step CPU A/B, helpers, tensor-parallel/drafter layers, and disk/RAM skip policies. DS4_STREAM_ZC_NOWAIT=1 alone does not imply or widen ZC-all.
  • Full-pin non-DSpark code and prose outputs were byte-identical with no-wait off/on. Deterministic partial-pin parity passed with no-wait active, nonzero CPU fallback, identical calibration files, and no online re-timing. Forced-CPU outputs matched exactly.
  • Partial-pin lane-output, landing, recent-slot, and RAM-swap byte checks passed. Ordinary and DSpark sustained runs completed without request, CUDA, mismatch, or shutdown failures.
  • No output-identical claim is made against the route-split control: moving experts between the existing CPU and GPU arithmetic can change last bits and therefore later greedy tokens. The adaptive timing mismatch observed in one partial-pin prose probe is retained in the local validation record; the frozen-calibration probe is the parity gate.
  • The new ds4_pcie_test covers persisted lane=off, no/zero/partial pinned slots, ZC disabled, forced routing, and hold mode. It needs neither a GPU nor a model.
  • On the clean upstream v1.1.29 (8b4b39f) branch: Windows CUDA build, ds4_pcie_test, HIP name-compatibility scan, git diff --check, and 133 server/DS4-conformance tests (3 platform skips).
  • Linux, AMD, and multi-GPU runtime behavior were not measured; the settings remain opt-in. The real-engine campaign validated the isolated source delta; the clean PR binary was not direct-engine retested because the healthy production engine was left running.

Relation to #495

#495's device self-answer is complementary but does not remove this wait for the target routes. Its cpu_any is computed from non-VRAM routing before the host split. A route whose non-VRAM picks are subsequently all streamed still has cpu_any=1, so #495 does not generate the empty response for it.

This PR's no-wait is intentionally narrower: it requires layer-wide pinned coverage and preserves the original response/wait for every fallback or mixed route. It is therefore included rather than relying on #495's pre-split flag.


🔄 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/mw00/project-maya/pull/530 **Author:** [@handmade0octopus](https://github.com/handmade0octopus) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/ds4-zc-all` --- ### 📝 Commits (1) - [`51f5be8`](https://github.com/mw00/project-maya/commit/51f5be84543e7d6113798c550c1fc70f59ad16fc) DeepSeek: opt-in full zero-copy routes and no CPU wait ### 📊 Changes **5 files changed** (+125 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `docs/SETTINGS.md` (+2 -0) 📝 `src/ds4/ds4_model.cu` (+69 -22) 📝 `src/ds4/ds4_pcie.hpp` (+15 -0) ➕ `tests/ds4_pcie_test.cpp` (+37 -0) </details> ### 📄 Description ## Summary Add two opt-in DeepSeek decode settings for experts with pinned, device-readable RAM copies: - `DS4_STREAM_ZC_ALL`: an ordinary one-token route whose non-VRAM picks all have pinned copies streams the whole route instead of using the measured partial split. - `DS4_STREAM_ZC_NOWAIT`: when **every possible non-VRAM expert in such a layer** is pinned, skip the empty CPU response and its wait. The baseline PCIe-lane allocation and expert placement happen first and are never overridden by these settings. The experiment becomes active only after a real pinned copy exists. Persisted device `lane=off`, `DS4_STREAM_ZC=0`, no RAM copy, zero pinning, forced routing, and stream-hold mode therefore retain the original behavior. A host-side regression test covers those gates. DSpark `T > 1` verify windows keep their original, separate eligibility. Uncovered routes and the whole-step CPU-only/fallback A/B arms stay on the original path. Both settings are **off by default**; neither skips an expert or route nor adds an approximation. ## Motivation On Windows with pinned expert copies, the measured lane split can leave ordinary one-token routes partially on the CPU even when every pick is device-readable. Full pinned coverage lets the existing zero-copy path serve that route without staged reads. Once the whole layer is covered, there is no CPU result for that arm to wait for. ## Measurements Test system: Windows 11, RTX 4090 D 48 GiB, Ryzen 5 3600, 128 GiB RAM; DeepSeek-V4.1-Flash IQ1_M. Fresh engine per run, matched greedy code/prose prompts, 384 generated tokens per prompt, frozen learned inputs, and engine-reported decode timing. Each control and candidate used the **same binary**, with only the candidate setting toggled, avoiding recalibration from the binary-timestamped lane-calibration key. The first non-DSpark prompt includes whole-step A/B warm-up; the second is the steady measurement. | DSpark mode | Same-build control code / prose | `ZC-all` code / prose | `ZC-all + no-wait` code / prose | | --- | ---: | ---: | ---: | | `none` | 19.37 / 23.77 t/s | 19.97 / 24.90 t/s | **19.99 / 25.16 t/s** | | `on` | 30.08 / 28.95 t/s | 37.23 / 32.47 t/s | **38.01 / 32.44 t/s** | Mean code/prose throughput changes from the same-build control: - `ZC-all`: **+4.0%** non-DSpark, **+18.1%** DSpark-on. - Full candidate: **+4.7%** non-DSpark, **+19.4%** DSpark-on. Separate fresh-engine sustained runs of the full candidate generated 1,024 tokens for each of code and prose: **22.59 / 24.46 t/s** non-DSpark and **36.01 / 33.06 t/s** DSpark-on. Both parent-pipe/QUIT shutdowns exited cleanly with no engine left behind. These are single-machine opt-in results, not a claim for every GPU, quant, or pinning layout. ## Correctness and fallback coverage - Full-mask routing requires per-pick `zc_ok`; no-wait uses the stronger layer-wide coverage predicate because the device decides before the host returns the route mask. - No-wait rejects forced routing, whole-step CPU A/B, helpers, tensor-parallel/drafter layers, and disk/RAM skip policies. `DS4_STREAM_ZC_NOWAIT=1` alone does not imply or widen ZC-all. - Full-pin non-DSpark code and prose outputs were byte-identical with no-wait off/on. Deterministic partial-pin parity passed with no-wait active, nonzero CPU fallback, identical calibration files, and no online re-timing. Forced-CPU outputs matched exactly. - Partial-pin lane-output, landing, recent-slot, and RAM-swap byte checks passed. Ordinary and DSpark sustained runs completed without request, CUDA, mismatch, or shutdown failures. - No output-identical claim is made against the route-split control: moving experts between the existing CPU and GPU arithmetic can change last bits and therefore later greedy tokens. The adaptive timing mismatch observed in one partial-pin prose probe is retained in the local validation record; the frozen-calibration probe is the parity gate. - The new `ds4_pcie_test` covers persisted `lane=off`, no/zero/partial pinned slots, ZC disabled, forced routing, and hold mode. It needs neither a GPU nor a model. - On the clean upstream v1.1.29 (`8b4b39f`) branch: Windows CUDA build, `ds4_pcie_test`, HIP name-compatibility scan, `git diff --check`, and **133 server/DS4-conformance tests** (3 platform skips). - Linux, AMD, and multi-GPU runtime behavior were not measured; the settings remain opt-in. The real-engine campaign validated the isolated source delta; the clean PR binary was not direct-engine retested because the healthy production engine was left running. ## Relation to #495 #495's device self-answer is complementary but does not remove this wait for the target routes. Its `cpu_any` is computed from non-VRAM routing **before** the host split. A route whose non-VRAM picks are subsequently all streamed still has `cpu_any=1`, so #495 does not generate the empty response for it. This PR's no-wait is intentionally narrower: it requires layer-wide pinned coverage and preserves the original response/wait for every fallback or mixed route. It is therefore included rather than relying on #495's pre-split flag. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:27:11 +07:00
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#585
No description provided.