Accelerating LLM Inference with Staged Speculative Decoding

Benjamin Spector, Christopher Ré · DOI

Abstract

Large Language Model (LLM) inference on local hardware is often constrained by memory bandwidth rather than computational capacity. We present "Staged Speculative Decoding," a hierarchical approach that accelerates inference by over 3x without compromising output quality. By utilizing tree-structured token guesses and a multi-tier speculation chain—incorporating an ultra-fast N-gram model alongside a traditional draft model—this method significantly increases arithmetic intensity and reduces the latency of autoregressive decoding.

Introduction: The Memory Bandwidth Bottleneck

Running LLMs locally on consumer-grade GPUs is notoriously slow. In standard autoregressive decoding, the model generates one token at a time, requiring the GPU to load the entire model's weights from memory for every single token produced. This leads to extremely low arithmetic intensity—the ratio of computation to data movement. Consequently, the GPU spends the majority of its time idling, waiting for data to arrive from memory.

The 4090 Roofline model shows how staged speculative decoding increases arithmetic intensity and performance compared to the baseline.

While traditional "Speculative Decoding" attempts to mitigate this by using a small "draft" model to predict multiple tokens in parallel, these models are often memory-bound themselves. Furthermore, if a single early guess is incorrect, the subsequent parallel computations by the "oracle" model are wasted, leading to diminishing returns.

Methods: Staged Speculation and Tree-Structured Batches

To overcome these limitations, we introduce two primary innovations:

1. Tree-Structured Batches

Instead of predicting a single linear sequence, the draft model generates a tree of potential token sequences. This allows the oracle model to verify multiple candidate paths simultaneously. By increasing the "expected tokens per batch," the system is more likely to find a correct sequence even if the primary path fails, maximizing the utility of each oracle model pass.

2. Staged Speculation

Recognizing that even small draft models can be memory-bound, we implement a three-tier hierarchy:

  • Oracle Model: The primary high-quality model (e.g., GPT-2 Large).
  • Draft Model: A smaller transformer (e.g., 40M parameters).
  • Draft$^2$ Model: An ultra-fast, non-neural N-gram model (specifically a Katz backoff trigram model).

In this "speculation on the speculator" setup, the N-gram model provides rapid guesses for the draft model, which then constructs a refined tree of speculations for the final verification by the oracle model.

Experimental Results

The system was evaluated using the HumanEval benchmark, consisting of 164 Python programming problems. The draft model was fine-tuned on the Python subsection of The Stack to ensure stylistic alignment with the oracle model.

Comparison of decoding throughput (tokens/sec) across different sampling methods.

Key performance metrics include:

  • Speedup: Achieved a 3.16x speedup in latency for single-batch decoding with GPT-2 Large.
  • Efficiency: Reduced memory bandwidth consumption to 0.23x of the baseline requirement for deterministic decoding.
  • Sampling Robustness: Maintained a 1.98x speedup even with stochastic "Top-k" sampling, which is typically harder to predict.
  • Zero Quality Loss: The output remains mathematically identical to the oracle model's standalone output, as the oracle model performs final verification of all tokens.

Discussion and Future Work

The success of staged speculative decoding stems from trading "cheap" compute for "expensive" bandwidth. By performing extra work during GPU idle cycles, the system effectively hides memory latency. This method is orthogonal to other optimizations like quantization or FlashAttention, allowing for cumulative performance gains.

Current limitations include software overhead from the Python implementation (estimated at 35%) and variability based on text entropy. Highly predictable code can see up to 10x speedups, while complex logic may yield closer to 2x. Future work involves porting the logic to C++/CUDA and scaling the hierarchy to larger models, such as a four-stage chain for 20B+ parameter models.

Summary updated

BibTeX
@inproceedings{spector2023accelerating,
  author = {Benjamin Spector and Christopher Ré},
  title = {{Accelerating LLM Inference with Staged Speculative Decoding}},
  booktitle = {ES-FoMO @ ICML},
  year = {2023},
  url = {https://openreview.net/forum?id=RKHF3VYjLK},
}
Figure