DSpark scheduler break-even model appears not to account for replay cost (Metal, net -1327ms despite 70% accept rate)
On Metal (M4 Max, Flash q2-q4, 0731 DSpark support GGUF, 6747e77), DSpark is consistently net-negative on generation:
| corpus | baseline gen | --dspark |
change |
|---|---|---|---|
| prose, 9485 tok | 29.31 t/s | 23.02 t/s | -21.5% |
| prose, 28790 tok | 27.82 t/s | 23.10 t/s | -17.0% |
| code, 9452 tok | 29.53 t/s | 22.90 t/s | -22.4% |
Reproducible to 0.2% across reps; prefill is unaffected as expected.
This is not the ROCm no-draft failure in #597 — here DSpark proposes normally and its proposals are usually accepted. DS4_DSPARK_STATS=1, prose:
cycles=88 proposed=44 accepted_draft=31 accept_rate=70.45% avg_accept=0.352
full=14 partial=2 miss_first=7 no_draft=65 scheduler_skips=52
draft_len_hist=1:10,2:6,3:6,4:1 accepted_len_hist=0:72,1:6,2:5,3:5
time_ms propose=332.0 verify=964.4 replay=1063.1 spec_total=2039.9
saved=1045.3 net_saved=-1326.6
The economics: each accepted token saves ~34 ms (one baseline token at 29.3 t/s), and 31 were accepted, giving saved=1045 ms. But replay=1063 ms over 44 proposals is ~24 ms per speculation cycle — roughly one full token. So a cycle must accept more than one token just to pay for its own replay, while avg_accept is 0.35.
The scheduler is clearly trying to avoid this: 52 of 88 cycles were skipped, and the no-draft pause logic fires. But it still ends up net-negative, which suggests its break-even model may not include the replay term — the largest single cost in the breakdown.
Two observations that may help localise it:
- Code is worse than prose, contradicting the README guidance that predictable continuations benefit most: accept_rate 62.22% vs 70.45%, avg_accept 0.308 vs 0.352, 77/91 vs 72/88 cycles accepting zero. Corpus was a 9452-token prefix of
ds4.citself, length-matched to the prose prompt within 0.3%. - Drafts never exceed 4 tokens in either corpus, and
--mtp-drafthas no effect across 1/4/8 (22.90 / 22.94 / 22.94 t/s) — expected, since that flag drives the legacy MTP path, but worth stating so others do not try it as a workaround.
Not asking for the replay fix (7fb2830) to be reverted — it is a correctness fix, and removing it would only move net_saved from -1327 ms to roughly -264 ms, still a loss. The suggestion is narrower: if the scheduler counted replay in its break-even estimate, it could pause speculation earlier on low-yield content and converge to baseline instead of below it.
Happy to run experiments if useful — the telemetry above is easy to regenerate.
Independent confirmation from a different angle — this extends the finding to the best possible case for DSpark, not just prose/code.
Setup
M5 Max 128GB, current main (e0c63d9, includes the 7fb2830/af80694 replay fix), Flash q2-q4 (asymmetric mixed quant, ~98GB), official DeepSeek-V4-Flash-DSpark-support-0731.gguf, --dspark-confidence 0.7 (default).
Best-case content: maximally predictable numeric continuation
Greedy (--temp 0, reasoning_effort: none to rule out thinking-mode content), continuing an already-started 1, 2, 3, ... sequence to 300 — about as repetitive as real content gets, and specifically the kind of input the README singles out as DSpark's ideal case:
- Before this fix (measured 2026-07-20, same content type, older
main): baseline 37.6 t/s → DSpark 89.3 t/s (+137%) - After this fix (today): decode is flat, 31.67 t/s average, no ramp-up at all across the whole generation
So it's not just prose/code that went net-negative — even the textbook best case (which used to be DSpark's strongest argument) now sits below the non-speculative baseline (~37-40 t/s on this quant). Consistent with your read: the replay fix is correct and shouldn't be reverted, but the scheduler's break-even estimate not counting replay means it no longer has any regime where it clearly wins on this hardware.
Separate but related data point
Worth having in the same place: at real (non-greedy) sampling — temp=1.0 top_p=1.0, DeepSeek's own documented recommendation for this model — DSpark's accept rate collapses independently of the replay-cost issue, because the verify step compares drafts to sample_argmax(target) rather than a true sample of the configured distribution (discussed at length on #482). So on Metal today, DSpark doesn't have a currently-reachable win condition for anyone running the model at its recommended sampling settings, on top of the replay economics above.
Happy to run more configurations if useful (different --dspark-confidence values, block sizes, etc.) — I have the quant and sidecar already downloaded.
Tested the opt-in scheduler timing knobs mentioned in the code comments (DS4_DSPARK_SCHEDULER_MAX_EXTRA_SAVED_RATIO_MILLI, DS4_DSPARK_SCHEDULER_MAX_MS_PER_ACCEPT_MILLI) against my best-case content from above (the 1→300 numeric continuation) — sharing since the result is a bit counter-intuitive.
They exist (ds4.c, ds4_dspark_scheduler_max_ms_per_accept_milli() / ds4_dspark_scheduler_max_extra_saved_ratio_milli()) and are wired into the break-even check, but both default to 0 (disabled) — the comment on ds4_dspark_scheduler_timing_enabled() explains why: "Timing-sensitive scheduling changes which arithmetic path advances a token. Keep it opt-in so greedy DSpark output is reproducible across runs." So out of the box, the only active backoff signals are the count-based ones (low_accept, many_no_draft), not the wall-clock ones — which matches your read that the break-even model isn't really counting replay by default.
I turned them on (MAX_EXTRA_SAVED_RATIO_MILLI=1200, MAX_MS_PER_ACCEPT_MILLI=40) expecting the scheduler to back off and at least recover to baseline. It didn't — same flat ~32 t/s as with defaults, no measurable change. My reading: on this content the accept rate stays high enough that the count-based skip logic never fully disengages, so the timing knobs don't get much chance to act within an already-running sequence — and since replay cost is paid per accepted token rather than per cycle, a high accept rate doesn't dilute it the way it would dilute a fixed per-cycle overhead. If that's right, backing off earlier wouldn't recover the old speedup here even with the knobs on by default; it would just cap the downside on genuinely low-yield content, which is still valuable but is a narrower fix than the break-even model catching this case.
Not confident in that read — happy for someone to correct it — but wanted to flag that enabling the existing opt-in mechanism isn't a free win here, at least not with these threshold values.
Adding a code-level confirmation of @Flor1an-B's per-accepted-token reading, because it changes what I asked for in the original report.
Replay is one full target-model forward per accepted token
At 6747e77, accepted drafts are replayed in a sequential loop:
for (int i = 0; i < replay_budget; i++) {
ok = metal_graph_eval_token_raw_swa(&s->graph, &e->model, &e->weights,
drafts[i], (uint32_t)s->checkpoint.len,
row_logits);
if (!ok) { ... }
token_vec_push(&s->checkpoint, drafts[i]);
accepted[n_accept++] = drafts[i];
replayed_drafts++;
}
(around ds4.c:61777 at that commit — I don't have af80694 locally, so the line may have moved.)
One metal_graph_eval_token_raw_swa per accepted token is one ordinary decode. The telemetry in my original report says the same thing numerically:
replay 1063.1 ms / 31 accepted = 34.3 ms per accepted token
one baseline token at 29.31 t/s = 34.1 ms
saved = 1045.3 vs replay = 1063.1 -> within 1.7%
An accepted token costs almost exactly what accepting it saved, leaving propose (332 ms) and verify (964 ms) with nothing to pay them.
This makes my original framing too weak
I suggested the scheduler's break-even estimate should include the replay term. If savings and replay cancel by construction, that isn't sufficient: no threshold makes speculation profitable, and the best a perfect scheduler can do is skip every cycle and converge to baseline. That matches the flat 31.67 t/s @Flor1an-B measures on maximally predictable content, where the old behaviour was +137%.
It also explains why the opt-in timing knobs changed nothing: the dominant cost scales with accepts, not with cycles, so a high accept rate cannot dilute it the way it would dilute a fixed per-cycle overhead.
A direction that doesn't touch the correctness fix
Batch the replay — evaluate an accepted run in a single multi-token forward instead of k sequential ones, so k accepted tokens cost ~1 forward rather than k. At my avg_accept of 0.35 this would change little, but the long-draft regime is exactly where the old speedup came from, so it is the case that stands to recover.
There is batched machinery on the prefill side (layer_attention_raw_swa_batch, chunked prefill), though reusing it for a mid-sequence replay against a restored snapshot is clearly not a small change.
Minor: stale comment on the invariant under discussion
The comment on the speculative scratch fields still describes the pre-7fb2830 design:
Prefix slots retain the intermediate frontiers of a tiny verifier block so partial accepts do not need target-model replay.
(ds4.c ~15021.) That is no longer true after the partial-accept shortcut was removed.
Setup otherwise unchanged from the original report (M4 Max, Flash q2-q4, 0731 DSpark GGUF). Happy to regenerate any of the telemetry.
This is a much sharper framing than what I had — thanks for tracing it through the actual replay loop and the arithmetic. "Savings and replay cancel by construction at the per-accepted-token level" is a real result, not just an observation from one dataset; it explains why my MAX_EXTRA_SAVED_RATIO_MILLI/MAX_MS_PER_ACCEPT_MILLI experiment did nothing, cleanly, rather than as a coincidence.
The batched-replay direction sounds right to me as the actual fix, for what my opinion's worth: it targets the thing that's actually broken (cost per accepted token) instead of working around it with scheduling, and it's the one change that could get back to something like the old long-draft-run economics rather than just capping the downside.
I don't have the Metal graph/kernel familiarity to responsibly attempt "batch an accepted run against a restored snapshot" myself — that's squarely your and @af80694-adjacent territory, not mine. Two things I can usefully do if helpful: (1) keep generating telemetry/A-B runs on an M5 Max across content types as you iterate, since hardware-specific replay/verify timing seems to matter here, and (2) I'll leave the stale comment fix to whoever picks this up rather than send a one-line patch that'll conflict with real work in flight. Ping me if a build to test against would save you time.
Independent confirmation on a second M4 Max, with a different drafter — plus one data point that I think strengthens your argument, and one that bounds the fix you propose.
The headline: at 90.7% accept rate it is still 23.8% slower than baseline. Your case was 70.45%, and the natural objection to it is "acceptance is just too low here". On a high-acceptance prompt the loss does not go away:
| prompt | accept_rate |
baseline | --dspark |
change |
|---|---|---|---|---|
| counting (1..120) | 90.70% | 32.53 t/s | 24.80 t/s | −23.8% |
| prose (~200 words) | 78.10% | 32.51 t/s | 22.44 t/s | −31.0% |
The counting run proposes 86 times and gets 78 drafts accepted, and still loses a quarter of the throughput. That is consistent with your reading that the dominant term is per-cycle and not per-rejection.
On the proposal — counting replay in the break-even so the scheduler pauses earlier. The direction is supported, and here is a slope for it. Same binary, same prompt, three configurations ordered by how much they pause:
| config | scheduler_skips / cycles |
counting | prose |
|---|---|---|---|
| default | 113/173 · 68/140 | 24.80 | 22.44 |
DS4_DSPARK_SCHEDULER_NO_DRAFT_SKIP=0 |
56/138 · 51/143 | 22.63 | 22.04 |
DS4_DSPARK_SCHEDULER=0 |
0 | 20.68 | 20.15 |
Monotone on both prompts: the more the scheduler pauses, the faster it runs. A break-even model that pauses more would move throughput the right way.
But the same table bounds the gain. The most aggressive configuration that exists today already skips 65% of cycles on the counting prompt and still lands 23.8% under baseline. For the scheduler to converge to baseline rather than below it, it would have to pause on essentially every cycle for this content — that is, the fix converges to "do not speculate here". That may well be the honest answer for low-bit main models, but it is a different change from correcting the estimate, and worth separating in the discussion.
Protocol, since this machine has a fault that ruins roughly one run in three: 5 replicas per arm; a cell is discarded when a single stall over 40 ms appears in the per-token execute profile or when prop_setup exceeds 200 ms (clean cells sit at 32 ms and 20-35 ms respectively, so the thresholds have an order of magnitude of headroom); the value is the max over surviving cells, because the fault is one-sided and the run is otherwise deterministic — surviving cells agree within 0.14%, and scheduler_skips is bit-identical across replicas of the same arm. Verified separately that DS4_METAL_GRAPH_TOKEN_PROFILE=1 does not perturb throughput (32.48 vs 32.52 with it off).
Environment: MacBook Pro M4 Max 128 GB, macOS 26.6, Metal, b030961, DeepSeek-V4-Flash-...-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf (80.7 GiB, fully resident), --temp 0 -n 256, short prompts (hence baselines higher than yours).
One caveat worth stating: my drafter is an 11.5 GiB DSpark support GGUF with tensors renamed to the mtp.<N>. convention, not the 5.6 GiB 0731 support file used in #676. It loads with missing=0 invalid=0. So this is a different drafter on different content reaching your conclusion — which at least rules the drafter out as the cause — but I have not checked whether it changes the numerics of the verify path.
Also relevant to anyone re-running older comparisons: before 7fb2830, --dspark did not reproduce the plain-greedy token stream, and on the prose prompt the four scheduler configurations above produced four different texts. Any t/s comparison taken before that commit is comparing different work. Details in #658.
Thanks — the 90.7% run is the data point this needed, and it corrects my original ask.
It closes the objection from the opposite end. My case was 70.45% acceptance, where the fair pushback is "acceptance is simply too low here". Yours accepts 78 of 86 drafts and still loses a quarter of throughput, so the loss survives across the whole acceptance range.
Putting the three reports together, the loss does not track acceptance at all:
| report | accept_rate | change |
|---|---|---|
| mine, prose | 70.45% | −21.5% |
| yours, prose | 78.10% | −31.0% |
| yours, counting | 90.70% | −23.8% |
That non-monotonicity is itself the argument. If the dominant cost were per rejection, the
90.7% cell should be close to break-even. If savings and replay cancel per accepted token, then
acceptance buys nothing either way and what remains is propose + verify as pure overhead —
which is what all three cells show.
And my proposal was too optimistic — your sweep bounds it. The report says a replay-aware break-even estimate "could pause speculation earlier on low-yield content and converge to baseline instead of below it". The second half of that is wrong. Your most aggressive existing configuration already skips 65% of cycles on the counting prompt and still lands 23.8% under baseline, so for the estimate alone to reach baseline the scheduler would have to pause on essentially every cycle. That is not a corrected estimate, it is a decision not to speculate on this content.
So the two changes are worth keeping separate:
- Counting replay in the break-even stops the bleeding on low-yield content, and your monotone slope (24.80 → 22.63 → 20.68 as pausing decreases) shows it moves throughput the right way. Its ceiling is baseline-minus-epsilon, approached by speculating never.
- Batched replay — evaluating an accepted run against a restored snapshot rather than one
metal_graph_eval_token_raw_swaper accepted token — is the only change that can put DSpark above baseline again, because it attacks the per-accepted-token cost itself.
The different drafter is more useful than it might look. You are on an 11.5 GiB support GGUF
with mtp.<N>. renamed tensors rather than the 5.6 GiB 0731 file, and you reach the same
conclusion — which rules out drafter mismatch as the cause. That is worth stating explicitly,
because a mismatched drafter is exactly what corrupted my own first measurement of this: the
legacy and 0731 support files are byte-identical in size (5,989,114,272) and differ only by
sha256, so nothing on disk flags the pairing, and it produced a plausible-looking −7.7% that I
had to throw away.
Your #658 note deserves more prominence than a footnote. Any --dspark throughput number
taken before 7fb2830 compares different generated text, so a fair amount of pre-existing
comparison in this area — including some of my own early numbers, though not the ones in this
report — is not measuring what it claims to. Worth flagging wherever those figures are still
quoted.
Traced the replay cost to its exact source in ds4_session_eval_dspark_speculative_argmax (ds4.c), which explains why it's structured this way and why the fix isn't a quick change.
The mechanism: verification is already correctly batched — metal_graph_verify_suffix_tops does one forward pass over all draft_n positions to get row_tops (the target model's greedy pick at each draft position), which is exactly how a fast verify step should work. But the code comment right after it says why the accepted tokens then get replayed one at a time (ds4.c:61711-61714):
Batch verification and ordinary decode update compressor state with different kernels. Restore the pre-verify frontier and replay every accepted draft through ordinary decode, including partial accepts, so speculative decoding retains the target model's greedy token stream.
So the batched verify kernel doesn't correctly maintain the compressed-KV/indexer state per accepted position — only the normal single-token decode kernel (metal_graph_eval_token_raw_swa) does. The checkpoint gets rolled back after verify and then each accepted draft is replayed through that single-token path, one full target-model forward per token (ds4.c:61777).
Why this cancels the savings almost exactly (confirms @datanerdie's per-accepted-token framing with the actual cost accounting): producing N accepted tokens costs 1 batched-verify forward (~1 normal forward, wall-clock-wise, since this is memory-bandwidth bound) + N sequential replay forwards + a cheap draft-model forward. That's ~(N+1) target-model forwards to produce N tokens — at best breakeven with plain autoregressive decoding (N forwards), before even counting the draft model's own cost. There's no regime where this wins; higher accept rates just mean you pay the full (N+1) more often instead of falling back to a cheap 1-token verify-miss path.
Why MTP stays viable with the same mechanism: MTP's replay path has the identical split (batched-ish confidence check, then per-token replay — see the mtp timing ... replay=...ms log lines in the same file) but typical draft windows are small (--mtp-draft commonly 1-2, vs DSpark's DS4_SPEC_PREFIX_SLOTS=4 → up to 5-token windows). Same per-token tax, much smaller absolute N, so it stays net-positive in practice where DSpark doesn't.
External expectation check: Unsloth's docs claim DSpark should give up to ~2x decode speedup (DeepSeek-V4-Flash "120 tokens/s on a B200 GPU compared to the original 60 tokens/s baseline"): https://unsloth.ai/docs/models/deepseek-v4#dspark-speculative-decoding. That's consistent with a correctly-batched implementation (verify and accept both O(1) forwards regardless of N) and sharpens the gap here — ds4's replay step currently pays the full O(N) cost speculation is supposed to let you skip.
The real fix is a batched-replay kernel that updates the compressed-KV/indexer state correctly per position the way the single-token path does, not just batched logits like verify already has — that's genuine kernel work I don't have the Metal expertise to attempt safely, but hopefully this narrows exactly what needs to change for whoever does (this lines up with @datanerdie's "batch the replay" proposal above, now with the specific reason the two kernels currently diverge).
Follow-up with a working prototype and real numbers, plus a finding that reframes the fix as a policy question rather than a pure bug.
MTP already made this trade-off, by default, on Metal. Tracing ds4_session_eval_speculative_argmax's MTP path (draft_n==2) turned up:
#ifdef DS4_ROCM_BUILD
const bool prefer_decode2_exact = true;
#else
const bool prefer_decode2_exact = false; // Metal
#endif
metal_graph_verify_decode2_exact — the exact, bit-identical-to-decode verifier — is only preferred on ROCm. On Metal, MTP's default path uses the same batched metal_graph_verify_suffix_tops DSpark's verify already uses, and on a full accept it commits directly from that batched pass with no rollback and no replay — it only snapshots/replays when the accept is partial. That's why MTP stays net-positive: it almost never pays sequential-replay cost. DSpark, by contrast, unconditionally rolls back and replays every accepted draft, full accept or not (ds4.c:61711-61714, quoted in my last comment).
Prototype: mirrored MTP's full-accept path onto DSpark — skip the rollback + sequential replay when commit_drafts == draft_n, and just read the already-computed spec_logits row for the last drafted position directly, same as MTP's commit_drafts == draft_n branch already does. TP path untouched (falls through to the existing rollback+replay unconditionally, since I haven't touched or validated that path).
Measured, same session, controlled A/B, --dspark --mtp-draft 2 --temp 0, same prompt:
- Unpatched: 30.43 t/s
- Patched: 35.95 t/s (+18.1%)
The catch, and it's a real one: comparing full generated output (not just the dspark-verify-depth unit test, which passed clean at worst_argmax_gap=0.000 over 128 cycles) — the patched output diverges from plain greedy decode starting at the first sentence. So I checked whether MTP's already-shipped default has the same property: it does. Same prompt, same settings, MTP's output diverges from greedy decode at the same point, with the same inserted phrase ("...spanning over a millennium and leaving an indelible mark on Western civilization..."), because it's the identical batched kernel causing the same near-tied-logit flip. This isn't a new risk my patch introduces — it's the exact trade-off MTP already ships by default on Metal, just not yet applied to DSpark.
So this isn't "here's a bug fix," it's "DSpark doesn't yet apply the speed/exactness trade-off the project already made for MTP." Whether that's the right call for DSpark too is a real decision, not something I want to sneak in as a quiet correctness-preserving patch — happy to open a PR with this behind an opt-in flag, or as the new default matching MTP, whichever @antirez would rather review.
Opened #746 with the prototype behind an opt-in flag (DS4_DSPARK_FULL_ACCEPT_FAST_COMMIT), plus a multi-prompt benchmark script and the full data — including confirmation that MTP's already-shipped default has the identical divergence-from-exact-greedy behavior on the same prompt, so this isn't a new risk category, just extending an existing trade-off to DSpark.
Re-ran my end of this on 84cc882, with 0e89a0e in. The replay cost is gone, and on the counting prompt speculation now wins. Since my earlier numbers are the ones in this thread, here they are again under the same protocol, so the before/after is like-for-like.
| prompt | accept_rate |
baseline | --dspark |
change | (same arms on b030961) |
|---|---|---|---|---|---|
| counting (1..120) | 88.95% | 35.45 t/s | 39.87 t/s | +12.5% | 32.53 → 24.80, −23.8% |
| prose (~200 words) | 77.22% | 35.50 t/s | 34.79 t/s | −2.0% | 32.51 → 22.44, −31.0%* |
* One correction to my own before-column while I am at it: that prose --dspark cell was the one arm my protocol flagged as suspect back then (surviving cells 22.44 / 21.69 / 17.37, 3.3% spread), so −31.0% was a lower bound on the loss, not a tight estimate. The −23.8% counting figure was solid (24.80 / 24.79 / 24.78 / 24.78).
The mechanism, measured rather than inferred: replay=0.000 in every cell of both campaigns, replay_fallbacks=0, and every acceptance accounted for as direct_full/direct_partial (counting full=37 partial=5, prose full=35 partial=9). Worth noting for anyone reading #746 first: the shipped default also covers partial accepts, which the opt-in prototype deliberately left on the old path — though reading the source rather than the counters, that direct partial path is conditional on being off TP (TP workers get no intermediate snapshots and keep the mirrored replay fallback) and on commit_drafts <= DS4_SPEC_PREFIX_SLOTS. Single-host Metal runs like mine take it every time; that is not the same as always.
Per-run balance (saved − spec_total − propose): +863 ms on counting, −100 ms on prose. So on prose the residual is no longer the replay — it is the drafter itself (propose ≈ 694 ms against verify ≈ 2836 ms). At 77% acceptance the margin does not cover the proposal.
Two things that are easy to conflate, and one of them is mine to flag. The non-speculative arm moved too: 32.53 → 35.45 and 32.51 → 35.50, +9.0% and +9.2%, from the MXFP4/M5 decode work and 0ad494e. Anyone comparing a number from today against one from five days ago is adding two effects. A free provenance check on that: the greedy text hashes to the same md5 as on b030961 on both prompts (5284848e counting, fa10dd86 prose, recomputed from the raw logs of the earlier campaign). So the exact fast paths really are exact here — 9% faster, byte-identical output.
The three-point scheduler series I posted above is now reversed, and it changes sign with the prompt. Same binary, same prompts, ordered by how much the scheduler pauses:
| config | scheduler_skips (counting · prose) |
counting | prose |
|---|---|---|---|
| default | 26 · 58 | 39.87 | 34.79 |
DS4_DSPARK_SCHEDULER_NO_DRAFT_SKIP=0 |
8 · 24 | 41.74 | 33.72 |
DS4_DSPARK_SCHEDULER=0 |
0 · 0 | 41.72 | 34.20 |
On counting the scheduler now costs 4.7%: the more it pauses, the slower it runs — the exact opposite of what it did before the fix, and the default is the worst of the three. On prose it still pays, which is consistent with its purpose (lower acceptance, pausing is worth it). So my earlier "monotone on both prompts, pause more" reading should be treated as withdrawn: it was measured on a build where every accepted token was decoded twice.
Output identity. The binary announces the trade-off itself (DSpark direct verifier-state commits enabled; greedy output may differ...), and that is what I see: on counting all three speculative arms diverge from the plain-greedy stream; on prose only the default diverges, while both reduced-scheduler arms stay byte-identical. Prompt-dependent, as was predicted in #658.
Protocol (unchanged, so the arms stay comparable to the earlier table): 5 replicas per arm, purge before each run, arms alternated inside a replica, warm-up run discarded, a cell discarded when a single stall above 40 ms shows up in the per-token execute profile or prop_setup exceeds 200 ms, value = max over surviving cells because the fault is one-sided. To be unambiguous about that last part, since it is the step that decides the numbers: the top two surviving cells of each arm agree within 0.02–0.19%, and that agreement is the confirmation I require before taking the max as the value — a single cell is not one. Across all surviving cells of an arm the spread is naturally wider, up to 0.88% (prose, DS4_DSPARK_SCHEDULER=0), because the contaminant only ever adds time and never removes it. This machine was noisier than usual today (audiomxd at 76% CPU): 4 cells of 21 discarded on counting, 7 of 22 on prose.
Environment: MacBook Pro M4 Max 128 GB, macOS 26.6, Metal, 84cc882, DeepSeek-V4-Flash-...-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf (80.7 GiB, fully resident), --temp 0 -n 256, short prompts.
Two corrections to my own earlier comments, while I am here. My drafter is 10.70 GiB, not "11.5 GiB" — that figure was GB read as GiB, twice. And it remains a locally converted mixed-precision support file, not the official 5.6 GiB one, so the acceptance pattern (and therefore the batch composition that decides whether a rounding flips) is mine, not the reference one.
From my side the issue as titled is answered: the break-even model no longer omits a replay cost, because there is no replay. What is left is narrower and probably deserves its own thread if anyone wants it — at low acceptance the drafter's own cost still puts speculation marginally under baseline, and the skip policy is tuned for that regime, which makes it a small net loss on high-acceptance content.
Adding the first ROCm / gfx1151 data point (Strix Halo, Radeon 8060S), since #695 and #733 are both Metal. The headline is that DSpark is net-negative here too — but for a different reason than replay, which may narrow the fix.
Environment: ds4 84cc882, Ubuntu 26.04, ROCm 7.1, DeepSeek-V4-Flash-IQ2XXS-...-0731, ctx 8192, --temp 0, 256 tokens, code-generation prompt.
Confidence sweep — monotonic: the more it speculates, the slower it gets.
| mode | generation | vs baseline |
|---|---|---|
| baseline (no DSpark) | 16.44 t/s | — |
--dspark (0.7, ROCm default) |
11.18 t/s | −32% |
--dspark-confidence 0.6 |
10.04 t/s | −39% |
--dspark-confidence 0.3 |
9.42 t/s | −43% |
--dspark-confidence 0 (5-token blocks) |
9.27 t/s | −44% |
Telemetry at default confidence (DS4_DSPARK_STATS=1):
cycles=135 proposed=135 accepted_draft=112 accept_rate=82.96% avg_accept=0.830
time_ms propose=2243.1 verify=11763.5 verify_layer=11729.4 replay=0.000
target=8805.8 saved=6849.0 net_saved=-7186.8
Two things differ from the Metal reports:
replay=0.000. The replay cost that #695 and #733 identify as the bottleneck does not exist on this path at all. Verification alone is net-negative: 11.7 s of verify to save 6.8 s of decode.verify_layeris 99.7% of verify (11729 of 11763 ms), and it scales superlinearly with block size:
| confidence | avg block | verify_layer/cycle |
|---|---|---|
| 0.7 | ~2.4 tokens | 86.9 ms |
| 0 | 5 tokens | 231.4 ms |
2.08× the tokens per block costs 2.66× the verify time. Decode here is bandwidth-bound, so verifying a k-token block should cost roughly one weight sweep — about one decode step — regardless of k. Cost growing with k is the signature of the batched verify not amortizing, and it explains the monotonic curve: acceptance stays high (83%) while the work per accepted token keeps rising.
Ruled out: DS4_MTP_BATCH_VERIFY=1 changes nothing (11.18 → 11.19 t/s, verify_layer unchanged). The prefer_decode2_exact ROCm conditional noted above is gated on draft_n == 2, so it is not on DSpark's path.
So on ROCm the break-even model is not mispricing replay — there is no replay. It is mispricing verify_layer itself, which is why no confidence threshold recovers baseline and the ROCm default (0.7) is merely the least-bad because it speculates least.
Happy to run any diagnostic or patch on this hardware.
Picking this back up on current main (110afdd, well past 0e89a0e/#746) to check whether the scheduler-miscalibration tail Florian flagged in his last comment ("a small net loss on high-acceptance content... probably deserves its own thread") is still present, and to narrow down which specific mechanism is responsible.
Setup: M5 Max 128GB, Metal, --warm-weights, single GPU, Flash q2-q4 (0731), official DeepSeek-V4-Flash-DSpark-support-0731.gguf, --temp 0 -n 300, 2 reps per arm (identical to 0.1-0.2% both times).
The regression reproduces cleanly on code-completion content
Counting-style content (Flor1an-B's/alangiu-gif's earlier test case) now hits 100% acceptance on this build with scheduler_skips=0 even at default — so it no longer exercises the scheduler at all, good or bad. A code-completion prompt (continuing a repetitive if/elif chain in Python) lands in the 85-92% band that does exercise it:
| config | gen t/s | vs scheduler-off | accept_rate | scheduler_skips |
|---|---|---|---|---|
| default | 52.48 / 52.62 | -8.5% | 84.72% | 19 |
DS4_DSPARK_SCHEDULER=0 |
57.38 / 57.40 | — | 92.05% | 0 |
Default leaves ~9% on the table vs. just always speculating, on content where speculation is clearly profitable (both arms land well above the ~44 t/s no-DSpark baseline).
It's not min_avg_milli
Swept DS4_DSPARK_SCHEDULER_MIN_AVG_MILLI at 500/800/1000 (default 1500) against the same prompt: scheduler_skips stayed at exactly 19 for all three, byte-for-byte identical stats otherwise. Whatever calibration issue is left, it isn't this threshold -- low_accept never appears to be the thing firing here.
It's mostly the immediate no-draft-triggered pause
DS4_DSPARK_SCHEDULER_NO_DRAFT_SKIP=0 (the count-based pause that fires as soon as a single cycle proposes nothing, independent of the windowed low_accept/many_no_draft/slow_accept check a few lines below it) takes scheduler_skips from 19 to 4 on this prompt, and gen t/s from 52.5 to 53.6 -- recovers about a fifth of the gap to fully-off. The remaining 4 skips are presumably the windowed many_no_draft check (no_draft*2 >= cycles over a 4-cycle window), since disabling only the immediate trigger doesn't touch it.
no_draft cycles are 59% of all cycles here (23/39), so the immediate trigger fires often. Before #746 that made sense: a no-draft cycle was itself cheap, but it was also usually a leading indicator of a stretch where any accepted draft nearby would still cost a full sequential replay per token, so pausing pre-emptively avoided walking into that. Post-#746, a no-draft cycle costs a cheap propose-and-decline and nothing else, and pausing for 3+ cycles afterward now has a real opportunity cost -- it unconditionally forfeits the next few potential full-accept cycles, which on this content are common and cheap (accepted_len_hist shows 5:11, eleven 5-token full accepts). The mechanism's original justification looks tied to the pre-#746 cost model that #746 already removed for the full-accept case.
Why I'm not proposing a specific threshold change
The same knob doesn't cut the same way on prose. Same build, same protocol, the "water cycle" prose prompt from earlier in this thread's spirit (70-77% acceptance, genuinely marginal):
| config | gen t/s |
|---|---|
| default | 43.04 |
DS4_DSPARK_SCHEDULER=0 |
42.6 / 42.68 |
DS4_DSPARK_SCHEDULER_NO_DRAFT_SKIP=0 only |
42.36 |
Here default beats both "fully off" and "just disable the no-draft trigger" -- the immediate no-draft pause is pulling its weight on this content, presumably because on genuinely marginal content, a no-draft cycle is a better leading indicator of an unprofitable stretch than it is on code. So "weaken or remove the immediate no-draft pause" fixes the code case and would very plausibly regress the prose case -- this reads as a real content-dependent tuning problem, not a single miscalibrated constant, which is more than I can responsibly resolve with two content types on one machine.
Sharing the isolated mechanism and the counter-example in the same place in case it saves someone the sweep before attempting a fix. Happy to run more content types / configs on this hardware if useful.
Ran your configuration against mine on 110afdd, and I think the two reports are compatible — but only once a variable neither of us was treating as one is on the table. The support GGUF flips which scheduler setting wins. Same prompt, same build, same machine, only the drafter changed:
| codegen prompt, drafter | baseline | default | NO_DRAFT_SKIP=0 |
SCHEDULER=0 |
accept (default) |
|---|---|---|---|---|---|
| mine (locally converted, 10.7 GiB) | 35.03 | 34.37 | 33.98 | 31.67 | 82.99% |
official ...DSpark-support-0731.gguf (5.6 GiB) |
34.93 | 32.61 | 31.96 | 33.68 | 69.93% |
With my drafter the scheduler pays and the default is the best of the three; with the official one it costs and turning it off wins. The second row is your ordering, on your support file. So I do not think either of us mismeasured: acceptance is what the scheduler is tuned against, and the drafter is what sets acceptance. Worth naming explicitly in this thread, because it is the one variable that is easy to leave unstated — the acceptance-vs-throughput picture is not a property of the content alone.
Note the two rows differ in more than ordering: net_saved goes from −122 ms to −478 ms, so on my hardware the official drafter is simply worse in absolute terms. That part is a property of my setup and I would not generalise it. The ordering flip is the part that affects how anyone reads a scheduler sweep.
On the immediate no-draft pause specifically, your intuition reproduces but the threshold sits higher than 85%. Removing it, across my four cells, ordered by acceptance:
| prompt (drafter) | accept_rate | NO_DRAFT_SKIP=0 vs default |
|---|---|---|
| counting (mine) | 88.95% | +4.8% (39.44 → 41.34) |
| codegen (mine) | 82.99% | −1.1% (34.37 → 33.98) |
| prose (mine) | 77.22% | −2.9% (34.44 → 33.45) |
| codegen (official) | 69.93% | −2.0% (32.61 → 31.96) |
Monotone in acceptance, and it crosses somewhere between 83% and 89% — so at the 85–92% band where you see it help, I see it hurt. That makes your reading of the mechanism right and its boundary too low. It also suggests the knob is not really content-dependent but acceptance-dependent, which is the better news of the two: acceptance is already observable at runtime, content type is not.
One thing of yours I could not reproduce, and I mention it because it would change what people bench. You report counting hitting 100% acceptance with scheduler_skips=0 at default on this build, i.e. no longer exercising the scheduler. On 110afdd my counting prompt gives 88.95% with 26 skips, and default-to-SCHEDULER=0 is a 4.7% spread — very much alive. Different prompt and different drafter, and I have just shown the drafter alone flips the ordering, so this is not a contradiction. But I would not retire counting from a scheduler bench on that basis.
A reading caveat that applies to my numbers as much as yours. In three of my four campaigns the speculative arms do not generate the same text, and on codegen with my drafter all three differ from each other, not just from greedy:
| campaign | baseline | default | NO_DRAFT_SKIP=0 |
SCHEDULER=0 |
|---|---|---|---|---|
| codegen (mine) | 50b4565e |
a512fbed |
4c67cb04 |
7e3e209e |
| codegen (official) | 50b4565e |
2e908f2f |
73f2b26e |
2e908f2f |
| counting | 5284848e |
4b984707 |
c6d747a6 |
c6d747a6 |
| prose | fa10dd86 |
53a7755e |
fa10dd86 |
fa10dd86 |
That is the trade-off the binary announces at startup, so it is expected — but it means a three-point scheduler series on codegen is not three configurations doing the same work, and on prose it is (both reduced-scheduler arms stay byte-identical to greedy). None of the reports here, mine from 10 Aug included, put the hashes next to the series. I would suggest we all do, since it costs one column and decides whether a percentage is a speed difference or a workload difference.
Incidental, but useful for anyone comparing against older numbers in this thread: across the 116 commits from 84cc882 to 110afdd, all eight arms of my two earlier prompts moved by −0.8% to −1.3%, same ordering, with the greedy md5 unchanged on both prompts. On Metal, nothing in that range moved DSpark or ordinary decode. So the 10 Aug figures upthread are still current, and a difference bigger than ~1% against them is a real difference, not drift.
Protocol, unchanged from my earlier post so the arms stay comparable: 5 replicas per arm, purge before each run, arms alternated inside a replica, warm-up run discarded, a cell discarded on any single stall above 40 ms in the per-token execute profile or prop_setup over 200 ms, value = max over surviving cells because the contaminant is one-sided. This run was clean in a way the previous one was not: zero cells discarded out of 84 (the 10 Aug campaign lost 4 of 21 and 7 of 22 to a noisy machine), top-two agreement 0.00–0.20% on every one of the sixteen arms. The host had been rebooted an hour earlier with nothing else resident, and a sampler confirmed no other model loaded at any point during the run. replay=0.000 in every cell of all four campaigns, official drafter included.
Environment: MacBook Pro M4 Max 128 GB, macOS 26.6, Metal, 110afdd, DeepSeek-V4-Flash-...-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf, --temp 0 -n 256, short prompts. My codegen prompt is a repetitive Python if/elif chain — not yours, since it is not posted, so absolute values are not comparable with your 52–57 t/s; the orderings are what I would compare.
One correction to something I implied on 10 Aug: I described the residual as a small net loss "on high-acceptance content". On these numbers the loss is not a property of high acceptance — at 88.95% speculation is +12.7% and net_saved is +896 ms. It is a property of the drafter's cost relative to the margin, and my earlier phrasing pointed at the wrong variable.
This is a great catch, thank you — the drafter really was the unstated variable, and your framing ("acceptance-dependent, not content-dependent") is the more useful one since it's observable at runtime and the content type isn't.
A few things this changes for how I'd read my own report:
- The 83-89% crossover you found is more precise than my "85-92% band" — I only had one prompt straddling the boundary, you have four cells bracketing it tightly. Deferring to your number.
- The hash-column suggestion is a real gap in what I posted — I reported t/s deltas on my code-completion prompt without checking whether the three arms generated the same text. Given what you're seeing on your codegen prompt (three different outputs from three configs, none matching each other), I can't currently claim my -8.5%/+what-fully-off-gains numbers are comparing identical work rather than different workloads. Will re-run with hashes before trusting that number again, and agree it should be standard going forward.
- Confirms the mechanism reading, narrows the fix. If it's genuinely acceptance-dependent rather than content-dependent, the fix isn't "weaken the no-draft pause for code-like content" (which I couldn't have specified anyway) — it's "gate the immediate no-draft pause on a runtime acceptance estimate crossing ~85%ish" instead of firing unconditionally on the first no-draft cycle. That's a real, scopeable change rather than the content-dependent dead end I'd landed on.
One thing your report prompted on our end: the official 5.6 GiB support GGUF apparently just isn't as good a drafter as a mixed-precision conversion of the same checkpoint (69.93% vs 82.99% accept on your machine, same content). gguf-tools/deepseek4-quantize --dspark-support defaults DSpark's routed experts to IQ2_XXS/Q2_K (same aggressive default as the main model's routed experts) — the --experts/--routed-w1/--routed-w2/--routed-w3 overrides documented for the main conversion apply here too (same quant_policy struct, confirmed in source). If your 10.7 GiB conversion is roughly "the same tensors at meaningfully higher precision," that would track. Might attempt our own conversion at a higher precision tier and see if it reproduces your acceptance gap on different hardware — will report back if so, since a better official default drafter would sidestep a fair amount of this thread's economics on its own.
Preliminary data point, tests still in progress (haven't checked output-hash identity between arms yet, which per the discussion above is a real gap, not an oversight I'm ignoring) — but wanted to share since it looks like your finding generalizes to a second checkpoint.
Built a custom DSpark support GGUF for DS4 Vision-Exp (the recently-added vision checkpoint, separate DSpark module from the 0731 text model) using gguf-tools/deepseek4-quantize --dspark-support, same tool, --experts q4_k instead of the tool's default (IQ2_XXS/Q2_K, matching what the officially published support GGUF uses). Source: 3 of the 48 deepseek-ai/DeepSeek-V4-Flash-Vision-Exp shards containing the mtp.* tensors (~10.9 GiB, identified via the safetensors index rather than downloading the full checkpoint). Output is 11.4 GiB — close to the 10.7 GiB you reported for your own text-0731 conversion, so probably the same tier.
M5 Max, main@110afdd, --temp 0, 2 reps each (identical at temp=0):
| content | baseline | official drafter (5.6 GiB) | q4_k drafter (11.4 GiB) |
|---|---|---|---|
| code (Python if/elif chain) | 43.92 t/s | 46.2-46.5 t/s, 65.52% accept | 49.5-47.7 t/s, 72.22% accept |
| prose (water cycle, ~200 words) | 44.65 t/s | 35.4 t/s, 39.64% accept (net loss) | 36.3 t/s, 40.53% accept (still net loss, less bad) |
So: real win on code (higher acceptance, higher t/s than the official drafter, not just a wash), and on prose it's still fundamentally unprofitable at ~40% acceptance regardless of drafter — consistent with the acceptance-dependent picture from this thread rather than a drafter-fixes-everything story.
Next before I'd trust this further: hash the outputs across arms (your point applies here too), try --experts q8_0 (21.1 GiB) to see if there's more room or if q4_k already captures most of the gain, and check whether the officially published support GGUFs were quantized with an imatrix at all — if not, a calibrated imatrix might close some of this gap at the default bit-width rather than needing a bigger file. Will report back once that's done rather than treat this as conclusive.
Follow-up on the methodological gap I flagged in my last comment (whether the scheduler-off numbers reflected identical generated text, or partly a different workload).
I ran the hash check across both drafters (official Vision-Exp DSpark support GGUF, and my Q4_K conversion of its routed experts) against non-speculative baseline, --temp 0, on 4 prompts:
| prompt | baseline vs official drafter | baseline vs Q4_K drafter |
|---|---|---|
| code (repetitive if/elif chain) | identical | identical |
| prose (water cycle) | identical | diverges |
| prose (why the sky is blue) | identical | diverges |
| prose (fall of Rome) | diverges | diverges (3rd distinct hash) |
The interesting part: the official drafter also diverges from true greedy on the Rome prompt. So this isn't something my Q4_K conversion introduces — it looks like DSpark's batched-verify path on Metal simply isn't bit-exact with sequential single-token decode, for either drafter. Read the actual diverged text (not just the hash) on two of these: in both cases it's a single early token flip, then a fully coherent, grammatical, factually-correct continuation from there — consistent with a near-tied top-1/top-2 logit at one position getting flipped by a tiny floating-point difference between the batched matmul reduction and the sequential one, rather than any kind of corruption.
My working theory for why the Q4_K drafter hits this more often (3/3 prose prompts vs official's 1/3): higher acceptance means longer accepted draft runs get committed per batched-verify call, so more token positions per cycle are exposed to the batched-vs-sequential numerical difference. If that's right, it's a direct consequence of a drafter being better (longer accepted runs), not a quality defect in the drafter itself — and it would apply to any future higher-acceptance drafter, mine or someone else's.
Practical takeaway for anyone reading this thread for the "should I build my own drafter" question: the acceptance/throughput gains from a higher-precision custom drafter are real and reproducible (this is on top of my earlier numbers: 72.22% vs 65.52% accept rate on Vision-Exp code content, 11.4GB Q4_K vs 5.6GB official). But DSpark was never bit-exact with non-speculative decode at --temp 0 for any drafter — this data just quantifies that a better drafter increases how often you'll notice it, since it's proportional to accepted-run length rather than to drafter quality per se.
Not proposing a fix here — flagging it as a data point since it's directly relevant to comparing "before/after drafter" throughput numbers on identical work, which is exactly the methodological question this thread has been chasing.
Follow-up with a concrete, actionable lever for anyone hitting the break-even problem this thread is about: --dspark-confidence.
Quick recap of what it does (from source, ds4.c): it makes the drafter self-truncate a draft block early once sigmoid(confidence_logit) at a given position drops below the threshold, instead of always proposing the full block. Default is 0.0, which disables the gate entirely (always propose full-length, let the verifier sort it out).
Swept it 0.0→0.99 on the same code-completion prompt I used for the hash-check above (--temp 0, my Q4_K Vision-Exp drafter, M5 Max):
| confidence | gen t/s | accept_rate | net_saved (ms) |
|---|---|---|---|
| 0.0 (default) | 45.01 | 56.14% | -88.8 |
| 0.5 | 44.49 | 54.42% | -144.0 |
| 0.7 | 45.84 | 59.08% | +28.2 |
| 0.8 | 50.98 | 82.19% | +702.9 |
| 0.85 | 51.18 | 88.46% | +745.7 |
| 0.9 | 49.87 | 92.55% | +584.2 |
| 0.95 | 49.51 | 98.94% | +531.6 |
| 0.99 | 43.39 | 70.00% | -335.9 |
| no-dspark baseline | 45.67 | — | — |
It's a sharp inverted-U, not monotonic: below ~0.7 the gate actively hurts (worse than leaving it off), there's a wide profitable plateau at 0.8-0.95, a clear peak around 0.85 (+12% over no-dspark, +14% over default), and it collapses hard by 0.99 (drafter proposes almost nothing — proposed=10 over 284 cycles in my run — pure per-cycle overhead with no payoff, worse than not using DSpark at all).
On prose (marginal/unprofitable content in this thread's terms) the same sweep only shrinks the loss, never flips it: -965ms at 0.0 down to -209ms at 0.99, asymptotically approaching but never beating the no-dspark baseline — there's a fixed per-cycle propose/setup cost paid even when the drafter declines to propose anything.
So this doesn't replace the scheduler discussion in this thread (content that's fundamentally unprofitable for DSpark stays unprofitable), but for content where DSpark's accept rate is marginal-but-positive (my code prompt was net-negative at default settings before tuning this), raising --dspark-confidence into the 0.8-0.95 band can flip it to a clear win without any code changes — worth trying before concluding a given workload just isn't a good DSpark fit. Also a useful independent variable to control for in any future scheduler-threshold experiments on this thread, since it changes draft length distribution directly rather than reactively pausing after the fact.
Closing the loop on the drafter-quality thread I've been running here (custom Q4_K Vision-Exp drafter, hash-check, --dspark-confidence sweep above): I validated the whole thing against real traffic and the headline win doesn't survive contact with temp>0.
Quick summary for anyone following this thread end to end:
- Custom Q4_K drafter: real, reproducible improvement over the official IQ2_XXS/Q2_K support GGUF (72-88% vs 56-65% accept rate depending on confidence, same content) — this part holds up.
--dspark-confidencesweep: at--temp 0, a sharp, well-defined optimum (0.85 on my content) turning a marginal/losing setup into a clear +12-14% win — this also holds up, but only at--temp 0.- Validated against real traffic at my actual setting (
temp=1.0): the win disappears entirely. Same drafter, same confidence value, same prompt (including the exact repetitive prompt that won +12% attemp 0), through both the CLI and the real HTTP server (ds4-server,--batched-session 1and4, with and without--vision) — no measurable gain anywhere. - Tried
--mtp-exact-sampling(the path meant for correcttemp>0accept/reject) as the fix: it's not just neutral, it's consistently worse than no-DSpark at every--dspark-confidencevalue I tried (0.0 through 0.9), by 4% to 25% depending on the value, with high seed-to-seed variance on top.
Full data and reproduction steps: I originally opened a separate issue for this (#951) but it turned out to duplicate an existing thread I'd forgotten about — #913 already has this exact finding (including a -5.9% average at temp=1.0 on ordinary traffic), and I've added the confidence-sweep + code-level cost analysis there instead: https://github.com/antirez/ds4/issues/913#issuecomment-5514772305
Practical upshot for my own setup: DSpark stays off in production. The scheduler discussion in this thread is still valid and worth pursuing for whenever/if the temp>0 accept-path performance gets addressed, but right now it's moot for me since there's no profitable regime to schedule around at my actual sampling temperature.