Abstract
Speculative Decoding (SD) enforces strict distributional equivalence to the target model when accepting candidate tokens. While it maintains the target model’s generation quality, this strict equivalence limits the speedup achievable by SD and prevents users from trading deviations from the target distribution in exchange for further inference speed gains. To address these limitations, we introduce Fuzzy Speculative Decoding (FSD) - a decoding algorithm that generalizes SD by accepting candidate tokens based on the divergences between the target and draft model distributions. By allowing for controlled divergence from the target model, FSD enables users to flexibly trade generation quality for inference speed. Across several benchmarks, our method is able to achieve significant runtime improvements of over 5 tokens per second faster than SD at only an approximate 2% absolute reduction in benchmark accuracy. In many cases, FSD is even able to match SD benchmark accuracy at over 2 tokens per second faster, demonstrating that distributional equivalence is not necessary to maintain target model performance. Furthermore, FSD can be seamlessly integrated into existing SD extensions; we demonstrate this by applying FSD to EAGLE-2, greatly enhancing this existing extension’s efficiency while allowing it to leverage FSD’s tunable quality-speed trade-off.
Introduction
Large Language Models (LLMs) are computationally expensive and slow due to their autoregressive nature, generating text one token at a time. Speculative Decoding (SD) was developed to mitigate this by using a smaller "draft" model to propose a sequence of tokens, which a larger "target" model then verifies in parallel. However, traditional SD is constrained by a "strict distributional equivalence" rule, requiring the final output to be mathematically identical to the target model's standalone output.
This rigid requirement often leads to the rejection of perfectly viable tokens simply because they do not perfectly align with the target model's internal probability distribution. This "overly strict" verification caps potential speedups and prevents a flexible tradeoff between inference speed and generation quality. We propose Fuzzy Speculative Decoding (FSD), which breaks this rule by introducing a tunable divergence threshold, allowing for significant speed gains with minimal impact on accuracy.
Methodology
Fuzzy Speculative Decoding (FSD) is a training-free algorithm that generalizes the standard speculative decoding framework. Instead of a binary probabilistic acceptance rule, FSD measures the divergence—specifically the Jensen-Shannon (JS) divergence—between the draft and target model distributions at each token position.
As illustrated in Figure 1, if the divergence at a given position is below a user-defined threshold ($T$), the candidate token is accepted. This "fuzzy" approach allows the system to accept tokens that are semantically and contextually appropriate even if they do not perfectly match the target model's top-tier probabilities. By adjusting $T$, users can navigate the accuracy-runtime curve. We also introduce rFSD, a variant that reduces to standard SD when $T=0$, ensuring full backward compatibility.
Experimental Setup
We evaluated FSD across four diverse benchmarks to test its robustness in various reasoning tasks:
- CSQA: Commonsense reasoning and factual knowledge.
- GSM8K: Multi-step mathematical word problems.
- MMLU: General knowledge across multiple academic subjects.
- HumanEval: Python code generation.
The experiments utilized three prominent model pairs: Llama 3.1 (8B/70B), Gemma 2 (2B/27B), and Qwen 2.5 (7B/32B).
Results and Discussion
Our results demonstrate that strict distributional equivalence is not a prerequisite for maintaining high performance. In many instances, FSD matched the accuracy of standard SD while operating at significantly higher speeds.
As shown in Figure 3, FSD consistently outperforms standard SD across all benchmarks. Key findings include:
- Speed Improvements: FSD achieved speedups of over 5 tokens per second (TPS) faster than SD with only a negligible (~2%) drop in absolute accuracy.
- Efficiency Gains: FSD often matched SD's accuracy while remaining 2 TPS faster, providing a "free" performance boost.
- Metric Effectiveness: Jensen-Shannon divergence proved to be the most effective signal for token acceptance compared to other metrics like KL Divergence.
- Ease of Calibration: The optimal threshold $T$ can be determined using a very small development set (8-16 samples), making it practical for real-world deployment.
Furthermore, FSD is highly extensible. When integrated with EAGLE-2, a state-of-the-art SD extension, FSD further accelerated inference while providing the same tunable quality-speed tradeoff.
Conclusion
Fuzzy Speculative Decoding provides a much-needed "knob" for LLM inference, allowing developers to prioritize speed or accuracy depending on the application. While the optimal threshold currently requires per-task calibration, the process is lightweight. Future research will explore training classifiers to predict acceptance based on divergence patterns, potentially enabling dynamic candidate lengths and even greater efficiency.
Summary updated