TokenTiming: A Dynamic Alignment Method for Universal Speculative Decoding Model Pairs

Sibo Xiao, Jinyuan Fu, Zhongle Xie, Lidan Shou

Abstract

Accelerating the inference of large language models (LLMs) has been a critical challenge in generative AI. Speculative decoding (SD) substantially improves LLM inference efficiency. However, its utility is limited by a fundamental constraint: the draft and target models must share the same vocabulary, thus limiting the herd of available draft models and often necessitating the training of a new model from scratch. Inspired by Dynamic Time Warping (DTW), a classic algorithm for aligning time series, we propose the algorithm TokenTiming for universal speculative decoding. It operates by re-encoding the draft token sequence to get a new target token sequence, and then uses DTW to build a mapping to transfer the probability distributions for speculative sampling. Benefiting from this, our method accommodates mismatched vocabularies and works with any off-the-shelf models without retraining and modification. We conduct comprehensive experiments on various tasks, demonstrating 1.57x speedup. This work enables a universal approach for draft model selection, making SD a more versatile and practical tool for LLM acceleration.

Introduction: The Vocabulary Bottleneck

Speculative Decoding (SD) has emerged as a primary strategy for speeding up LLM inference. The process involves a small, efficient "draft" model proposing a sequence of tokens that a larger "target" model verifies in parallel. While effective, traditional SD is hindered by a strict requirement: both models must share the same vocabulary.

This constraint creates a significant compatibility bottleneck. Researchers are often forced to train custom draft models or "draft heads" from scratch to match a specific target's tokenizer, which is both computationally expensive and inflexible. Existing workarounds, such as String-level Exact Match or Token-level Intersection (TLI), often fail to support probabilistic sampling or suffer from low acceptance rates when vocabulary overlap is minimal.

Comparison of TokenTiming with previous methods like TLI, showing how DTW-based alignment enables successful parallel verification even with mismatched vocabularies.

Methodology: Dynamic Token Alignment

To overcome these limitations, we introduce TokenTiming, a framework that treats vocabulary mismatch as a sequence alignment problem. The core insight is that while token boundaries are model-specific, the underlying linguistic content remains identical. TokenTiming bridges this gap using a four-stage pipeline:

  1. Draft Token Conversion: The draft model's output is decoded into a raw string and then re-tokenized using the target model's tokenizer to create a "Proxy Target Token" sequence.
  2. Dynamic Time Warping (DTW): Because different tokenizers split words differently (e.g., "Scaling" vs. "Scal" + "ing"), sequences often differ in length. TokenTiming uses DTW to find the optimal many-to-many mapping between draft and proxy sequences.
  3. Probability Transfer: Using the DTW mapping, the algorithm transfers probability distributions from the draft model to the target model's vocabulary space.
  4. Lossless Speculative Sampling: The target model verifies the proxy tokens. We provide a mathematical proof that this sampling method is "lossless," ensuring the final output distribution is identical to the target model's standalone output.
The TokenTiming technical pipeline: (a) re-tokenization, (b) DTW cost matrix, (c) probability distribution mapping, and (d) search space optimization using the Sakoe-Chiba band.

To ensure computational efficiency, we implement the Sakoe-Chiba Band constraint. This limits the DTW search space to a diagonal band, reducing overhead to a negligible 0.1% to 0.5% of total runtime.

Experimental Evaluation

We evaluated TokenTiming using the Spec-Bench suite across tasks including summarization, translation, reasoning, and coding. We tested 25 model pairs, including flagship models like Llama-3.1-70B and phi-4, paired with tiny off-the-shelf drafters like vicuna-68m.

Key results include:

  • Significant Speedups: TokenTiming consistently outperformed previous universal methods. For instance, when accelerating Qwen3-32B, it achieved a 1.57x speedup.
  • Closing the Gap: On 33B-parameter models, TokenTiming reached a 2.27x speedup, nearly matching specialized, vocabulary-homogeneous methods like EAGLE-1 (2.21x) without requiring any training.
  • Robustness: The method remains effective even when vocabulary overlap is as low as 6%.

Conclusion and Future Work

TokenTiming enables a truly "plug-and-play" approach to speculative decoding, allowing any small model to accelerate any large model instantly. While currently most effective for Latin-based languages, future work will focus on improving semantic alignment for character-based languages like Chinese and Japanese, and refining the handling of special tokens in reasoning-heavy models.

Summary updated

Abstract

Accelerating the inference of large language models (LLMs) has been a critical challenge in generative AI. Speculative decoding (SD) substantially improves LLM inference efficiency. However, its utility is limited by a fundamental constraint: the draft and target models must share the same vocabulary, thus limiting the herd of available draft models and often necessitating the training of a new model from scratch. Inspired by Dynamic Time Warping (DTW), a classic algorithm for aligning time series, we propose the algorithm TokenTiming for universal speculative decoding. It operates by re-encoding the draft token sequence to get a new target token sequence, and then uses DTW to build a mapping to transfer the probability distributions for speculative sampling. Benefiting from this, our method accommodates mismatched vocabularies and works with any off-the-shelf models without retraining and modification. We conduct comprehensive experiments on various tasks, demonstrating 1.57x speedup. This work enables a universal approach for draft model selection, making SD a more versatile and practical tool for LLM acceleration.
BibTeX
@misc{xiao2025tokentiming,
  author = {Sibo Xiao and Jinyuan Fu and Zhongle Xie and Lidan Shou},
  title = {{TokenTiming: A Dynamic Alignment Method for Universal Speculative Decoding Model Pairs}},
  year = {2025},
  eprint = {2510.15545},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.15545},
}
Figure