[PR #612] fix(ds4): isolate prefill timing by prompt size #625

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

📋 Pull Request Information

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

Base: main ← Head: fix/ds4-prefill-path-feedback


📝 Commits (3)

  • 55622a0 Fix DS4 prefill path feedback isolation
  • 40fd73a test(ds4): prove cold feedback cannot reverse larger prompt choices
  • 3bd2962 docs(ds4): explain size-local prompt learning and existing tuning

📊 Changes

5 files changed (+127 additions, -20 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 docs/SETTINGS.md (+14 -0)
📝 src/ds4/ds4_model.cu (+9 -20)
➕ src/ds4/ds4_path_policy.hpp (+45 -0)
➕ tests/ds4_path_policy_test.cpp (+57 -0)

📄 Description

DeepSeek processes small inputs through either a streamed GPU pass, called flow, or repeated 16-token windows. Its selector predicts their cost from startup calibration and timings of earlier requests.

When an input's size class has no flow measurements, the selector borrows a timing correction from the nearest measured class. A slow 11-token warmup can therefore inflate the flow estimate for a 515-token input and make windows look faster. Fixed overhead can dominate the tiny request without making larger requests equally slow.

This PR keeps each correction within the size class that produced it. Unmeasured classes use the startup-calibrated estimate until they have their own measurements.

  • Existing size boundaries, clipping, smoothing and the safeguard for uncached weights stay unchanged. Windows remain available when predicted faster; this does not force every input through flow.
  • The fix works automatically, with no new setting or calibration command. It changes neither read-ahead policy nor expert RAM allocation.
  • The regression case checks that a slow 11-token call cannot make an unmeasured 513-token input choose windows over a faster calibrated flow estimate. Other cases keep windows eligible.

Measured effect

Main e16dec85 versus PR 3bd2962, on a Threadripper PRO 3945WX with four RTX 3090s and the DeepSeek V4.1 Flash GSQ RCO IQ2-XXS pack. Prefill is input-processing time; complete time also includes generating 256 tokens.

Added tokens Main prefill PR prefill Main complete time PR complete time
128 2.084 s 1.576 s 8.431 s 8.136 s
512 6.912 s 2.453 s 13.202 s 8.765 s
2048 4.517 s 4.488 s 10.769 s 10.873 s
  • For 512-token additions, prefill fell 64.5% and complete time fell 33.6%. All three pairs improved. The 95% paired-start bootstrap intervals were 60.6% to 67.5% less prefill time and 30.2% to 35.4% less complete time. Other complete-time and decode effects remain uncertain.
  • Main used windows for all nine measured 515-token inputs; the PR used flow for all nine. The PR still used windows for three of nine 131-token inputs. Chat framing accounts for the three extra tokens beyond the table's added-input counts.
Benchmark setup and limits
  • Three paired fresh starts, with run order rotated. Each start processed an 8K code-chat prefix, then nine cached turns. Both versions used full CPU-expert RAM copies, automatic calibration, TP=1 and speculative decoding. The wider run included a separate copy-allocation candidate, excluded from this table.
  • Every turn generated 256 tokens. All outputs were included, even when they differed. The bootstrap resamples paired engine starts, not individual turns; only three pairs underpin the estimates.
  • Synthetic chat retained prior reasoning tokens. Timings cover one direct-engine request at a time, excluding HTTP and queueing. They do not establish answer quality, multi-user performance or gains on other hardware.

This fix is independent of the read-ahead control in #569. Their measured gains should not be added together.


🔄 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/612 **Author:** [@Whamp](https://github.com/Whamp) **Created:** 10/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ds4-prefill-path-feedback` --- ### 📝 Commits (3) - [`55622a0`](https://github.com/mw00/project-maya/commit/55622a015991476a72a836d0daa1a2c3638a1481) Fix DS4 prefill path feedback isolation - [`40fd73a`](https://github.com/mw00/project-maya/commit/40fd73a6ba222709cf55de77ae08fee8bb783674) test(ds4): prove cold feedback cannot reverse larger prompt choices - [`3bd2962`](https://github.com/mw00/project-maya/commit/3bd29623d83f37458c82166620517292790ef341) docs(ds4): explain size-local prompt learning and existing tuning ### 📊 Changes **5 files changed** (+127 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `docs/SETTINGS.md` (+14 -0) 📝 `src/ds4/ds4_model.cu` (+9 -20) ➕ `src/ds4/ds4_path_policy.hpp` (+45 -0) ➕ `tests/ds4_path_policy_test.cpp` (+57 -0) </details> ### 📄 Description DeepSeek processes small inputs through either a streamed GPU pass, called flow, or repeated 16-token windows. Its selector predicts their cost from startup calibration and timings of earlier requests. When an input's size class has no flow measurements, the selector borrows a timing correction from the nearest measured class. A slow 11-token warmup can therefore inflate the flow estimate for a 515-token input and make windows look faster. Fixed overhead can dominate the tiny request without making larger requests equally slow. This PR keeps each correction within the size class that produced it. Unmeasured classes use the startup-calibrated estimate until they have their own measurements. - Existing size boundaries, clipping, smoothing and the safeguard for uncached weights stay unchanged. Windows remain available when predicted faster; this does not force every input through flow. - The fix works automatically, with no new setting or calibration command. It changes neither read-ahead policy nor expert RAM allocation. - The regression case checks that a slow 11-token call cannot make an unmeasured 513-token input choose windows over a faster calibrated flow estimate. Other cases keep windows eligible. ## Measured effect Main `e16dec85` versus PR `3bd2962`, on a Threadripper PRO 3945WX with four RTX 3090s and the DeepSeek V4.1 Flash GSQ RCO IQ2-XXS pack. Prefill is input-processing time; complete time also includes generating 256 tokens. | Added tokens | Main prefill | PR prefill | Main complete time | PR complete time | |---|---:|---:|---:|---:| | 128 | 2.084 s | 1.576 s | 8.431 s | 8.136 s | | 512 | 6.912 s | 2.453 s | 13.202 s | 8.765 s | | 2048 | 4.517 s | 4.488 s | 10.769 s | 10.873 s | - For 512-token additions, prefill fell 64.5% and complete time fell 33.6%. All three pairs improved. The 95% paired-start bootstrap intervals were 60.6% to 67.5% less prefill time and 30.2% to 35.4% less complete time. Other complete-time and decode effects remain uncertain. - Main used windows for all nine measured 515-token inputs; the PR used flow for all nine. The PR still used windows for three of nine 131-token inputs. Chat framing accounts for the three extra tokens beyond the table's added-input counts. <details> <summary>Benchmark setup and limits</summary> - Three paired fresh starts, with run order rotated. Each start processed an 8K code-chat prefix, then nine cached turns. Both versions used full CPU-expert RAM copies, automatic calibration, TP=1 and speculative decoding. The wider run included a separate copy-allocation candidate, excluded from this table. - Every turn generated 256 tokens. All outputs were included, even when they differed. The bootstrap resamples paired engine starts, not individual turns; only three pairs underpin the estimates. - Synthetic chat retained prior reasoning tokens. Timings cover one direct-engine request at a time, excluding HTTP and queueing. They do not establish answer quality, multi-user performance or gains on other hardware. </details> This fix is independent of the read-ahead control in #569. Their measured gains should not be added together. --- <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#625
No description provided.