[PR #622] ds4 DSpark: the drafter head, markov steps and confidences only for the rows the round cut can keep (DS4_DSPARK_LAZY=0: all) #630

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/622
Author: @SeriousRising
Created: 10/28/2026
Status: 🔄 Open

Base: main ← Head: ds4-lazy-draft-head


📝 Commits (1)

  • aed24df ds4 DSpark: the drafter head, markov steps and confidences only for the rows the round cut can keep (DS4_DSPARK_LAZY=0: all)

📊 Changes

4 files changed (+97 additions, -38 deletions)

View changed files

📝 docs/SETTINGS.md (+1 -0)
📝 src/ds4/ds4_main.cpp (+7 -3)
📝 src/ds4/ds4_model.cu (+83 -34)
📝 src/ds4/ds4_model.hpp (+6 -1)

📄 Description

What. Today draft_() (src/ds4/ds4_model.cu:13792, v1.1.35) runs the trunk's head over all 5 rows of the DSpark block, then 5 markov + argmax steps, then the confidence head for all 5 (:13979), and round() (src/ds4/ds4_main.cpp:273) throws away everything after the first cut confidence. In chat most rounds keep 0-2 drafts, so most of that head work (a 129280 x 5120 GEMV a row) is thrown away.

With this PR, when the head is on one device (no TP head group, no DS4_DSPARK_DUMP), draft_() works in up to three stages and evaluates round()'s own cut on the host after each:

  1. confidence 0 only (it reads x_0 and y); if the first draft is cut, no head row runs at all;
  2. head rows 0-1, drafts 0-1, confidences 1-2;
  3. the remaining rows up to min(block, DS4_DSPARK_MAX, room - 1).

A stage runs only if every confidence so far passed. The host test is round()'s, with the same float operations in the same order (h_w[k] >= conf_min && (cum *= h_w[k]) >= cum_min). Model::draft() gets max_n, conf_min, cum_min and min_n; with the defaults (0) nothing is cut, so other callers keep the old behaviour.

Prompt lookup: round() compares the lookup proposal with drafts[0] even when the drafter's first draft is cut, so the proposal is now made before draft(), and when there is one min_n = 1 makes the lazy head produce row 0 anyway. propose() only reads the suffix table, so moving it earlier changes nothing.

Setting: DS4_DSPARK_LAZY (read like DS4_DSPARK_MAX / DS4_DSPARK_DUMP), on by default because it gives the same drafts and is measured faster (below); DS4_DSPARK_LAZY=0 = the full head, as before. A row in docs/SETTINGS.md.

Output: unchanged (same drafts, same tokens):

  • confidence_kernel is one block per row and reads only x_t and tok[t]; markov_add and sample_tokens / sample_draft run per row exactly as before.
  • The GGUF head GEMV (mv_kernel<kQ5_K, NC> on this pack) computes each column with the same lanes, order and warp_sum whatever the launch's column count; only the 4 + 1 split of rows into launches becomes 2 + up to 3.
  • round() keeps the same count: the cut stops at the first failing confidence, at room - 1, or at the block.

Measured. 2x NVIDIA CMP 170HX 64 GB (GA100, sm_80, CUDA 12.8; card 0 PCIe Gen2 x16, card 1 Gen2 x4: a mining card's link, platform-specific), 16-vCPU Xeon E5-2697 v4 VM, 106 GiB RAM. DeepSeek-V4.1-Flash-1017 GSQ-RCO IQ2_XXS, layer split CUDA0 [0,20) / CUDA1 [20,40) + head, --tp 1 --gpus 0,1 --dspark on --cpu-threads 14.

The maya-ds4 CLI on this branch, 2000 fixed prompt ids + 256 greedy tokens, --suffix-draft 0, one binary, one run each (a quick check):

v1.1.35 DS4_DSPARK_LAZY=0 default (lazy)
token ids (reference) = v1.1.35 = v1.1.35
DSpark rounds / offered / accepted, per-position counts 80 / 194 / 175 = v1.1.35 = v1.1.35
drafting, ms a round 6.28 6.27 5.38 (-14 %)
decode tok/s 40.68 40.69 41.13 (+1.1 %)

With prompt lookup on (--suffix-draft 3, and DS4_ASYNC_T=16 from #608 so that a lookup window's rows do not depend on its size), =0 and default give the same 256 ids (20 / 21 lookup rounds: the lookup's window choice follows wall-clock round times).

Earlier, through the server on our v1.1.29-based fork (its other patches the same in both arms; 5 prompts x 512 tokens, temperature 0, thinking off; ms a verify window from the engine's timer; two repeats): lazy off 46.33 / 46.36 ms, 41.96 / 41.93 tok/s; lazy on 44.87 / 44.87 ms (-3.2 %), 43.32 / 43.32 tok/s; the same text hashes. The drafter there was 6.32 -> 5.40 ms a pass (5.00 -> 3.57 head rows a pass). Most of the saving is the head GEMV of rows the cut never keeps: the Q5_K head on dp4a costs ~0.68 ms a row on a CMP 170HX. Any single-device head should gain where the head GEMV is a visible share of a drafter pass; not measured on other GPUs. A TP head group / mk_split is unchanged (the lazy path is skipped).

Costs and limits.

  • One extra D2H + sync (~30 µs) a drafter pass, and a third on passes that keep >= 2 drafts (~61 % of passes above); a net saving, as measured.
  • Not exercised: an EXL3 head (fmt != 0, split-K partials); the per-column argument was checked for the GGUF GEMV only. DS4_DSPARK_LAZY=0 is the escape.
  • Not separately tested: DS4_DSPARK_SAMPLE=1 at temperature > 0 (rows are drawn with the same per-row counter, so the draws should be the same).
  • ds4_gguf_test (full suite): ALL OK.

Checks (as .github/workflows/tests.yml): tools/check_hip_compat.py OK; server tests 463 OK (12 skipped); installer and tools tests 584 OK (31 skipped) - the same counts as v1.1.35.

🤖 Generated with Claude Code


🔄 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/622 **Author:** [@SeriousRising](https://github.com/SeriousRising) **Created:** 10/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ds4-lazy-draft-head` --- ### 📝 Commits (1) - [`aed24df`](https://github.com/mw00/project-maya/commit/aed24df272c0f7f532b15edca2f796b9b6e5e29d) ds4 DSpark: the drafter head, markov steps and confidences only for the rows the round cut can keep (DS4_DSPARK_LAZY=0: all) ### 📊 Changes **4 files changed** (+97 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/ds4/ds4_main.cpp` (+7 -3) 📝 `src/ds4/ds4_model.cu` (+83 -34) 📝 `src/ds4/ds4_model.hpp` (+6 -1) </details> ### 📄 Description **What.** Today `draft_()` (`src/ds4/ds4_model.cu:13792`, v1.1.35) runs the trunk's head over all 5 rows of the DSpark block, then 5 markov + argmax steps, then the confidence head for all 5 (`:13979`), and `round()` (`src/ds4/ds4_main.cpp:273`) throws away everything after the first cut confidence. In chat most rounds keep 0-2 drafts, so most of that head work (a 129280 x 5120 GEMV a row) is thrown away. With this PR, when the head is on one device (no TP head group, no `DS4_DSPARK_DUMP`), `draft_()` works in up to three stages and evaluates `round()`'s own cut on the host after each: 1. confidence 0 only (it reads `x_0` and `y`); if the first draft is cut, no head row runs at all; 2. head rows 0-1, drafts 0-1, confidences 1-2; 3. the remaining rows up to `min(block, DS4_DSPARK_MAX, room - 1)`. A stage runs only if every confidence so far passed. The host test is `round()`'s, with the same float operations in the same order (`h_w[k] >= conf_min && (cum *= h_w[k]) >= cum_min`). `Model::draft()` gets `max_n`, `conf_min`, `cum_min` and `min_n`; with the defaults (0) nothing is cut, so other callers keep the old behaviour. Prompt lookup: `round()` compares the lookup proposal with `drafts[0]` even when the drafter's first draft is cut, so the proposal is now made before `draft()`, and when there is one `min_n = 1` makes the lazy head produce row 0 anyway. `propose()` only reads the suffix table, so moving it earlier changes nothing. **Setting:** `DS4_DSPARK_LAZY` (read like `DS4_DSPARK_MAX` / `DS4_DSPARK_DUMP`), on by default because it gives the same drafts and is measured faster (below); `DS4_DSPARK_LAZY=0` = the full head, as before. A row in `docs/SETTINGS.md`. **Output: unchanged** (same drafts, same tokens): - `confidence_kernel` is one block per row and reads only `x_t` and `tok[t]`; `markov_add` and `sample_tokens` / `sample_draft` run per row exactly as before. - The GGUF head GEMV (`mv_kernel<kQ5_K, NC>` on this pack) computes each column with the same lanes, order and `warp_sum` whatever the launch's column count; only the 4 + 1 split of rows into launches becomes 2 + up to 3. - `round()` keeps the same count: the cut stops at the first failing confidence, at `room - 1`, or at the block. **Measured.** 2x NVIDIA CMP 170HX 64 GB (GA100, sm_80, CUDA 12.8; card 0 PCIe Gen2 x16, card 1 Gen2 x4: a mining card's link, platform-specific), 16-vCPU Xeon E5-2697 v4 VM, 106 GiB RAM. DeepSeek-V4.1-Flash-1017 GSQ-RCO IQ2_XXS, layer split CUDA0 [0,20) / CUDA1 [20,40) + head, `--tp 1 --gpus 0,1 --dspark on --cpu-threads 14`. The `maya-ds4` CLI on this branch, 2000 fixed prompt ids + 256 greedy tokens, `--suffix-draft 0`, one binary, one run each (a quick check): | | v1.1.35 | `DS4_DSPARK_LAZY=0` | default (lazy) | |---|---|---|---| | token ids | (reference) | = v1.1.35 | = v1.1.35 | | DSpark rounds / offered / accepted, per-position counts | 80 / 194 / 175 | = v1.1.35 | = v1.1.35 | | drafting, ms a round | 6.28 | 6.27 | **5.38 (-14 %)** | | decode tok/s | 40.68 | 40.69 | 41.13 (+1.1 %) | With prompt lookup on (`--suffix-draft 3`, and `DS4_ASYNC_T=16` from #608 so that a lookup window's rows do not depend on its size), `=0` and default give the same 256 ids (20 / 21 lookup rounds: the lookup's window choice follows wall-clock round times). Earlier, through the server on our v1.1.29-based fork (its other patches the same in both arms; 5 prompts x 512 tokens, temperature 0, thinking off; ms a verify window from the engine's timer; two repeats): lazy off 46.33 / 46.36 ms, 41.96 / 41.93 tok/s; lazy on **44.87 / 44.87 ms (-3.2 %)**, 43.32 / 43.32 tok/s; the same text hashes. The drafter there was 6.32 -> 5.40 ms a pass (5.00 -> 3.57 head rows a pass). Most of the saving is the head GEMV of rows the cut never keeps: the Q5_K head on dp4a costs ~0.68 ms a row on a CMP 170HX. Any single-device head should gain where the head GEMV is a visible share of a drafter pass; not measured on other GPUs. A TP head group / `mk_split` is unchanged (the lazy path is skipped). **Costs and limits.** - One extra D2H + sync (~30 µs) a drafter pass, and a third on passes that keep >= 2 drafts (~61 % of passes above); a net saving, as measured. - Not exercised: an EXL3 head (`fmt != 0`, split-K partials); the per-column argument was checked for the GGUF GEMV only. `DS4_DSPARK_LAZY=0` is the escape. - Not separately tested: `DS4_DSPARK_SAMPLE=1` at temperature > 0 (rows are drawn with the same per-row counter, so the draws should be the same). - `ds4_gguf_test` (full suite): ALL OK. **Checks** (as `.github/workflows/tests.yml`): `tools/check_hip_compat.py` OK; server tests 463 OK (12 skipped); installer and tools tests 584 OK (31 skipped) - the same counts as v1.1.35. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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 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#630
No description provided.