Table of Contents
Fetching ...

When Drafts Evolve: Speculative Decoding Meets Online Learning

Yu-Yang Qian, Hao-Cong Wu, Yichao Fu, Hao Zhang, Peng Zhao

Abstract

Speculative decoding has emerged as a widely adopted paradigm for accelerating large language model inference, where a lightweight draft model rapidly generates candidate tokens that are then verified in parallel by a larger target model. However, due to limited model capacity, drafts often struggle to approximate the target distribution, resulting in shorter acceptance lengths and diminished speedup. A key yet under-explored observation is that speculative decoding inherently provides verification feedback that quantifies the deviation between the draft and target models at no additional cost. This process naturally forms an iterative "draft commits-feedback provides-draft adapts" evolving loop, which precisely matches the online learning paradigm. Motivated by this connection, we propose OnlineSpec, a unified framework that systematically leverages interactive feedback to continuously evolve draft models. Grounded in dynamic regret minimization, we establish a formal link between online learning performance and speculative system's acceleration rate, and develop novel algorithms via modern online learning techniques, including optimistic online learning that adaptively reuses historical gradients as predictive update hints, and online ensemble learning that dynamically maintains multiple draft models. Our algorithms are equipped with theoretical justifications and improved acceleration rates, achieving up to 24% speedup over seven benchmarks and three foundation models.

When Drafts Evolve: Speculative Decoding Meets Online Learning

Abstract

Speculative decoding has emerged as a widely adopted paradigm for accelerating large language model inference, where a lightweight draft model rapidly generates candidate tokens that are then verified in parallel by a larger target model. However, due to limited model capacity, drafts often struggle to approximate the target distribution, resulting in shorter acceptance lengths and diminished speedup. A key yet under-explored observation is that speculative decoding inherently provides verification feedback that quantifies the deviation between the draft and target models at no additional cost. This process naturally forms an iterative "draft commits-feedback provides-draft adapts" evolving loop, which precisely matches the online learning paradigm. Motivated by this connection, we propose OnlineSpec, a unified framework that systematically leverages interactive feedback to continuously evolve draft models. Grounded in dynamic regret minimization, we establish a formal link between online learning performance and speculative system's acceleration rate, and develop novel algorithms via modern online learning techniques, including optimistic online learning that adaptively reuses historical gradients as predictive update hints, and online ensemble learning that dynamically maintains multiple draft models. Our algorithms are equipped with theoretical justifications and improved acceleration rates, achieving up to 24% speedup over seven benchmarks and three foundation models.
Paper Structure (34 sections, 6 theorems, 51 equations, 17 figures, 7 tables, 1 algorithm)

This paper contains 34 sections, 6 theorems, 51 equations, 17 figures, 7 tables, 1 algorithm.

Key Result

Lemma 1

Under Assumption assum:main, for Algorithm alg:generation_refinement_interactive with $T$ steps, the expected length of the draft sequence $\mathbb{E}[|\hat{\mathbf{x}}|] = \sum_{t=1}^T \mathbb{E}[n_t]$ is bounded by where $\widetilde{\Omega}(\cdot)$ hides the logarithmic factor.

Figures (17)

  • Figure 1: Illustration of Generation-refinement framework. A draft sequence is first generated rapidly by a small draft model, and then verified by the target model, which naturally forms an iterative "draft commits--feedback provides--draft adapts" evolving loop.
  • Figure 2: A comprehensive 3D-visualization illustrates generation-refinement approaches across three dimensions: draft level, token level, and incorporating interactive feedback. Our OnlineSpec framework provides a unified perspective for integrating interactive feedback and can be seamlessly combined with existing methods to further enhance the acceleration rate.
  • Figure 3: Evolution of tokens per second (TPS) on the GSM8K dataset: (a) Opt-Hydra with lmsys/Vicuna-7B-v1.3, (b) Ens-EAGLE with lmsys/Vicuna-7B-v1.3, (c) Ens-EAGLE-3 with lmsys/Vicuna-7B-v1.3, and (d) Online-LR with Qwen/Qwen3-8B. This demonstrates consistent performance improvements via online learning, validating the effectiveness of our OnlineSpec during deployment.
  • Figure 4: Performance comparison of Hydra, OSD-Hydra, and Opt-Hydra on (a) GSM8K, (b) Spider, (c) Code-Search, and (d) Alpaca-Finance using lmsys/Vicuna-7B-v1.3 as the foundation model. We report the average accepted length (AvgLen, top row) and tokens per second (TPS, bottom row) over time.
  • Figure 5: Performance comparison of EAGLE, OSD-EAGLE, and Ens-EAGLE on (a) GSM8K, (b) Spider, (c) Code-Search, and (d) Alpaca-Finance using lmsys/Vicuna-7B-v1.3 as the foundation model. We report the average accepted length (AvgLen, top row) and tokens per second (TPS, bottom row) over time.
  • ...and 12 more figures

Theorems & Definitions (16)

  • Lemma 1: Accepted Length
  • Theorem 1: Acceleration Rate
  • Corollary 1
  • Remark 1: Comparison with OSD ICML'24:OSD
  • Corollary 2
  • Corollary 3
  • Remark 2: Why Dynamic Regret?
  • Corollary 4
  • proof : Proof of Corollary \ref{['cor:interval']}
  • proof
  • ...and 6 more