SpecEE: Accelerating Large Language Model Inference with Speculative Early Exiting

Jiaming Xu, Jiayi Pan, Yongkang Zhou, Siming Chen, Jinhao Li, Yaoxiu Lian, Junyi Wu, Guohao Dai

TL;DR

SpecEE is a novel inference engine that combines speculative decoding with early exiting to significantly speed up Large Language Models (LLMs). By using speculative tokens to narrow the predictor's search space from tens of thousands to just a few candidates, it achieves up to 2.43x speedup with negligible accuracy loss and improved energy efficiency.

What Problem Does This Paper Address?

Large Language Models (LLMs) are notoriously slow and power-hungry because every token generated usually requires passing through every single layer of a massive transformer. Two popular solutions exist, but they have friction when combined:

  1. Early Exiting: Stopping the computation at an intermediate layer if the model is "confident enough" about the next token. However, the "predictors" that decide when to exit are often slow because they have to check the entire vocabulary (e.g., 32,000+ tokens in Llama2), adding significant overhead.
  2. Speculative Decoding: Using a tiny "draft" model to guess several tokens at once, which a big model then verifies in one go. Combining this with early exiting is mathematically complex because the draft model creates a "tree" of possibilities that makes standard exit predictors explode in computational cost.

SpecEE tackles these bottlenecks by making the exit predictors "speculation-aware," turning a massive search problem into a simple verification task.

Methods

The authors introduce three key optimizations across different levels of the inference stack:

  • Algorithm Level (Speculation-based Predictor): Instead of the predictor looking at the full vocabulary, it only considers the few tokens suggested by the speculative draft model. This reduces the search space by 10,000x. They replace heavy traditional predictors (like SVMs) with a lightweight, two-layer MLP that is optimized for GPU parallelization.
  • System Level (Two-level Heuristic Scheduling): Not every layer needs a predictor. SpecEE uses Offline Scheduling to identify which layers statistically exit most often and Online Scheduling to look at the "contextual similarity" of recent tokens. If the last few tokens were "easy" (exited early), the system prioritizes early exiting for the current one.
  • Mapping Level (Context-aware Merged Mapping): To handle speculative decoding's token trees, SpecEE merges paths of tokens into "hyper-tokens." This keeps the mapping complexity linear rather than exponential, allowing the system to verify multiple speculative tokens simultaneously without a massive performance hit.

Datasets

The researchers evaluated SpecEE using the Llama2 family (7B, 13B, and 70B parameters) across a wide array of standard benchmarks:

  • General Knowledge & Reasoning: MMLU, GSM8K, CommonsenseQA (CSQA).
  • Dialogue & Instruction: MT-Bench, Alpaca.
  • Summarization & Coding: SUM (CNN/DailyMail), HumanEval.
  • Sentiment Analysis: SST2.
  • Language Modeling: SQuAD (QA).

Key Insights and Ideas

  • The Vocabulary is the Bottleneck: The authors realized that ~20% of inference latency in early exiting comes just from the predictor traversing the massive vocabulary. By using speculative tokens as a "multiple-choice" hint, they bypass the "LM Head" bottleneck entirely.
  • The "Probability Shift" Phenomenon: They observed that when a model is going to be correct, the probability of the correct token in the reduced speculative space tends to "rise sharply" at a specific layer. This "shift" is a much more reliable signal for exiting than raw confidence scores.
  • Contextual Exit Stability: If an LLM is in the middle of a predictable phrase, it tends to exit at similar layers for several tokens in a row. SpecEE exploits this "contextual similarity" to skip unnecessary predictor checks.
  • Cannikin Law in Decoding: In a sequence of tokens, the exit point is determined by the "rearmost" (deepest) required layer in the path. Merging these into hyper-tokens allows the system to respect this constraint efficiently.

Key Results

  • Speedup: SpecEE achieved 2.25x speedup on cloud hardware (NVIDIA A100/4090) and 2.43x speedup on consumer PC hardware (RTX 4060) compared to standard implementations (Hugging Face/llama.cpp).
  • Accuracy: The accuracy loss was negligible (<1%) across all tested benchmarks, effectively pushing the Pareto frontier of the speed-vs-accuracy trade-off.
  • Efficiency: The system reduced average GPU power consumption by ~10% and improved overall energy efficiency by 1.57x.
  • Low Overhead: Training the tiny MLP predictors is extremely fast, requiring only about 2% of the original training data and taking roughly 10 minutes.

Limitations and Future Work

  • Memory Footprint: Using a speculative draft model and adding predictors increases VRAM usage by about 0.9GB to 1.4GB. While manageable on high-end GPUs, this could be a constraint for very memory-limited edge devices.
  • Predictor Workload: Even though the predictors are lightweight, they are "memory-bound" operators. The authors suggest that future hardware (like GPUs with "big-little" core designs) could handle these small tasks even more efficiently.
  • Draft Model Dependency: The performance of SpecEE is partially tied to the quality of the speculative draft model; if the draft model is very poor, the speedup gains from the reduced search space may diminish.

Summary updated

BibTeX
@misc{xu2025specee,
  author = {Jiaming Xu and Jiayi Pan and Yongkang Zhou and Siming Chen and Jinhao Li and Yaoxiu Lian and Junyi Wu and Guohao Dai},
  title = {{SpecEE: Accelerating Large Language Model Inference with Speculative Early Exiting}},
  year = {2025},
  eprint = {2504.08850},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.08850},
}

Loading related content...

Figure