Introduction
As Large Language Models (LLMs) continue to scale, their computational demands present a significant barrier to deployment in resource-constrained environments like edge devices. Depth pruning—the removal of entire transformer layers—has emerged as a popular solution to reduce model height and accelerate inference. However, traditional depth pruning is typically static, applying a single fixed set of removed layers to every input regardless of its semantic content.
IG-Pruning (Input-Guided Pruning) challenges this "one-size-fits-all" approach. The authors argue that different tasks, such as mathematical reasoning versus creative writing, rely on different internal representations. A layer redundant for one prompt may be critical for another. IG-Pruning introduces a dynamic, input-aware framework that skips unnecessary transformer blocks during inference based on the semantic context of the input.
Methods
IG-Pruning utilizes a two-stage pipeline to move beyond static pruning limitations:
Stage 1: Mask Discovery (Offline)
- Input Clustering: Calibration data is transformed into embeddings using a lightweight sentence encoder (e.g., MiniLM) and grouped into $N$ clusters (typically 16) via K-means.
- Soft Mask Training: For each cluster, a dedicated "soft mask" is trained while the LLM's weights remain frozen. Using Hard Concrete Distributions and $L_0$ optimization, the system learns which blocks (Attention or FFN) are least important for a specific semantic group at a target sparsity level.
Stage 2: Dynamic Routing (Inference)
- Semantic Routing: When a user provides a prompt, the system encodes it, identifies the nearest cluster center, and applies the corresponding pre-trained binary mask.
- Granular Skipping: Unlike methods that remove entire layers, IG-Pruning can independently skip the Attention block or the Feed-Forward Network (FFN) block within a layer. To maintain autoregressive generation, skipped Attention blocks still update the KV cache but bypass heavy dot-product computations.
Key Insights and Ideas
- Perplexity vs. Performance: The researchers found that Perplexity (PPL) can be a deceptive metric; masks with identical PPL scores often perform drastically differently on downstream reasoning tasks.
- The "Middle Layer" Redundancy: Visualizations indicate that Llama models tend to prune Attention blocks more heavily in middle layers, while FFN blocks are generally more critical to preserve.
- The Value of Diversity: Performance consistently improves as the number of clusters increases, confirming that specialized computational pathways are more effective than a single pruned architecture.
- Efficiency: Because the LLM weights are never modified, there is no risk of catastrophic forgetting. Mask training is extremely fast, taking approximately 15 minutes for 16 clusters on 4 H800 GPUs.
Key Results
IG-Pruning consistently outperformed state-of-the-art static methods like SLEB, ShortenedLlama, and EvoPress across multiple architectures, including Llama-3-8B and Qwen-3-8B.
- Llama-3-8B at 25% Sparsity: IG-Pruning preserved 87.18% of the original dense model's performance, a 10.86 percentage point lead over the best static baseline (EvoPress).
- Qwen-3-8B at 13.9% Sparsity: The model maintained 96.01% of its original performance, significantly higher than the 90.37% achieved by baselines.
- Computational Savings: At 25% sparsity, the method reduced total FLOPs to approximately 89.8% of the dense model. While the FLOP reduction is slightly less than the sparsity percentage (due to KV cache maintenance), the accuracy gains make it a superior trade-off for real-world applications.
Limitations and Future Work
The quality of the masks is highly dependent on calibration data; the authors found that diverse, general pre-training data (like FineWeb-edu) outperformed instruction-tuning data. Future work includes studying the impact of pruning on factuality and hallucinations, as well as integrating IG-Pruning with truthfulness editing techniques to ensure efficient models remain reliable.
Summary updated