mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #608] ds4: a row's logits change when its window has more than 8 rows (DS4_ASYNC_T defaults to 8, so 9-16-row prompt-lookup windows take the host-routed MoE path); temp-0 text then depends on earlier requests #252
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#252
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SeriousRising on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/608
Symptom
At temperature 0, with prompt lookup on (
--suffix-draft, default 3) and DSpark loaded, the same request can give adifferent text depending on what ran before it in the same server lifetime. The cause is the window path: a token's
logits are bit-identical whether it is computed in a window of 1, 2, ... or 8 rows, and different in a window of 9-16
rows.
Stock v1.1.28 (
6afa525) as released, one process, 48 prompt ids read once in windows of each size (m.reset()betweenpasses), logits compared with the windows-of-2 pass:
DS4_ASYNC_T=16With the default, windows 1..16 fall into six classes ({1..8} | {9,15} | {10} | {11} | {12,13,16} | {14}): a size's
class depends on how many of its windows (the last one is shorter) have more than 8 rows. With
DS4_ASYNC_T=16, allwindows 1..16 are one bit-identical class. Our v1.1.34-based tree, with all our switches on, shows the same: six
classes by default and one with the switch.
Hardware: 2x NVIDIA CMP 170HX 64 GB (sm_80, CUDA 12.8; PCIe Gen2, the second card on x4), DeepSeek-V4.1-Flash-1017 GSQ-RCO
IQ2_XXS,
--tp 1 --gpus 0,1,--cpu-threads 14. Nothing here depends on the cards. The threshold is a plain rowcount.
Why it matters
DSpark's verify windows stay at 6 rows or fewer. Prompt lookup's windows can reach
verify_max()= kWin = 16 rows.DraftPolicychooses between lookup and DSpark windows from EMAs of wall-clock round times and from earlierrequests' acceptance, and it lives as long as the engine. So whether a request verifies a 9+-row lookup window depends
on timing and on the requests before it. Each such window computes its rows on the other path. A different last bit
then grows into a different token a few hundred tokens later.
We saw this as one gate prompt giving two different texts: run alone, and run after another request. Both runs used
fresh servers with equal expert placement.
draft_policy.hppsays "it only chooses which drafts to verify: the output is unchanged". That holds only while averify row's bits do not depend on the window's size.
Cause
src/ds4/ds4_model.cu, v1.1.34 (v1.1.28 in brackets). Checked in the v1.1.34 source; v1.1.35's notes list noDeepSeek changes:
:1437[:1224]int async_max_t = DS4_ASYNC_T ? atoi(...) : 8; // windows up to this:16423[:12309]plan_window:wp.async = par || (!sync_decode && T <= async_max_t);(and:13808[:10247]dp.async, the same test for the decode window's mailbox).:17273[:12946]layer()'s FFN,if (wp.async):win_experts(fused gate/up + swiglu);mx_combine_kernelcombines the results.elsebranch (T 9-16, orDS4_SYNC) is the host-routed path:gemv_f32+route, with the picks synchronised to the host;gg::mv->iq::mv_nc, activations rounded per 32 byq8_quant);swiglu;combine.These are two implementations of the routed experts with different roundings, chosen by the window's row count. So
every layer's MoE output depends on whether the window has more than 8 rows. Layer 0's MoE is the first place the two
paths part.
Repro (stock)
Compare window sizes inside one process. Expert placement comes from the free VRAM at load (
cudaMemGetInfominusthe reserve), so two processes can place an expert differently and confound the comparison. We added a test-only
switch to
ds4_main.cpp's bench loop (+16 / -3, below; cut on v1.1.28, applies to v1.1.34 unchanged). WithDS4_BENCH_WINDOWS=a,b,..., pass i reads the prompt in windows of the i-th size, with them.reset()the bench already does between
DS4_BENCH_REPEATpasses.DS4_CHUNK_MIN=100000keeps the prompt on the window path, which is the path a verify window runs.Test-only patch: DS4_BENCH_WINDOWS
Proposed fix
Make the default
async_max_tkWin(16):The async path already covers every T <= kWin:
Req/Respare[kWin].win_expertstakes up to 16 entries.--parallel(wp.async = par) and the chunk runner already use it at any T.After the change, the host-routed path serves only
DS4_SYNC. Windows of 1-8 rows run exactly as before, so DSparkrounds and plain decode do not change.
Measured 2026-10-28, same rig, one process per arm. Pass times are for the 48 ids; the last window of a pass is the
remainder:
DS4_ASYNC_T=16The async path is faster on these cards. That speed result is specific to our CMP 170HX setup, where part of each layer's experts sits on the CPU lane, and is
worth re-measuring elsewhere. The exactness result is not specific to these cards.
Serving check, two requests in flight, prompt lookup on: one request run alone and run after another request gives
the same text (573 / 573 verify rows bit-identical, in order). Our serving config with
DS4_ASYNC_T=16passes our"two in flight = alone" gate 4/4 and our 12-prompt quality set 12/12.
A test worth adding: one row's logits in windows of 1..16, bit for bit, in one process (the patch above is the
harness).
Not covered
Restart-to-restart reproducibility is a separate issue. Placement depends on the moment's free VRAM, so two lifetimes
can place an expert differently; we have not filed that one.
@somnergy commented on GitHub (Oct 28, 2026):
A data point from a different place: the drafter pass of
--paralleldrafting, measured on 2× Blackwell cards on a layer split.DS4_ASYNC_T=16makes our multi-conversation drafter passes match the lone drafter. The pass runs 10-15 rows (2-3 conversations × a 5-row block), so with the default 8 it took the host-routed branch. Its drafts then differed from the lone drafter's in the last bits: 116 of 154 differed. WithDS4_ASYNC_T=16, and later withdp.async = par || ...in the code, they were bit for bit the lone drafter's: 83 of 83, then 92 of 92.One caveat on "all windows 1..16 are one bit-identical class". On the async path, the experts' kernels take an expert's rows in tiles of 1/4/8/16, and an expert that draws 9 or more rows of one window sums in another order. On a layer split with every main expert in VRAM:
A single-sequence check rarely routes 9+ rows of a window to one expert, so it may not show this; it shows once several conversations share a window. Raising the default still looks right to us. The tile rule is a separate dependence on row count.
@mw00 commented on GitHub (Oct 28, 2026):
Fixed in v1.1.36: windows of 9-16 rows now take the same path as 1-8 (
DS4_ASYNC_Tdefault 16), so a row's logits no longer depend on its window's size. We reproduced it on one V100: 48 positions read in windows of 12 differed from windows of 2 (largest logit difference about 20); with the new default they are bit-identical, and windows of 1-8 are unchanged bit for bit. Decode and prefill times are the same or slightly better. Thank you @SeriousRising, the table and the repro made this a ten-minute check.Released in v1.1.36: https://github.com/mw00/project-maya/releases/tag/v1.1.36
@somnergy commented on GitHub (Oct 29, 2026):
A correction to my earlier comment here (and to point 1 of mine on #611): the "tile rule" caveat was wrong. v1.1.36 with #587 on top, two-GPU layer split, every multi step on the async path,
--multi-check --n 160, the expert cache off so the placement stays fixed:--parallel 2: drafting windows of about 12 rows;--parallel 3: windows of about 14 rows;--parallel 4: windows of about 16 rows (710 drafts in 62 rounds).At all three, every conversation's tokens with the drafter are the same as alone, and the plain rows are bit for bit (318/318, 477/477, 636/636).
So windows of 9-16 rows are fine on the async path. My failing 10-row and 16-row windows must have taken the host-routed branch (
DS4_ASYNC_Twas 8 then), which is what this issue fixed. The experts' tile sizes were a wrong guess at the cause. Sorry for the noise.