Abstract
Large Language Models (LLMs) typically utilize a fixed number of transformer layers for every token generated, leading to significant computational overhead. This paper presents Position-Aware Depth Decay Decoding ($D^3$), a training-free inference strategy that dynamically adjusts model depth based on a token's position in a sequence. By observing that later tokens in a generation sequence often require less computation, $D^3$ employs a power-law decay function to skip redundant middle layers. Experimental results on Llama 2 models across GSM8K and BBH benchmarks demonstrate that $D^3$ achieves up to a 1.94x reduction in FLOPs and a 1.23x wall-clock speedup with less than a 1% drop in accuracy.
Introduction
The inference phase of Large Language Models is notoriously resource-intensive. Standard architectures process every token through every layer, regardless of the token's complexity or its context within the sequence. While dynamic depth techniques—such as early exiting or layer skipping—have been proposed to mitigate this, they frequently encounter three primary obstacles: the need for specialized retraining, state inconsistency that breaks Key-Value (KV) caching, and incompatibility with hardware-efficient batch processing.
Position-Aware Depth Decay Decoding ($D^3$) is introduced as a "plug-and-play" solution to these challenges. It requires no fine-tuning and maintains compatibility with modern acceleration techniques, offering a scalable way to improve inference efficiency in production environments.
The D3 Framework
The $D^3$ method is built upon two foundational observations regarding the internal dynamics of LLMs during generation.
1. The "Easier Later" Hypothesis
By analyzing model perplexity, researchers found that as a model generates more text, its uncertainty per token tends to decrease. Early tokens in a sequence are critical for establishing context and direction, requiring the full depth of the model. However, as the sequence progresses, the path becomes more deterministic. $D^3$ formalizes this via a Power-Law Decay Function:
$$\text{Layers to retain} = \lfloor L \times (\alpha^i) \rfloor$$
where $L$ is the total number of layers, $i$ is the index of the generated token, and $\alpha$ is a decay coefficient. This allows the model to gradually reduce its computational effort as the sequence grows.
2. Core vs. Flex Layers
Not all layers contribute equally to the final output. Through analysis of hidden state cosine similarity and Euclidean distance, the authors identified that the initial "head" layers (responsible for feature extraction) and the final "tail" layers (responsible for classification) are essential. The middle layers, termed "Flex Layers," exhibit higher redundancy. $D^3$ specifically targets these middle layers for skipping, preserving the specialized functions of the model's boundaries.
Maintaining State Consistency
To solve the "Missing State" problem common in layer-skipping methods, $D^3$ utilizes a simple copy operation. When a layer is skipped, the hidden state from the previous active layer is copied forward. This ensures the KV cache remains structurally intact for subsequent tokens, preventing error propagation without requiring complex re-computation.
Experimental Evaluation
The researchers evaluated $D^3$ using the Llama 2 family (7B, 13B, and 70B parameters) across two challenging benchmarks:
- GSM8K: Grade-school math word problems requiring multi-step reasoning.
- BBH (Big-Bench Hard): A suite of 23 tasks designed to test the limits of current language models.
Key Results
- Efficiency Gains: $D^3$ achieved computational speedups ranging from 1.07x to 1.94x in terms of FLOPs reduction. In real-world wall-clock testing using the
lm-harnessframework, this translated to actual speedups of up to 1.23x on GPU hardware. - Performance Retention: The method proved remarkably robust. On the BBH benchmark, Llama 2-7B using $D^3$ maintained an average score of 31.88%, slightly exceeding the full-depth baseline of 31.22%. This suggests that skipping redundant layers may actually reduce "over-thinking" or noise in certain tasks.
- Zero-Shot Transferability: A significant practical advantage of $D^3$ is that optimal hyperparameters (such as the decay coefficient $\alpha$) can be identified on a small model (e.g., 7B) and applied directly to larger models (e.g., 70B) without further tuning.
Discussion and Future Work
$D^3$ demonstrates that the middle layers of LLMs are highly compressible, especially as sequence length increases. However, the current framework applies a uniform decay based on position, which may not account for "high-entropy" tokens (like specific mathematical operators) that appear late in a sequence but still require deep processing.
Future research may explore integrating $D^3$ with other efficiency techniques, such as quantization or speculative decoding. Additionally, developing a more granular mechanism that combines position-aware decay with token-specific complexity metrics could further optimize the balance between speed and reasoning accuracy.
Conclusion
Position-Aware Depth Decay Decoding ($D^3$) offers a simple yet effective strategy for accelerating LLM inference. By recognizing the diminishing marginal utility of deep layers in long sequences, $D^3$ provides a training-free path to more efficient AI deployment without sacrificing the performance of state-of-the-art pre-trained models.
Summary updated