Introduction
To deploy massive Large Language Models (LLMs) on resource-constrained devices, researchers often turn to model compression. A highly promising approach combines sparse pruning (removing individual weights) with low-rank matrix approximation (compressing weight matrices into smaller factors)—a technique known in classical matrix analysis as Robust Principal Component Analysis (RPCA).
This paper introduces a novel bilevel optimization framework that learns the optimal sparsity and low-rank allocations for different layers, rather than relying on heuristics. By combining a policy gradient-based allocation search with a highly efficient QR-based matrix approximation solver, the method achieves up to a 2x inference speedup while maintaining over 95% zero-shot accuracy at 50% sparsity.
The Challenge of LLM Compression
Different layers in an LLM exhibit vastly different levels of redundancy. Existing RPCA-based compression methods typically apply a uniform sparsity across all layers or rely on manually designed heuristics (like activation outliers) to guess how much to prune. Finding the globally optimal pruning structure—specifically, how much sparsity to allocate per layer and what rank to retain per matrix—is extremely difficult due to the massive search space and the limited compute available during post-training compression.
The Bilevel Optimization Framework
To overcome these limitations, the authors propose a framework that allows learning and matrix approximation to collaborate through a bilevel optimization process.
- Outer Loop (Learning Allocation): Instead of using heuristics, the framework treats weight allocation as a probabilistic optimization problem. It uses a truncated Gaussian prior to model the distribution of layer-wise sparsities and matrix-wise retained ranks. To update these parameters without performing expensive backpropagation through the entire compressed model, the authors employ a policy gradient estimator (similar to REINFORCE in reinforcement learning).
- Inner Loop (Matrix Approximation): For a given sparsity/rank allocation sampled by the outer loop, the inner loop compresses the model's matrices. Standard RPCA solvers rely on Singular Value Decomposition (SVD), which is computationally agonizing for large LLM matrices. To resolve this, the authors introduce an adapted QR-based matrix fitting scheme, drastically reducing computational complexity and making iterative solving feasible.
Key Insights: Speed, Stability, and Allocation
The study reveals several critical insights into effective LLM compression:
- Rank Allocation is the Secret Sauce: Ablation studies show that optimizing the matrix-wise rank ratio has a more significant impact on final model performance than just optimizing layer-wise sparsity—a factor largely overlooked by prior methods.
- Heterogeneous Redundancy: The learned allocations demonstrate that different transformer blocks require different treatments. MLP matrices are allocated fewer low-rank budgets (allowing the sparse component more flexibility to preserve capacity), while Attention blocks receive more rank budget to fully exploit their underlying structure.
- QR > SVD for Speed: Swapping SVD for QR decomposition in the inner loop is a game-changer. For 80 iterations of optimization, the SVD-based approach took 5 hours, while the QR-based approach took just 4 minutes, all while maintaining approximation quality.
- Truncated Gaussians Stabilize Training: Using a truncated Gaussian distribution for the policy gradient bounds the sampling range (keeping sparsity ratios strictly between 0 and 1). This prevents gradient explosions in low-density regions and stabilizes the search process.
Experimental Results
The framework was evaluated on models including Phi-3-mini, Llama-2 (7B, 13B), and Llama-3-8B, using the C4 dataset for calibration and benchmarks like WikiText2, MMLU, and various zero-shot tasks for evaluation.
- Accuracy: The proposed method consistently outperforms state-of-the-art baselines like SparseGPT, Wanda, and OATS. On Llama2-13B at 50% sparsity, it preserves over 95% of its original MMLU accuracy.
- Perplexity: On the WikiText2 benchmark, the method reduces Phi-3-mini’s perplexity by about 5% compared to the previous best RPCA method (OATS) at 50% sparsity.
- Speedup: When tested on CPUs using the DeepSparse engine, the 50%-pruned Llama2-13B achieved a 1.99x throughput speedup. It outperformed purely unstructured sparse methods because the structured low-rank components are highly optimized for modern hardware.
Conclusion and Future Work
While RPCA-based compression is inherently a more challenging optimization problem than simple metric-based pruning, this bilevel framework proves highly effective. Furthermore, the authors demonstrated that their outer-loop allocation framework can be detached and applied to other compression methods (like Wanda and SparseGPT) to improve their performance. This suggests the approach could serve as a general, plug-and-play sparsity allocation mechanism for a wide variety of future model compression pipelines.
Summary updated