Abstract
With the rapid growth in the size and complexity of large language models (LLMs), the costs associated with their training and inference have escalated significantly. Research indicates that certain layers in LLMs harbor substantial redundancy, and pruning these layers has minimal impact on the overall performance. While various layer pruning methods have been developed based on this insight, they generally overlook the finer-grained redundancies within the layers themselves. In this paper, we delve deeper into the architecture of LLMs and demonstrate that finer-grained pruning can be achieved by targeting redundancies in multi-head attention (MHA) and multi-layer perceptron (MLP) blocks. We propose a novel, training-free structured pruning approach called BlockPruner. Unlike existing layer pruning methods, BlockPruner segments each Transformer layer into MHA and MLP blocks. It then assesses the importance of these blocks using perplexity measures and applies a heuristic search for iterative pruning. We applied BlockPruner to LLMs of various sizes and architectures and validated its performance across a wide range of downstream tasks. Experimental results show that BlockPruner achieves more granular and effective pruning compared to state-of-the-art baselines.
Introduction
Large Language Models (LLMs) are notoriously resource-hungry, making deployment on edge devices or cost-sensitive environments difficult. While "unstructured pruning" (removing individual weights) offers high theoretical compression, it requires specialized hardware to see actual speedups. On the other hand, traditional "structured pruning" (removing entire layers) is hardware-friendly but often too "blunt," discarding significant amounts of useful information along with the redundancy.
BlockPruner identifies a "middle ground" of redundancy. Within a single Transformer layer, the Multi-Head Attention (MHA) and Multi-Layer Perceptron (MLP) components often harbor different levels of importance. Existing methods that treat the layer as an indivisible unit overlook these finer-grained redundancies, leading to sub-optimal compression.
Methodology
BlockPruner operates through three main phases: Decomposition, Importance Estimation, and Iterative Heuristic Search.
Decomposition
Each Transformer layer is split into its two constituent residual blocks: the MHA block and the MLP block. This doubles the number of prunable units—for example, a 32-layer model becomes 64 prunable blocks. This granularity allows the pruning algorithm to selectively remove less critical components within a layer while preserving the more important ones.
Importance Estimation and Search
Instead of using local similarity metrics, which only measure how much a layer's output changes, BlockPruner uses Perplexity (PPL) as a global importance metric. It masks a block and measures the impact on the model's ability to predict text on a small calibration dataset (e.g., 256 samples from the Alpaca dataset).
Pruning is an iterative process rather than a one-shot operation. The algorithm masks each remaining block one by one, calculates the PPL, and removes the single block that causes the least performance degradation. This process repeats until the target pruning ratio is met. This iterative approach accounts for the complex interactions between blocks that "one-shot" methods miss.
Key Insights
Differential Redundancy
A striking finding is that LLMs tend to have more redundant Attention blocks than MLP blocks. In the early stages of pruning, BlockPruner almost exclusively removes MHA blocks.
As shown in Figure 6, the number of MHA blocks removed significantly exceeds the number of MLP blocks for both Llama2-7B and Llama2-13B. This has a direct benefit for inference: because the method frequently prunes MHA blocks, it significantly reduces the size of the Key-Value (KV) cache. This leads to a direct reduction in memory usage during inference and faster generation speeds—a benefit that standard layer pruning doesn't specifically optimize for.
Global vs. Local Metrics
The authors show that local metrics fail at higher pruning ratios. Perplexity, while more computationally expensive to calculate during the pruning phase, serves as a much more robust "global" health check for the model. Furthermore, the iterative search is essential; using Perplexity in a one-shot manner is actually less effective than simpler metrics.
Experimental Results
BlockPruner was validated on models including Llama2, Baichuan2, Qwen1.5, Llama3-8B, and Mistral-7B-v0.3 across benchmarks such as PIQA, WinoGrande, HellaSwag, and ARC.
- Superior Performance: Across almost all models and benchmarks, BlockPruner outperformed state-of-the-art baselines like ShortGPT, SliceGPT, and LaCo. For example, on Llama2-7B at a ~22% pruning ratio, BlockPruner maintained an average score of 60.17, while ShortGPT trailed at 58.18.
- Efficiency Gains: BlockPruner achieved a 1.47x speedup on Llama2-7B at a 24% pruning ratio, significantly higher than SliceGPT’s 1.25x speedup at a similar ratio.
- Reasoning Retention: On the AQuA-RAT reasoning benchmark, pruned models retained over 90% of the original model's accuracy, proving that fine-grained pruning preserves complex logic better than removing whole layers.
Conclusion
BlockPruner demonstrates that targeting finer-grained redundancies within Transformer layers is a highly effective strategy for LLM compression. By decomposing layers into MHA and MLP blocks and employing an iterative search based on perplexity, it achieves superior performance-to-compression ratios and faster inference speeds compared to traditional layer-pruning techniques. Future work will focus on scaling this approach to larger models and exploring more advanced optimization algorithms for the search process.
Summary updated