Abstract
Standard Large Language Models (LLMs) are computationally rigid, processing every token through the same number of layers regardless of task complexity. We present DiffSkip, a novel "plug-in" method that allows LLMs to dynamically skip Feed-Forward Network (FFN) blocks on a per-token basis. By identifying a high correlation between self-attention outputs and FFN outputs, we develop a lightweight router that predicts FFN necessity. DiffSkip maintains over 90% of model performance while significantly reducing computational depth and avoiding the catastrophic forgetting common in prior skipping methods.
Introduction
The "uniform computation" paradigm in current LLMs is inherently inefficient; generating a simple punctuation mark requires the same FLOPs as solving a complex mathematical proof. While "early exiting" and "layer skipping" have been proposed, they typically suffer from high training overhead or poor stability during multi-token generation. DiffSkip addresses these challenges by leveraging internal signals already present in pre-trained models to make dynamic, token-level routing decisions.
Methodology
The Core Insight: $\Delta_{Attn} \approx \Delta_{FFN}$
The fundamental premise of DiffSkip is that the "input-output difference" of a self-attention block ($\Delta_{Attn} = Attn(x) - x$) serves as a strong proxy for the contribution of the subsequent FFN block ($\Delta_{FFN} = FFN(h) - h$). Empirical analysis shows a high similarity between these signals across the middle layers of the model, suggesting that the attention mechanism essentially "prepares" the signal for the FFN.
Architecture
DiffSkip introduces two lightweight, tunable components to each transformer layer while keeping the original model weights frozen:
- Router: A small MLP that processes $\Delta_{Attn}$ to produce a gating score $g$.
- Adaptor: A "tiny FFN" that processes tokens when the FFN is skipped, ensuring latent space alignment.
If the gating score $g$ exceeds a threshold $\tau$, the token undergoes full FFN computation. Otherwise, it passes through the Adaptor, maintaining consistency in the model's internal representations. This token-by-token decision-making prevents the error propagation seen in sequence-level skipping methods.
Perplexity-Weighted Training
To optimize the routers, the authors employ a dual-loss objective combining next-token prediction with a skipping loss. Crucially, the skipping loss is weighted by token perplexity: "easy" tokens (low perplexity) are encouraged to skip more layers, while "hard" tokens (high perplexity) retain full computational depth to preserve reasoning quality.
Key Results and Insights
Evaluations on Llama-3-8B-Instruct demonstrate that DiffSkip is both efficient and robust:
- Performance Retention: With a 25% reduction in FFN depth (8 blocks skipped), the model retains 91.3% of its original performance across knowledge, logic, and reasoning benchmarks.
- Multi-Token Stability: Unlike sequence-level skipping methods that often fail on complex tasks like GSM8K, DiffSkip's token-by-token routing maintains 57.8% accuracy (vs. 67.9% vanilla), avoiding the "catastrophic forgetting" seen in baselines.
- U-Shaped Utilization: The model naturally learns that the first and last layers are critical, while middle layers are often redundant and can be frequently skipped.
- Semantic Sensitivity: DiffSkip automatically reduces computation for "copying" tasks (e.g., repeating numbers from a prompt) while allocating more power to "reasoning" steps.
Discussion and Limitations
While DiffSkip reduces theoretical FLOPs, real-world wall-clock speedups are currently limited by GPU kernel optimizations for uniform batching. Future work will focus on optimizing I/O for dynamic routing and extending the skipping mechanism to self-attention blocks. Despite these hardware hurdles, DiffSkip represents a significant step toward truly adaptive and efficient LLM inference.
Summary updated