DySpec: Faster speculative decoding with dynamic token tree structure

Yunfan Xiong, Ruoyu Zhang, Yanzeng Li, Lei Zou

Abstract

Speculative decoding accelerates Large Language Model (LLM) inference by using a smaller draft model to predict sequences verified in parallel by a larger target model. However, traditional methods rely on fixed "chain" or "tree" structures that fail to adapt to varying model confidence across different prompts. We present DySpec, an algorithm that dynamically builds a token tree using a greedy expansion strategy. By prioritizing paths with higher draft probabilities, DySpec optimizes the speculation budget in real-time. Our implementation achieves up to a 9.1x throughput increase on Llama2-70B with negligible overhead, demonstrating a robust and hardware-aware approach to efficient LLM deployment.

Introduction

The primary bottleneck in deploying Large Language Models (LLMs) is inference latency. Due to the auto-regressive nature of text generation, models must be fully loaded into memory for every single token produced. For a 70-billion parameter model, this memory-bound process significantly limits throughput. Speculative decoding addresses this by employing a small, fast "draft" model to generate a sequence of candidate tokens. These candidates are then verified by the large "target" model in a single parallel step, potentially accepting multiple tokens at once.

The Problem: Inference Latency and Static Speculation

While speculative decoding offers a path to faster inference, existing methods often utilize rigid structures for speculation. Early approaches used a simple "chain" of tokens, while more recent state-of-the-art (SOTA) methods utilize static "tree" structures to explore multiple potential paths simultaneously.

Evolution of speculative decoding structures from simple chains to complex trees.

The limitation of a fixed structure is its inability to adapt to the draft model's confidence. If the draft model is highly certain, a short fixed tree fails to exploit the potential for longer speculation. Conversely, if the model is uncertain, a fixed tree wastes computational resources exploring unlikely paths. DySpec proposes that the speculation structure should be dynamic, adapting to the specific prompt and the draft model's real-time confidence.

Methods: The Dynamic Token Tree

The core innovation of DySpec is the Dynamic Token Tree. Instead of following a pre-defined shape, the algorithm constructs the tree on the fly using a greedy strategy.

The authors establish a statistical link between a token's draft probability and its likelihood of being accepted by the target model. By analyzing KL divergence, they demonstrate that tokens with higher draft probabilities are empirically more likely to be verified as correct. This insight allows the draft model's own internal confidence to serve as a reliable proxy for the speculation strategy.

Greedy Expansion

Using this link, DySpec employs a greedy expansion algorithm. It maintains a heap of "expandable" nodes and consistently selects the node with the highest estimated acceptance rate to sample the next token. This ensures that the fixed "budget" of speculated tokens is allocated to the most promising outcomes.

An example of a dynamic token tree generated by DySpec for the prompt 'A Wall'.

System Optimizations

To ensure that dynamic tree construction does not become a bottleneck, DySpec incorporates several system-level optimizations:

  • C++ Implementation: The tree construction logic is implemented in C++ for maximum efficiency.
  • DFS Reordering: Tree nodes are reordered using a Depth-First Search (DFS) pattern. This creates a "block-sparse" attention mask, enabling the use of optimized kernels like FlashAttention or Triton during the target model's verification phase, bridging the gap between algorithmic theory and hardware efficiency.

Key Results

DySpec was evaluated across standard benchmarks including C4, OpenWebText, and CNN/DailyMail using Llama2 models (7B to 70B).

  • Significant Throughput Gains: On Llama2-70B at low temperatures, DySpec achieved a 9.1x throughput improvement and a 9.4x reduction in latency.
  • Robust Performance: Unlike static methods, DySpec maintains high performance across varying "temperatures" (randomness levels). Even at high temperatures, it achieved a 6.21x throughput boost.
  • Low Overhead: System profiling shows that the overhead of dynamic tree construction remains under 2% of total execution time, making it highly practical for real-world applications.

Conclusion

DySpec demonstrates that adapting the speculation structure to the draft model's confidence is a powerful strategy for accelerating LLM inference. By combining a greedy dynamic tree construction with hardware-aware optimizations, DySpec significantly outperforms static speculative decoding methods while maintaining minimal computational overhead. Future work may explore dynamic thresholding to further refine the balance between speculation depth and computational budget.

Summary updated

BibTeX
@article{xiong2025dyspec,
  author = {Yunfan Xiong and Ruoyu Zhang and Yanzeng Li and Lei Zou},
  title = {{DySpec: Faster speculative decoding with dynamic token tree structure}},
  journal = {WWW},
  year = {2025},
  doi = {10.1007/s11280-025-01344-0},
}
Figure