Data-independent Module-aware Pruning for Hierarchical Vision Transformers

Yang He, Joey Tianyi Zhou

Introduction

Pruning is a standard technique for reducing the size and computational cost of deep learning models by removing redundant weights. While well-established for Convolutional Neural Networks (CNNs), applying pruning to hierarchical Vision Transformers (ViTs) like the Swin Transformer presents unique challenges. Researchers have introduced DIMAP (Data-independent Module-Aware Pruning), a novel method designed to efficiently slim down these complex architectures without requiring input data for calibration.

The Challenge of Hierarchical ViTs

Traditional pruning methods often struggle with hierarchical ViTs due to their distinct structural properties. Unlike CNNs, which are dominated by convolutional layers, hierarchical ViTs rely heavily on fully connected (FC) and attention (ATT) layers.

Comparison of parameter and FLOP distributions between traditional CNNs and the Swin-B Transformer.

The primary difficulties include:

  1. Local vs. Global Importance: Hierarchical ViTs use local window attention. Global magnitude pruning might inadvertently remove weights that are critical for specific local features but have small absolute values relative to the entire network.
  2. Distribution Shifts: Feature resolution changes across stages (from fine to coarse), leading to varying weight distributions that simple magnitude pruning ignores.
  3. Data Dependency: Many state-of-the-art methods require passing large datasets through the model to identify important neurons, which is computationally expensive and slow.

DIMAP: A Module-Aware Approach

DIMAP addresses these issues by being both data-independent and module-aware. Instead of treating the network as a flat sequence of layers, it recognizes the functional blocks within the transformer architecture.

Architecture of a Swin Transformer block and its hierarchical stages, illustrating the modules targeted by DIMAP.

Key Methodological Components

  • Module-Awareness: DIMAP groups layers into functional modules, such as Attention-related modules (QKV and Projection) and Multilayer Perceptron (MLP) modules. This ensures that importance comparisons are made within functionally similar groups.
  • Information Distortion Metric: The method utilizes a metric derived from Frobenius distortion analysis. It calculates the potential "information flow" distortion caused by removing a weight, providing a more sophisticated importance measure than simple magnitude.
  • One-Shot Pruning: Since the metric is purely mathematical and based on existing weights, pruning is performed in a single step, avoiding the need for iterative "prune-and-fine-tune" cycles.

Key Results and Insights

Evaluations on the ImageNet-1k benchmark using Swin-T, Swin-S, and Swin-B models demonstrate the effectiveness of DIMAP:

  • High Efficiency: For Swin-B, DIMAP removed 52.5% of FLOPs and 52.7% of parameters with a negligible top-5 accuracy drop of only 0.07%.
  • Pruning as Regularization: Interestingly, pruning sometimes improved performance. For Swin-S, a 33.2% reduction in size led to a 0.8% higher relative top-5 accuracy, suggesting that pruning can act as a form of regularization against overfitting.
  • Superiority of "Prune-from-Large": A large model pruned down to a specific size often outperforms a smaller model designed for that size from scratch. For example, a pruned Swin-B typically beats a standard Swin-S.
  • Layer Sensitivity: Analysis revealed that earlier layers (closer to the input) are more sensitive and retain more parameters, highlighting the importance of initial fine-grained feature extraction.

Conclusion and Future Work

DIMAP provides a fast, data-free way to optimize hierarchical ViTs. While it significantly reduces theoretical complexity (FLOPs), the authors note that unstructured pruning may not always lead to immediate speedups on standard GPUs, which favor structured pruning. Future research will explore the performance of these pruned models on downstream tasks such as object detection and semantic segmentation.

Summary updated

BibTeX
@inproceedings{he2024data,
  author = {Yang He and Joey Tianyi Zhou},
  title = {{Data-independent Module-aware Pruning for Hierarchical Vision Transformers}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=7Ol6foUi1G},
}
Figure