DSpark: neither accept path (opportunistic or --mtp-exact-sampling) nets a win at temp>0, across the full confidence range
Summary
Following up on the drafter-quality/scheduler work in #695: I built a higher-precision DSpark drafter for DeepSeek-V4-Flash-Vision-Exp (Q4_K routed experts instead of the official IQ2_XXS/Q2_K) and swept --dspark-confidence at --temp 0, finding a clean, reproducible +12-14% throughput win in that regime. When I validated the same configuration against real traffic at --temp 1.0 (my actual production sampling setting), the win completely disappeared. Digging further, neither DSpark accept path currently gives a net win at temp>0 on this hardware/model — the default "opportunistic" (greedy-argmax) path is a wash at best, and --mtp-exact-sampling (the path meant for proper temp>0 sampling) is consistently worse than not using DSpark at all, across its entire useful --dspark-confidence range.
Setup
- Hardware: Apple M5 Max, 128 GB unified memory, Metal backend
- Build:
main@110afdd - Model: DeepSeek-V4-Flash-Vision-Exp (
IQ2_XXS/w2Q2K/AProjQ8/SExpQ8/OutQ8) - Drafter: custom
--dspark-supportconversion with--experts q4_k(routed experts only override; same metadata as the official support GGUF —stages=3 block=5 markov_rank=256). Built and validated on #695; the official (lower-precision) support GGUF shows the same qualitative pattern below, just with a lower baseline accept rate. - Prompt: fixed code-completion prompt (repetitive Python
if/elifchain over HTTP status codes), 300 generated tokens,DS4_DSPARK_STATS=1for internal accept-rate/timing stats.
Part 1 — the opportunistic (default) path: greedy gain doesn't transfer to temp=1.0
At --temp 0 (deterministic), sweeping --dspark-confidence gives a clean, wide, reproducible profitable band:
| confidence | gen t/s | accept_rate | net_saved (ms) |
|---|---|---|---|
| 0.0 (default) | 45.01 | 56.14% | -88.8 |
| 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 | — | — |
Re-running the identical config and prompt at --temp 1.0 (5 seeds, --dspark-confidence 0.85): accept_rate drops from 88.46% to a 68-76% range, and net_saved becomes a wash (mix of small positive/negative, average close to zero). This reproduces cleanly through the real HTTP server too (ds4-server, /v1/chat/completions, temperature: 1.0) — I get no measurable difference vs no-DSpark on several real prompts, including the exact same repetitive prompt that won +12% at --temp 0. I ruled out --batched-session count (tested 1 and 4, no difference) and --vision (tested with/without, gain persists fine at --temp 0 either way) as confounds — temperature alone is the variable that kills the gain.
This makes sense given the accept criterion: without --mtp-exact-sampling, DSpark commits draft tokens only while they match the target's greedy argmax, regardless of the request's actual sampling temperature (ds4_session_eval_speculative_argmax, gated by opportunistic_dspark in ds4.c). At temp=0 the real generation is greedy, so this is a great proxy. At temp=1.0, the actually-sampled trajectory increasingly diverges from the target's own greedy continuation as tokens accumulate — accept rate craters purely from this mismatch, independent of drafter quality or confidence tuning.
Part 2 — --mtp-exact-sampling: not just a wash, consistently worse
Given the above, I tried the path that should handle temp>0 correctly: --mtp-exact-sampling (routes to ds4_session_eval_dspark_speculative_stochastic). Full --dspark-confidence sweep at --temp 1.0, 5 seeds each, same prompt:
| confidence | avg gen t/s (n=5) | vs no-dspark baseline (45.33 t/s avg, n=5) |
|---|---|---|
| 0.0 (gate disabled) | 34.11 | -24.7% |
| 0.3 | 36.63 | -19.2% |
| 0.5 | 36.96 | -18.4% |
| 0.7 | 43.47 | -4.1% |
| 0.85 | 39.10 | -13.7% |
| 0.9 | 35.20 | -22.3% |
| default (auto 0.8, n=3) | 45.20 avg, but net_saved avg -611.9ms, huge run-to-run spread (42.85-49.19 t/s) | ~flat but unreliable |
No confidence value recovers a win. Best case is roughly break-even (0.7); everything else ranges from a mild to severe regression. Variance across seeds at fixed confidence is also large (e.g. 0.85: 35.67-43.30 t/s depending only on RNG seed), which looks like a structural property of stochastic accept/reject rather than measurement noise.
Where the extra cost is going, from reading ds4_session_eval_dspark_speculative_stochastic (ds4.c, starting ~line 70283): for every draft position after the first, the verify loop does, sequentially:
metal_graph_read_spec_logits_row(&s->graph, (uint32_t)(i - 1), s->spec_row_logits);
sample_build_probabilities(s->spec_row_logits, DS4_N_VOCAB, temperature, top_k, top_p, min_p, s->sample_probs);
speculative_point_accept(s->sample_probs[drafts[i]], 1.0f, rng);
i.e. a full-vocabulary logits readback from GPU plus a full probability-distribution build (temp/top_k/top_p/min_p) per draft position, one at a time — versus the opportunistic path's much cheaper per-position argmax-token-ID comparison. The opportunistic path also has a dedicated full/partial-accept fast-commit optimization (DS4_DSPARK_FULL_ACCEPT_FAST_COMMIT, #746); the stochastic path does increment the same direct_full_commits/direct_partial_commits counters on a full accept, so it isn't skipping that bookkeeping, but the per-position verify cost above is paid regardless of whether the block ends up fully accepted. I haven't done a cycle-level profiling breakdown to attribute the exact percentage to this specific readback pattern vs. other factors, so I'm presenting it as the most likely driver rather than a proven root cause — happy to dig further if useful.
Why this seems worth a separate issue from #695
#695 is about the DSpark scheduler's pause heuristics assuming DSpark is profitable in the first place; this issue is upstream of that — on this hardware/model, at temp>0, I can't find any configuration (drafter precision, confidence threshold, accept path) where DSpark nets a win at all. The +3.8/+7.5% numbers on #913 were measured in greedy mode too, so I don't think this contradicts that data, but it does mean DSpark's real-world value for temp>0 (i.e. most actual usage) is currently unverified at best, possibly negative, and the exact-sampling path in particular looks like it needs its own performance pass rather than just threshold tuning.
Reproduction
# opportunistic path, temp sweep
./ds4 --dspark -m <vision-exp.gguf> --mtp-model <dspark-support.gguf> --dspark-confidence 0.85 --temp 0 --tokens 300 --nothink -p <repetitive-code-prompt>
./ds4 --dspark -m <vision-exp.gguf> --mtp-model <dspark-support.gguf> --dspark-confidence 0.85 --temp 1.0 --seed N --tokens 300 --nothink -p <repetitive-code-prompt>
# exact-sampling path
./ds4 --dspark -m <vision-exp.gguf> --mtp-model <dspark-support.gguf> --mtp-exact-sampling --dspark-confidence <C> --temp 1.0 --seed N --tokens 300 --nothink -p <repetitive-code-prompt>
DS4_DSPARK_STATS=1 for the internal accept-rate/timing breakdown shown above.
Happy to share the exact prompt file or run more content types/seeds if that'd help narrow this down.
Duplicate of the temp>0 DSpark finding already tracked in #913 (I'd forgotten this thread existed when I opened this). Moved the additional data (full confidence sweep, code-level cost analysis) there: https://github.com/antirez/ds4/issues/913