TL;DR
GroupMask introduces a layer-adaptive, group-wise semi-structured pruning method for Large Language Models (LLMs). By using a lightweight hypernetwork to learn optimal sparsity ratios across different layers under a global budget, it breaks the rigid constraints of traditional N:M pruning, achieving significantly better model quality and zero-shot accuracy while maintaining a regular structure suitable for hardware acceleration.
What Problem Does This Paper Address?
Pruning is essential for deploying massive LLMs on resource-constrained hardware. However, researchers usually face a trade-off between unstructured pruning (flexible and high-quality, but slow on standard GPUs) and structured pruning (fast, but significantly degrades model performance).
Semi-structured pruning, particularly the N:M pattern (like 2:4 sparsity supported by NVIDIA Ampere GPUs), seeks a middle ground. The problem is that standard N:M pruning forces every single layer to have the exact same sparsity ratio. While "layer-adaptive" sparsity (giving more budget to important layers and less to redundant ones) works wonders for unstructured pruning, previous studies suggested it was ineffective for semi-structured patterns.
The authors of GroupMask investigate whether this failure is a fundamental limitation of semi-structured pruning or simply a byproduct of the overly restrictive N:M pattern.
Methods
The authors propose GroupMask, which shifts the focus from fine-grained N:M patterns to group-level sparsity.
- Group-Level Sparsity: Instead of looking at small windows of weights, the weight matrix is partitioned into regular groups (e.g., $1 \times 256$ or $32 \times 32$). Each group is either kept or pruned as a whole. This maintains a regular structure for hardware efficiency but allows the sparsity ratio of individual layers to vary.
- Hypernetwork-Based Mask Generation: Rather than using simple heuristics (like weight magnitude), GroupMask uses a lightweight hypernetwork (a bidirectional GRU) to generate "selector logits" for every group in the model simultaneously.
- Differentiable Optimization: To train the hypernetwork, the authors use a Gumbel-Sigmoid relaxation and a straight-through estimator (STE). This allows them to backpropagate gradients through the discrete "keep or prune" decisions.
- Self-Distillation: The model is trained by minimizing the KL divergence between the outputs of the original dense model (the teacher) and the new sparse model (the student). Crucially, the pretrained weights remain frozen; only the hypernetwork's parameters are updated.
- Global Budgeting: A log-ratio regularizer enforces a global sparsity target (e.g., 50% total parameters removed) while letting the hypernetwork decide exactly which layers should be sparse and which should stay dense.
Datasets
The authors evaluated GroupMask on several prominent LLM families, including LLaMA-2 (7B, 13B), LLaMA-3 (8B), and Qwen (8B, 14B).
- Calibration: WikiText-2 and Alpaca datasets were used to provide the training signal for the hypernetwork.
- Evaluation: Language modeling quality was measured via WikiText-2 perplexity. Downstream performance was tested across six zero-shot benchmarks: ARC-Challenge, ARC-Easy, BoolQ, HellaSwag, PIQA, and WinoGrande.
Key Insights and Ideas
- The N:M Constraint was the Culprit: The paper demonstrates that layer-adaptive allocation is highly beneficial for semi-structured pruning, provided you move away from the rigid N:M constraint. By allowing layers to "trade" sparsity, the model preserves its most critical components.
- Attention is More Redundant than MLPs: The learned masks revealed a fascinating trend: the model chose to prune deep attention layers (specifically Query and Key projections) much more aggressively—sometimes keeping as little as 8% of groups—while retaining over 50% of the weights in MLP projections.
- Hypernetworks Beat Direct Parameterization: Learning the mask through a hypernetwork resulted in much lower task loss and better generalization than trying to learn a mask parameter for every weight group directly.
Key Results
- Quality Boost: On LLaMA-2-7B at 50% sparsity, GroupMask reduced WikiText-2 perplexity from 10.02 (with uniform per-layer sparsity) to 8.30.
- Zero-Shot Gains: Average zero-shot accuracy improved from 0.455 to 0.496 compared to uniform allocation.
- State-of-the-Art: GroupMask outperformed several established baselines, including SparseGPT, Wanda, and MoDeGPT, across multiple models.
- Hardware Potential: While group-level sparsity isn't natively baked into current GPU kernels like 2:4 is, the authors implemented a custom kernel on an NVIDIA H100 that achieved a 1.09x speedup at 50% sparsity and 1.88x at 90% sparsity.
Limitations and Future Work
- Hardware Ecosystem: The primary hurdle is that group-level sparsity currently lacks the native, "out-of-the-box" hardware support that N:M patterns enjoy. Widespread adoption would require more mature custom sparse kernels.
- Scale: The experiments were conducted on models up to 14B parameters. Testing on 70B+ parameter models remains for future work.
- Heuristic Comparison: The comparison against N:M is somewhat indirect, as the non-uniform N:M baselines used in prior work were based on heuristics rather than the end-to-end learning approach used here.
Overall, GroupMask proves that semi-structured pruning doesn't have to be a "one-size-fits-all" approach for every layer, opening a new path for efficient LLM compression.
Summary updated