DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding

Hossein Entezari Zarch, Lei Gao, Chaoyi Jiang, Murali Annavaram

TL;DR

Self-speculative decoding accelerates LLM inference by using a model's early layers to draft tokens before verifying them with the full network. However, statically fixing the draft layer and speculation length hurts efficiency across different tasks and contexts. This paper introduces DEL (Dynamic Exit Layer), a plug-and-play method that adaptively tunes these parameters on the fly, delivering up to a 2.62× speedup over vanilla decoding with negligible overhead.

What Problem Does This Paper Address?

Large Language Models (LLMs) are notoriously slow at generating text because they operate auto-regressively—generating tokens one by one, with each step requiring a full pass over billions of parameters. Speculative Decoding (SD) mitigates this memory bottleneck by using a smaller "draft" model to guess a sequence of tokens, which the larger "target" model then verifies in parallel.

A recent flavor of this technique, called self-speculative decoding (e.g., LayerSkip), eliminates the need for a separate draft model entirely. Instead, it executes just the first $E$ layers of the target model to draft tokens, using the remaining layers for verification.

The catch? Prior works select the exit layer ($E$) and the number of drafted tokens (speculation length $\gamma$) statically via offline grid search. The authors demonstrate that this one-size-fits-all approach is highly suboptimal. The ideal hyperparameters shift drastically depending on the task, the prompt, and even the specific stage of generation within a single prompt (e.g., switching from boilerplate code to complex logic).

Figure 1: (a) Optimal (E, γ) configurations of LayerSkip are task-specific; there is no uni- versally best setting. The legend shows configurations tuned for each task, with colors matching the corresponding task label on the x-axis. Bars show the speedup achieved when applying each configuration to each task. Tasks perform best with their own configuration, while cross-task settings degrade performance. (b) Optimal (E, γ) configurations vary across prompts and even within segments of a single prompt. Heatmaps show decoding speed over (E, γ) grids. Shifting optimal regions motivate dynamic, context-aware adaptation.

Methods

DEL introduces a dynamic, context-aware framework to adaptively optimize both the exit layer and speculation length at each decoding round. It relies on three core components:

  1. The Token-per-Layer (TPL) Metric: The authors define TPL to quantify decoding efficiency. It calculates the expected number of accepted tokens divided by the computational cost (approximated by the number of loaded layers).
  2. Shadow Token Generation (Free Counterfactuals): To choose the best exit layer, DEL needs to know the token acceptance rate for every potential layer. Instead of running expensive extra forward passes, DEL exploits a clever trick: it takes the intermediate hidden states already computed during the verification phase and passes them through the language modeling head in a single parallel step. This generates "shadow tokens"—counterfactual sequences showing what each layer would have predicted, allowing DEL to track historical acceptance rates for all layers simultaneously.
  3. Dynamic Draft-Exiting: Within a single speculative round, DEL monitors the confidence score of the draft tokens. If the confidence drops below a dynamically adjusted threshold $\tau$, drafting halts early to avoid wasting compute on tokens likely to be rejected.
DEL pipeline: generating shadow tokens from cached hidden states to dynamically optimize TPL and confidence thresholds.

Datasets

The authors evaluated DEL across a diverse suite of standard benchmarks covering multiple capabilities:

  • Language Modeling & Summarization: CNN/DailyMail, XSUM
  • Code Generation: HumanEval
  • Arithmetic Reasoning: GSM8K, AQuA-RAT-CoT
  • Translation: WMT14 De–En (German to English)

Key Insights and Ideas

  • The "Free Lunch" of Self-Speculation: Because self-speculative decoding already computes intermediate hidden states, evaluating alternative drafting strategies is incredibly cheap. DEL turns these wasted hidden states into a feedback loop for real-time optimization.
  • Context-Driven Hardness: Token predictability fluctuates wildly during generation. A fixed threshold or layer cannot adapt when a model transitions from highly predictable text (like syntax or common phrases) to high-entropy tokens requiring deeper semantic processing.
  • Midpoint Thresholding: Rather than using a fixed confidence threshold to halt drafting, DEL dynamically sets the threshold as the midpoint between the weighted historical confidence of correctly matched tokens and mismatched tokens.

Key Results

DEL was evaluated on top of LayerSkip using LLaMA-2 (7B, 13B, 70B), LLaMA-3 (8B, 3.2-1B), and CodeLLaMA models.

  • Substantial Speedups: DEL achieved overall wall-clock speedups ranging from 2.16× to 2.62× compared to vanilla auto-regressive decoding.
  • Outperforming Baselines: It consistently beat state-of-the-art static and dynamic speculative decoding baselines (such as Draft & Verify), outperforming them by up to 0.19×.
  • Preserved Quality: Because speculative decoding includes a mathematically rigorous verification phase, DEL maintains the exact output distribution and fidelity of the target model (confirmed by ROUGE-2 and exact-match scores).
  • Negligible Overhead: Computing the TPL metric and shadow tokens adds a mere 0.52% to 2.26% memory overhead over vanilla decoding, making it highly practical for deployment.

Limitations and Future Work

  • Distribution Alignment Dependency: Like all speculative decoding methods, DEL's efficiency gains rely on the assumption that early layers are reasonably well-aligned with the final layer. Under extreme out-of-distribution prompts, acceptance rates may drop, degrading the speedup.
  • Pretraining Requirements: DEL is designed to plug into models trained with early-exit capabilities (like LayerSkip). Applying it to standard off-the-shelf LLMs without early-exit fine-tuning remains an open challenge.

Summary updated

Abstract

Speculative Decoding (SD) is a widely used approach to accelerate the inference of large language models (LLMs) without reducing generation quality. It operates by first using a compact model to draft multiple tokens efficiently, followed by parallel verification using the target LLM. This approach leads to faster inference compared to auto-regressive decoding. While there are multiple approaches to create a draft model, one promising approach is to use early-exit methods. These methods draft candidate tokens by using a subset of layers of the primary model and applying the remaining layers for verification, allowing a single model to handle both drafting and verification. While this technique reduces memory usage and computational cost, its performance relies on the choice of the exit layer for drafting and the number of tokens drafted (speculation length) in each SD round. Prior works use hyperparameter exploration to statically select these values. However, our evaluations show that these hyperparameter values are task-specific, and even within a task they are dependent on the current sequence context. We introduce DEL (Dynamic Exit Layer), a plug-and-play method that adaptively selects the exit layer and speculation length during inference. DEL dynamically tracks the token acceptance rate if the tokens are drafted at each layer of an LLM and uses that knowledge to heuristically select the optimal exit layer and speculation length. Our experiments across a broad range of models and downstream tasks show that DEL achieves overall speedups of $2.16\times$$\sim$$2.62\times$ over vanilla auto-regressive decoding and improves upon state-of-the-art SD methods, which peak at $2.43\times$, by up to $0.19\times$. The code is available at https://github.com/hoenza/DEL.
BibTeX
@inproceedings{zarch2025del,
  author = {Hossein Entezari Zarch and Lei Gao and Chaoyi Jiang and Murali Annavaram},
  title = {{DEL: Context-Aware Dynamic Exit Layer for Efficient Self-Speculative Decoding}},
  booktitle = {COLM},
  year = {2025},
}
Figure