Adaptive Layer-skipping in Pre-trained LLMs

Xuan Luo, Weizhi Wang, Xifeng Yan · DOI

Abstract

Standard Large Language Models (LLMs) are computationally rigid, applying the same number of operations to every token regardless of its complexity. This paper introduces FlexiDepth, a "plug-and-play" framework that enables dynamic, per-token layer skipping in pre-trained LLMs. By integrating lightweight routers and adapters while keeping the base model frozen, FlexiDepth allows models like Llama-3-8B to skip up to 25% of their layers with negligible performance loss. Our results demonstrate that adaptive computation can maintain—and in some cases improve—benchmark accuracy while significantly reducing theoretical FLOPs.

Introduction: The Cost of Uniformity

In human cognition, mental effort scales with task difficulty; we do not exert the same energy to recognize a word as we do to solve a complex equation. Current LLMs, however, pass every token through every Transformer layer. This uniform allocation is inefficient. Previous attempts at adaptive computation, such as early-exiting or pruning, often require expensive retraining or lead to sharp performance drops. FlexiDepth addresses this by introducing a modular approach to skip redundant middle layers without disrupting the model's pre-trained knowledge.

Methodology: Routers and Adapters

FlexiDepth augments each layer of a pre-trained LLM with two trainable components:

  1. The Router: A bottlenecked MLP that makes non-linear decisions on whether to process a hidden state through the attention/FFN blocks or skip them.
  2. The Adapter: A lightweight module that realigns the latent space when a layer is skipped, ensuring compatibility with subsequent layers.
The FlexiDepth routing mechanism: tokens either pass through the full layer (left) or skip to an adapter (right) based on the router's decision.

Technical Nuance: Intelligent KV Caching

A major challenge in layer skipping is maintaining the Key-Value (KV) cache. If a token skips an attention block entirely, future tokens lose the ability to attend to it, breaking the model's memory. FlexiDepth solves this by skipping Query computation and dot-product operations while still generating the necessary KV vectors to preserve contextual integrity.

Comparison of attention matrices: Vanilla (full), No KV Cache (broken context), and FlexiDepth's KV Cache approach (preserved context).

Key Results and Insights

The researchers evaluated FlexiDepth on Llama-3-8B, Llama-2-13B, and Qwen-2.5-3B using benchmarks like MMLU (general knowledge) and GSM8K (math).

  • Performance Retention: Llama-3-8B achieved 100.7% performance retention while skipping an average of 8 out of 32 layers.
  • Robustness in Reasoning: On the GSM8K math benchmark, FlexiDepth maintained nearly full performance where competing methods like ShortGPT saw accuracy collapse.
  • Utilization Patterns: Analysis revealed a "bowl" pattern: the model rarely skips the initial "parsing" layers or final "decoding" layers, focusing its efficiency gains on redundant middle layers.
  • Complexity Correlation: Simpler tasks (e.g., text copying) utilized significantly fewer layers (~21) compared to reasoning-heavy tasks like summarization (~30).

Discussion: From Theory to Wall-Clock Speed

While FlexiDepth successfully reduces theoretical FLOPs, achieving real-world "wall-clock" speedups on current GPUs remains a challenge. GPU architectures are optimized for uniform batch processing; "branching" paths (where different tokens in a batch require different numbers of layers) introduce synchronization overhead. Future work must focus on hardware-aware scheduling and token grouping to translate these computational savings into faster inference times.

Summary updated

BibTeX
@inproceedings{luo2025adaptive,
  author = {Xuan Luo and Weizhi Wang and Xifeng Yan},
  title = {{Adaptive Layer-skipping in Pre-trained LLMs}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=Gu0XSax2YS},
}
Figure