Abstract
As Large Language Models (LLMs) scale, efficient deployment on consumer-grade hardware becomes increasingly difficult. Traditional depth-wise pruning methods, which involve deleting entire layers, often lead to catastrophic performance drops. We propose Sliding-Window Merging (SWM), a novel pruning strategy that identifies blocks of functionally redundant layers and merges them into a single representative layer. By consolidating parameter differences rather than simply discarding weights, SWM preserves the model's hierarchical logic. Our experiments on LLaMA and Vicuna models demonstrate that SWM significantly outperforms existing pruning techniques in both accuracy retention and inference efficiency.
Introduction
The computational and memory requirements of state-of-the-art LLMs necessitate effective compression techniques. While width-wise pruning (removing neurons or heads) reduces memory footprint, it often fails to alleviate the sequential processing bottlenecks inherent in Transformer architectures. Depth-wise pruning directly addresses inference speed by reducing the number of layers but is typically destructive. This research explores a "surgical" alternative to layer deletion: merging redundant functional blocks to maintain knowledge while reducing depth.
Methodology
Identifying Patch-Redundancy
The authors utilized Center Kernel Alignment (CKA) to analyze the similarity between layer outputs. Their analysis revealed a "patch-like" structure within LLMs, where large sequences of intermediate layers produce nearly identical representations. This suggests that these layers perform incremental refinements rather than unique transformations.
Sliding-Window Merging (SWM)
To exploit this redundancy, the SWM algorithm operates through an iterative process:
- Sliding Window Initialization: The algorithm scans the model from the deepest layers toward the shallower ones.
- Layer Grouping: Consecutive layers are grouped into a "patch" as long as their similarity exceeds a predefined threshold.
- Parameter Consolidation: Instead of simple averaging, the method calculates the parameter differences between redundant layers and a base layer. These "deltas" are incorporated into the base layer's weights, preserving the incremental knowledge of the merged block.
- Recovery: After merging, the model undergoes a brief "fast recovery" phase using LoRA (Low-Rank Adaptation) to fine-tune the remaining parameters on a small dataset (e.g., 50k samples from Alpaca).
Experimental Setup
The SWM method was evaluated on LLaMA2-7B, LLaMA3-8B, and Vicuna-7B/13B models. Performance was measured across seven commonsense reasoning benchmarks, including BoolQ, PIQA, HellaSwag, and WinoGrande. Similarity calculations were performed using a small calibration set from BookCorpus, and retraining utilized the Alpaca dataset.
Key Results and Insights
- Performance Retention: At a 35% pruning rate on Vicuna-7B, SWM achieved a 1.654% higher average zero-shot accuracy compared to the previous state-of-the-art, LLM-Pruner.
- Inference Efficiency: On LLaMA2-7B, a 20% reduction in depth resulted in a throughput increase from 46.9 to 54.7 tokens per second, with a corresponding decrease in latency from 2.729s to 2.339s.
- Consolidation vs. Deletion: The results confirm that merging layers is superior to deletion. By adding parameter differences back into the base layer, the model retains the "signal" of the redundant layers while removing structural overhead.
- Synergy with Width Pruning: SWM-compressed models remain compatible with traditional width-wise pruning, allowing for multi-dimensional model optimization without performance collapse.
Conclusion and Future Work
Sliding-Window Merging provides a robust framework for depth-wise pruning that avoids the pitfalls of layer deletion. While the method shows significant gains on high-end GPUs, future research should evaluate its performance on edge devices and explore automated frameworks for balancing width and depth pruning dynamically based on specific model architectures.
Summary updated