Test-Time Speculation

Avinash Kumar, Sujay Sanghavi, Poulami Das

TL;DR

Speculative decoding accelerates LLM inference but fails on long-response tasks because the draft model's accuracy degrades over extended sequences. This paper introduces Test-Time Speculation (TTS), an online distillation method that continuously updates the draft model during inference using the target model's verification outputs. TTS increases the draft acceptance length by up to 72% (41% on average), unlocking significant speedups for long-context generation.

What Problem Does This Paper Address?

Speculative decoding is a popular technique to speed up Large Language Model (LLM) inference. It uses a small, fast "draft" model to generate a sequence of candidate tokens, which a large, slow "target" model then verifies in parallel. The efficiency of this process hinges on the acceptance length—the number of tokens the target model accepts per round.

However, the authors discover a critical flaw in state-of-the-art speculators (like DFlash, EAGLE-3, and PARD): their acceptance length degrades drastically as the generation length grows, often dropping close to 1 (meaning no speedup) after just a few thousand tokens. This happens because draft models are trained offline on short sequences (typically $\le$ 2K tokens) but are forced to extrapolate to much longer outputs at inference time. This distribution mismatch causes the draft model's predictions to progressively diverge from the target model.

Figure 1: (a) Acceptance length (AL) for the LiveCodeBench dataset on Qwen3-8B with increasing output lengths for three speculators. Beyond a certain number of output tokens, the draft model fails to accurately approximate the target model and the AL becomes vanishingly low (too close to 1), yielding practically no benefits. (b) Our proposal, Test-Time Speculation (TTS), adapts the draft model in real-time to address this limitation and consistently improves acceptance lengths.

Methods

To bridge this distribution gap, the authors propose Test-Time Speculation (TTS). TTS turns the standard token verification step into an online, on-policy distillation process at no additional target-model cost.

When the target model verifies the draft tokens, it naturally computes its full probability distribution over those tokens. TTS leverages this "free" supervision signal by treating the target model as a teacher and the draft model as a student.

The core components of TTS include:

  1. Online Distillation Loss: After each verification round, the draft model undergoes a single gradient update step using a loss function that combines an approximate KL-divergence (matching the target's distribution) and a regularization term (preventing the draft from drifting too far from its initial state).
  2. Strided Updates: Instead of updating the draft model every single round—which introduces high computational overhead—TTS runs updates every $S$ rounds (e.g., $S=5$ or $10$).
  3. Asynchronous Pipelining: To keep the backward pass and optimizer steps off the critical path of inference, TTS offloads the draft model updates to a dedicated, parallel CUDA stream.

Datasets

The authors evaluated TTS across eight rigorous benchmarks that require long-form generation and complex reasoning:

  • Competition Mathematics: AIME 2024, AIME 2025, MATH-500, and OlympiadBench-Math.
  • Physics: OlympiadBench-Physics.
  • Scientific Reasoning: GPQA Diamond (graduate-level multiple-choice questions).
  • Theorem Application: TheoremQA.
  • Code Generation: LiveCodeBench (v6).

No new benchmarks were introduced, but the selected datasets specifically elicit long output lengths ranging up to 32K tokens.

Key Insights and Ideas

  • The Target Gets Confident, the Draft Gets Lost: As generation proceeds, the target model's distribution entropy actually decreases, meaning it becomes more confident and predictable. Conversely, the draft model's cross-entropy sharply increases because it cannot handle the long context window.
  • Free Supervision Signal: The target model already evaluates the full draft canvas in a single forward pass during standard speculative decoding. TTS realizes that this intermediate computation is exactly what is needed for distillation, meaning we don't need extra forward passes from the heavy target model to train the draft.
  • Less is More for Real-Time Tuning: The authors found that performing multiple optimization steps per round degrades performance. A single gradient step ($K=1$) generalizes best, preventing the draft model from overfitting to the immediate verification round.

Key Results

  • Substantial Acceptance Length Gains: TTS consistently outperforms vanilla speculators across all benchmarks. It improves mean acceptance lengths by up to 72% (41% on average) over DFlash and up to 67% (34% on average) over EAGLE-3.
  • Compounding Benefits over Time: Because TTS accumulates training signals as generation proceeds, its benefits scale with sequence length. For instance, on LiveCodeBench, the acceptance length improvement is only 17% for the first 10K tokens but skyrockets to 245% in the 20K–30K token range.
Figure 2: Acceptance Length of four tasks using (a) DFlash, (b) EAGLE-3, and (c) PARD speculators on the Qwen3-8B model. It consistently reduces with increasing output generation lengths.
  • Wall-Clock Speedups: When balancing the trade-off between acceptance length and update overhead, an update stride of $S=5$ achieved the highest mean throughput, yielding up to a 1.71× speedup over vanilla DFlash on the massive Qwen3.5-122B model.

Limitations and Future Work

  • Kernel Optimization: The gradient updates are currently implemented using standard PyTorch kernels. Fusing these into a custom CUDA/Triton kernel would significantly reduce update latency and further boost throughput.
  • Static Stride: The update stride $S$ is currently fixed. A promising future direction is an adaptive stride mechanism that automatically updates more frequently when acceptance lengths drop and less frequently when the draft remains stable.

Summary updated

BibTeX
@inproceedings{kumar2026test,
  author = {Avinash Kumar and Sujay Sanghavi and Poulami Das},
  title = {{Test-Time Speculation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=elwxI8Nne1},
}
Figure