DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation

framework dspark
speculative-decodingsemi-autoregressive-drafterMTPconfidence-scheduled-verificationthroughput-schedulingverification-scheduling

DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation #

1. TL;DR #

DSpark bolts a lightweight sequential head (Markov or RNN) onto a parallel draft backbone (DFlash) to inject intra-block token dependency and stop suffix decay, then adds a calibrated confidence head + hardware-aware scheduler that prunes verification length per request to maximize throughput. +16–30% accepted length offline; 60–85% faster per-user generation vs MTP-1 in DeepSeek-V4 production.


2. Q1 / Q2 / Q3 #

Q1 — 痛点 (the two bottlenecks of large parallel draft blocks) #

Parallel drafters generate all $\gamma$ tokens in one forward pass, so drafting latency is nearly independent of block size — but this creates two failures when you actually try to exploit long blocks:

  1. Quality bottleneck (acceptance decay). Because each draft position is predicted independently, the drafter cannot model inter-token dependency. When the context admits multiple plausible continuations ("of course" vs "no problem"), a parallel model marginalizes over all predecessors and can emit incoherent cross-mode combinations ("of problem"). This multi-modal collision makes conditional acceptance decay rapidly deeper into the block.
  2. System bottleneck (verification waste). Producing more draft tokens does not translate to end-to-end speedup. Verifying every proposed token indiscriminately burns target-model batch capacity. The right verification length varies along two axes: data (code sustains higher acceptance than open-ended chat) and load (verifying an extra token is nearly free under light load, but under heavy concurrency it steals batch capacity from other active requests).
  3. The latency model that frames everything is Eq. 1:

    $$L = \frac{T_{\text{draft}} + T_{\text{verify}}}{\tau}$$

    with three levers — lower $T_{\text{draft}}$ (draft faster), raise $\tau$ (draft better), or shrink effective $T_{\text{verify}}$ (verify smarter). Autoregressive drafters get high $\tau$ but pay $T_{\text{draft}} \propto \gamma$; parallel drafters collapse $T_{\text{draft}}$ but sacrifice $\tau$.

    Q2 — 方法 (two complementary mechanisms) #

    • Semi-autoregressive generation. Keep the heavy parallel backbone (DFlash) fully parallel for $\tau$-cheap bulk computation, and append a lightweight sequential head that adds a prefix-dependent transition bias $B_k$ so each position can condition on the actually-sampled prefix. Crucially the head uses local (per-position) softmax normalization, not a global partition function, so exact per-token probabilities remain computable for lossless rejection sampling.
    • Confidence-scheduled verification. A confidence head emits per-position survival probability $c_k$, calibrated via Sequential Temperature Scaling (STS). A hardware-aware prefix scheduler then casts verification-length selection as a global throughput-maximization problem $\Theta = \tau \cdot \text{SPS}(B)$ solved by a greedy, early-stopping admission over survival probabilities — routing target compute only to tokens with positive expected return.

    核心技术壁垒 (the single hardest-to-replicate insight): achieving load-aware, lossless verification-length scheduling. The scheduler must consume absolute-magnitude calibrated survival probabilities (not just rankings) to estimate $\tau$, yet the greedy search's early-stopping is exactly what preserves the non-anticipating property (admission of token $k$ must not depend on the realization of $x_k$). The genuinely subtle part — and the one that would trip a re-implementer — is that in production the early-stopping break is removed for jagged-hardware reasons, and losslessness is instead restored by an asynchronous "two-steps-prior" causal barrier. Getting this interaction right (calibration ↔ greedy monotonicity ↔ causality ↔ ZOS compatibility) is the moat.

    Q3 — 结果 #

    • Offline: DSpark is best in every cell of Table 1 (4 targets × 9 benchmarks). Macro-average accepted length improves over Eagle3 by 30.9% / 26.7% / 30.0% (Qwen3-4B/8B/14B) and over DFlash by 16.3% / 18.4% / 18.3%. The gap over DFlash widens with block size (16% → 30% on math from $\gamma{=}7$ to $\gamma{=}15$).
    • Ablation: a 2-layer DSpark beats a 5-layer DFlash across all domains; the sequential head adds only 0.2–1.3% round latency for up to 30% accepted-length gain. STS cuts ECE from 3–8% to ~1% while preserving AUC 0.81–0.90.
    • Production (DeepSeek-V4): vs MTP-1, 60–85% (V4-Flash) / 57–78% (V4-Pro) faster per-user generation at matched throughput; the scheduler expands verification budget to 4–6 tokens under light load and shrinks it under heavy load, shifting the throughput–interactivity Pareto frontier outward.

    3. 架构 / 方法图 #

    No figures were extracted for this source; the decoding cycle (paper's Figure 1) and the two-module data path are reconstructed below as Mermaid diagrams.

    Decoding cycle (prompt ABC → anchor D → draft EFGH → schedule → verify):

    flowchart LR subgraph Target1["Target step 1"] ABC["prompt ABC"] --> D["anchor D"] end subgraph Draft["Draft phase"] D --> PB["Parallel backbone (DFlash, 5L)"] PB -->|"h_k, U_k"| SH["Sequential head (Markov)"] SH -->|"sample E F G H"| CH["Confidence head c1..c4"] end CH --> SCH["Hardware-Aware Prefix Scheduler"] SCH -->|"keep EFG, drop H"| Verify["Target step 3: verify EFG"] Verify -->|"accept E,F; reject G"| Gstar["target emits corrected G*"] Gstar -->|"next round anchor"| PB

    The parallel backbone does the expensive work once per block; the sequential head runs a cheap left-to-right loop to inject dependency; the confidence head scores each position; the scheduler truncates the block before it reaches the target model, so the target only verifies a load-appropriate prefix.

    Two-module composition (where each equation lives):

    flowchart TB A["anchor x0 + (gamma-1) masks"] --> B["Parallel backbone: h_k, base logits U_k (Eq. modification: anchor = position 1)"] B --> C["Sequential head: bias B_k -> p_k = softmax(U_k + B_k) (Eq. 4)"] C -->|"Markov: B = W1[x_{k-1}] W2 (Eq.5)"| C C -->|"RNN: gated state s_k (Eq.6)"| C B --> E["Confidence head: c_k = sigma(w^T [h_k; W1[x_{k-1}]]) (Eq.7)"] C --> E E --> F["STS calibration of cumulative product prod c_i"] F --> G["Scheduler: maximize Theta = tau * SPS(B) (Alg.1)"]

    Note the parameter coupling: the confidence head (Eq. 7) reuses the Markov embedding $W_1$ from the sequential head as a feature, so it conditions on the actually-sampled predecessor at essentially no extra parameter cost.


    4. 作者证明 #

    DSpark has one formal theoretical result (Appendix A losslessness counterexample) plus a set of analytical identities the design rests on. Notation table:

    SymbolMeaning
    $M_t, M_d$target / draft model
    $\gamma$draft block size (proposal length)
    $x_0$anchor (bonus) token from previous cycle
    $U_k$base logit vector from parallel backbone at position $k$
    $B_k$prefix-dependent transition bias from sequential head
    $p^d_k, p^t_k$draft / target distribution at position $k$
    $\tau$accepted tokens per cycle
    $c_k \in (0,1)$predicted per-position survival prob (given prefix accepted)
    $c^*_k$analytical (ground-truth) per-step acceptance rate
    $a_{r,j}=\prod_{i\le j}c_{r,i}$prefix survival probability of request $r$ at position $j$
    $\text{SPS}(B)$profiled engine throughput (steps/sec) at batch $B$
    $\Theta = \tau\cdot\text{SPS}(B)$expected system token throughput

    方程物理意义 (key equations):

    • Local factorization (Eq. 4): $P(X\mid x_0)=\prod_k p_k(x_k\mid x_0,x_{per-position (not a global energy model), exact per-token probabilities survive — the property that CRF-NAT and CTC-drafter lack.
    • Analytical acceptance label (Eq. 8): $c^*_k = 1 - \tfrac12\lVert p^d_k - p^t_k\rVert_1$. This is the standard rejection-sampling identity used both as the confidence-head supervision label and as the TV loss's justification.
    • Throughput objective: $B=\sum_r(1+\ell_r)$, $\tau=\sum_r(1+\sum_{j=1}^{\ell_r}a_{r,j})$, $\Theta=\tau\cdot\text{SPS}(B)$.

    Monotonicity / greedy-optimality proposition (§3.2.2, informal). Statement: because $a_{r,j}\le a_{r,j-1}$ (survival probability is non-increasing in $j$), the marginal gain of extending request $r$ from $j-1$ to $j$ is exactly $a_{r,j}$. Therefore, for a fixed batch size $B$, the optimal length allocation is obtained by greedily admitting the globally-highest-$a_{r,j}$ tokens; sorting descending by $a_{r,j}$ automatically respects intra-block prefix ordering. Assumption: stepwise early-stopping yields the global-max $\Theta$ iff $\Theta$ is unimodal in $B$, which requires a smoothly decaying SPS curve. When it breaks: real hardware SPS is jagged/step-wise (tensor-core tile quantization), so the unimodality assumption fails in production — addressed in §7 below.

    Losslessness counterexample (Appendix A, reproduced). Setup: $R=1$, $\gamma=2$, $a_1=0.8$, capacity $\text{SPS}(1)=1.0,\ \text{SPS}(2)=0.5,\ \text{SPS}(3)=0.45$.

    $$\Theta_0 = 1\cdot 1.0 = 1.0, \qquad \Theta_1 = (1+0.8)\cdot 0.5 = 0.9.$$

    Without early-stopping the scheduler evaluates $\Theta_2$, but $c_2$ (and thus $a_2=a_1 c_2$) depends on the realization of $x_1$: if $c_2=0.9$ then $\Theta_2=(1+0.8+0.72)\cdot0.45=1.134$ (returns $\ell=2$, admits $x_1$); if $c_2=0$ then $\Theta_2=0.81$ and the max stays $\Theta_0$ (returns $\ell=0$, rejects $x_1$). So admission of $x_1$ depends on $x_1$ — selection bias. Made explicit with vocab $\{A,B\}$, $p^t=(0.7,0.3)$, $p^d=(0.5,0.5)$: acceptance $\sum_x\min(p^t,p^d)=0.8$ matches $a_1$. The retrospective scheduler yields

    $$\Pr(Y=A) = 0.5\cdot 1 + 0.5\cdot 0.7 = 0.85 \ne p^t(A)=0.7,$$

    proving the global-search scheduler is not lossless. Early-stopping fixes it: since $\Theta_1<\Theta_0$, the scheduler halts at $\ell=0$ before touching any $x_1$-dependent quantity, restoring the non-anticipating property.

    Six minimum checks:

    1. Units. $L$ = time/token: numerator wall-clock time, denominator dimensionless token count — consistent.
    2. Boundary $\gamma{=}1$. DSpark reduces to a single-position parallel prediction with no sequential loop; matches the MTP-1 single-token regime it is compared against.
    3. Boundary $B_k\equiv 0$. Sequential head off → $p_k=\text{softmax}(U_k)$, i.e. pure DFlash — the stated backbone, sanity-consistent.
    4. Probability range. $c_k=\sigma(\cdot)\in(0,1)$; $c^*_k=1-\tfrac12\lVert\cdot\rVert_1\in[0,1]$ since $\lVert p^d-p^t\rVert_1\in[0,2]$ — labels and predictions share a valid range for BCE.
    5. Monotone survival. $a_{r,j}=\prod_{i\le j}c_{r,i}$ with $c_i\in(0,1)$ ⇒ non-increasing in $j$, exactly the property the greedy proof needs.
    6. Loss-weight extremes. With $\alpha_{\text{ce}}=0.1,\alpha_{\text{tv}}=0.9,\alpha_{\text{conf}}=1.0$, TV dominates draft quality while confidence loss (absolute-largest weight) forces calibrated scores; setting $\alpha_{\text{conf}}=0$ recovers a scheduler-less drafter — degrades gracefully.

    7. 5. 实验与数据 #

      No figures were extracted; the load-bearing tables/plots are reproduced numerically below.

      Table 1 — accepted length $\tau$ per round (scheduler disabled, fixed block). DSpark is bold/best in every cell.

      TargetDrafterGSM8KMATHAIME25MBPPHumanEvalLCBMT-BenchAlpacaArena-Hard
      Qwen3-4BEagle35.144.623.923.694.163.772.392.262.55
      Qwen3-4BDFlash5.404.854.154.404.744.183.072.962.83
      Qwen3-4BDSpark6.115.704.895.135.384.863.643.543.29
      Qwen3-8BEagle35.304.773.913.964.334.172.662.542.54
      Qwen3-8BDFlash5.334.914.074.364.644.393.112.982.81
      Qwen3-8BDSpark6.175.785.015.165.525.173.723.583.21
      Qwen3-14BEagle35.244.603.713.814.144.012.622.472.48
      Qwen3-14BDFlash5.414.843.984.444.594.333.102.942.72
      Qwen3-14BDSpark6.215.744.945.265.435.023.703.583.13
      Gemma4-12BEagle35.875.464.834.725.374.163.193.062.72
      Gemma4-12BDFlash5.455.044.224.394.953.702.982.842.59
      Gemma4-12BDSpark6.055.785.125.115.644.513.493.352.92

      The table also exposes a strong domain effect (Qwen3-4B: ~5.6 math, ~5.1 code, ~3.5 chat). This inherent variance is what makes a static verification length wasteful and directly motivates the scheduler.

      Position-wise conditional acceptance (Fig. 2, numeric). With the penalty of earlier rejections removed, Eagle3 is flat/rising with position while DFlash decays:

      • Position-1 capacity gap (deeper parallel net wins): DFlash 0.88 vs Eagle3 0.81 (Math); 0.72 vs 0.53 (Chat).
      • Tail behavior: Eagle3 rises 0.53→0.74 (Chat) leveraging conditional certainty; DFlash decays 0.87→0.78 (Code), 0.72→0.63 (Chat) via multi-modal collision.
      • DSpark inherits the high start (0.93 Math) and stays flat — combining both regimes. This is the empirical core of the counter-intuitive "parallel beats AR" result: position 1 has the highest leverage under prefix-survival, so a deep parallel drafter's initial-token advantage dominates.

      Depth & length ablations (Fig. 3/4, numeric).

      • 2-layer DSpark > 5-layer DFlash across all domains; steepest marginal gain is 1→2 layers ("a little autoregression goes a long way").
      • Gap widens with $\gamma$: at $\gamma{=}7$ DSpark beats DFlash by +16% (math) / +15% (code) / +18% (chat); at $\gamma{=}15$ by +30% / +26% / +22%.
      • Latency overhead of the sequential loop (batch 128, context-length-averaged): only +0.2% to +1.3% full-round latency from $\gamma{=}4$ to $16$.
      • RNN head gives only marginal gains over Markov, mostly at long $\gamma$; Markov is default for deployment simplicity.

      Confidence-head validation (Fig. 5/6, numeric).

      • Static threshold sweep: raising the confidence threshold lifts overall acceptance by pruning doomed suffixes. Most dramatic on chat: 45.7% → 95.7%; milder on structured tasks (Math 76.9%→92.5%, Code 67.6%→92.0%).
      • Reliability (Alpaca): raw head has strong discrimination (AUC 0.818/0.812/0.864/0.907 at positions 1/3/5/7) but is overconfident (ECE 3–8%). STS cuts ECE to ~1% (e.g. position 3: 8.2%→1.7%) while, being order-preserving, leaving AUC intact.

      Production (Fig. 7/8, numeric).

      • Throughput–interactivity frontier vs MTP-1. V4-Flash: +51% throughput at 80 tok/s/user SLA; at the stricter 120 tok/s/user SLA a nominal +661% (the baseline collapses to a tiny batch — authors explicitly caveat this as frontier-extension, not a representative speedup). At matched throughput: 60–85% faster per user.
      • V4-Pro: +52% at 35 tok/s/user; nominal +406% at 50 tok/s/user SLA; 57–78% faster per user at matched capacity.
      • Load-adaptive budget (Fig. 8): under moderate concurrency the scheduler expands verification from MTP-1's static 2 tokens to ~4–6 tokens; as concurrency saturates it smoothly shrinks the budget to protect batch capacity.

      6. 论证链 #

      #StepPaper-internal support
      1Per-token latency is $L=(T_{\text{draft}}+T_{\text{verify}})/\tau$, giving three optimization levers.Eq. 1 (§2.1)
      2Parallel drafters collapse $T_{\text{draft}}$ but lose $\tau$ because independent positions cause multi-modal collision and suffix decay.§3.1 para 1; Fig. 2 tail decay (§4.3.1)
      3Adding a locally-normalized sequential bias $B_k$ (Eq. 4–6) restores intra-block dependency while keeping exact per-token probabilities and near-parallel speed.Eq. 4–6 (§3.1); latency +0.2–1.3% (Fig. 4)
      4This yields both high position-1 acceptance and a flat tail, so accepted length beats both AR and parallel baselines.Fig. 2 + Table 1 (§4.2–4.3.1)
      5But longer accepted blocks don't help throughput unless verification is load-aware; a confidence head (Eq. 7) supervised by the TV-distance acceptance rate (Eq. 8) predicts survival probability.§3.2.1; Fig. 5 pruning
      6The scheduler must consume absolute calibrated probabilities to estimate $\Theta=\tau\cdot\text{SPS}(B)$; STS calibrates cumulative products to ~1% ECE without disturbing rankings.§3.2.1; Fig. 6
      7Verification-length selection is then a throughput-max problem solvable greedily by survival-probability monotonicity, with early-stopping guaranteeing losslessness.Alg. 1 (§3.2.2); Appendix A counterexample
      8In production, jagged SPS + ZOS force removing early-stopping; an asynchronous two-steps-prior "causal barrier" restores losslessness, shifting the DeepSeek-V4 Pareto frontier.§5.2; Fig. 7/8 (§5.4)

      7. 实现 cross-reference #

      The paper open-sources DSpark checkpoints (DeepSeek-V4-Flash/Pro preview) and DeepSpec, an algorithm-driven training repository including Eagle3, DFlash, and DSpark (github.com/deepseek-ai/DeepSpec). Specific file:line citations to the released training/inference code are not enumerated in the L1 source. [实现未公开 — 代码仓库已开源但 L1 未记录具体 file:line]

      核心技术壁垒 (dedicated paragraph). The load-bearing, hard-to-replicate insight is the interaction between calibration, greedy monotonicity, and causality under a real serving pipeline. The scheduler needs absolute-magnitude survival probabilities (Fig. 6 shows raw scores are 3–8% overconfident and would distort $\tau$ estimation), so STS calibration is a prerequisite, not a nicety. The greedy admission is only optimal because $a_{r,j}$ is monotone; and losslessness hinges on the non-anticipating property, which the offline algorithm secures with an early-stopping break (Appendix A shows removing it yields output $(0.85,0.15)\ne(0.7,0.3)$). Production then removes that break to escape jagged-SPS local minima — and re-earns losslessness only because the asynchronous scheduler evaluates predictions from two steps prior, forming a temporal causal barrier that isolates the admission decision from the current token's realization (§5.2). Reproducing DSpark's headline production numbers requires getting all four of these to hold simultaneously alongside ZOS/CUDA-graph compatibility.

      关键实现细节 (easy-to-miss tricks):

      1. Anchor-as-first-position modification. Instead of DFlash's "anchor + $\gamma$ masks predict only mask positions," DSpark treats the anchor itself as the first prediction position, so $\gamma$ input tokens yield $\gamma$ draft logits — reducing draft compute at similar quality (§3.1).
      2. Confidence head reuses the Markov embedding $W_1$. Eq. 7 features are $[h_k; W_1[x_{k-1}]]$, sharing the sequential head's low-rank embedding table so the confidence estimator conditions on the sampled predecessor almost for free (§3.2.1).
      3. Variable-length execution via a marker tensor. Rather than padding variable verified-prefix lengths, all tokens across requests are flattened and processed identically; intra-sequence dependencies are conveyed by a marker tensor in the sparse-attention kernel — on DeepSeek-V4 only the index-attention and compress kernels need modification (§5.3).
      4. SPS cost table profiled once at init. The $\text{SPS}(B)$ capacity curve is measured once during engine initialization and stored as a lightweight table, making the scheduler's throughput lookup $O(1)$ (§3.2.2).