Skip to main content
QUICK REVIEW

[Paper Review] Pruning Self-attentions into Convolutional Layers in Single Path

Haoyu He, Jianfei Cai|arXiv (Cornell University)|Nov 23, 2021
Advanced Neural Network ApplicationsComputer Science64 references16 citations
TL;DR

SPViT proposes a single-path pruning framework that jointly optimizes self-attention and feed-forward network pruning in Vision Transformers by sharing weights between multi-head self-attention and convolutional operations, enabling efficient, automatic architecture search with low computational cost. It achieves state-of-the-art pruning performance, reducing 52.0% FLOPs in DeiT-B while improving top-1 accuracy by 0.6% on ImageNet-1k.

ABSTRACT

Vision Transformers (ViTs) have achieved impressive performance over various computer vision tasks. However, modeling global correlations with multi-head self-attention (MSA) layers leads to two widely recognized issues: the massive computational resource consumption and the lack of intrinsic inductive bias for modeling local visual patterns. To solve both issues, we devise a simple yet effective method named Single-Path Vision Transformer pruning (SPViT), to efficiently and automatically compress the pre-trained ViTs into compact models with proper locality added. Specifically, we first propose a novel weight-sharing scheme between MSA and convolutional operations, delivering a single-path space to encode all candidate operations. In this way, we cast the operation search problem as finding which subset of parameters to use in each MSA layer, which significantly reduces the computational cost and optimization difficulty, and the convolution kernels can be well initialized using pre-trained MSA parameters. Relying on the single-path space, we introduce learnable binary gates to encode the operation choices in MSA layers. Similarly, we further employ learnable gates to encode the fine-grained MLP expansion ratios of FFN layers. In this way, our SPViT optimizes the learnable gates to automatically explore from a vast and unified search space and flexibly adjust the MSA-FFN pruning proportions for each individual dense model. We conduct extensive experiments on two representative ViTs showing that our SPViT achieves a new SOTA for pruning on ImageNet-1k. For example, our SPViT can trim 52.0% FLOPs for DeiT-B and get an impressive 0.6% top-1 accuracy gain simultaneously. The source code is available at https://github.com/ziplab/SPViT.

Motivation & Objective

  • To address the high computational cost and lack of inductive bias in Vision Transformers due to multi-head self-attention layers.
  • To enable efficient, automatic pruning of pre-trained ViTs into compact models with introduced local inductive bias.
  • To reduce the search cost and optimization difficulty of NAS-based pruning by unifying MSA and convolutional operations in a single-path space.
  • To jointly optimize pruning of MSA layers and FFN expansion ratios under target FLOP constraints.
  • To explore the structural importance of ViT components through empirical analysis of searched architectures.

Proposed method

  • Proposes a weight-sharing scheme that expresses convolutional operations as subsets of MSA parameters, enabling shared parameterization between attention and convolution.
  • Constructs a single-path search space where all candidate operations (MSA and convolutions) are encoded within a single MSA per layer, reducing search complexity.
  • Introduces learnable binary gates in MSA layers to select which subset of MSA parameters to use, effectively pruning to convolutional operations.
  • Extends learnable gates to FFN layers to jointly prune hidden dimensions and optimize MLP expansion ratios.
  • Optimizes the learnable gates end-to-end to automatically discover efficient architectures under target FLOP constraints.
  • Initializes convolution kernels using pre-trained MSA parameters, enabling effective and stable training.
Figure 1: Multi-path vs. single-path search space. (a) Multi-path search space. MSA and different types of convolutional operations are added as separate trainable paths, leading to an expensive search cost. $\mathcal{P}$ and $g_{p}$ denote the ordered operation set and the learnable gate for the $p
Figure 1: Multi-path vs. single-path search space. (a) Multi-path search space. MSA and different types of convolutional operations are added as separate trainable paths, leading to an expensive search cost. $\mathcal{P}$ and $g_{p}$ denote the ordered operation set and the learnable gate for the $p

Experimental results

Research questions

  • RQ1Can a unified single-path search space reduce the computational cost and optimization difficulty of NAS-based ViT pruning?
  • RQ2Does sharing weights between MSA and convolutional operations enable effective and stable initialization of convolutional kernels?
  • RQ3Can joint pruning of MSA and FFN layers in a unified search space achieve better efficiency-accuracy trade-offs than separate pruning?
  • RQ4How do the structural choices in searched architectures (e.g., pruning MSA to convolutions in shallow vs. deep blocks) relate to the model's functional behavior?
  • RQ5What is the role of FFN capacity in different ViT blocks, and how does it vary across standard and hierarchical ViT architectures?

Key findings

  • SPViT reduces 52.0% FLOPs in DeiT-B while achieving a 0.6% top-1 accuracy gain on ImageNet-1k, setting a new SOTA for post-training pruning.
  • The method successfully prunes shallow MSA layers into convolutional layers or skip-connections, aligning with attention patterns that show local attention in shallow blocks.
  • Deep MSA layers are preserved in all models, confirming their importance for global representation learning.
  • FFN layers in deeper blocks of standard ViTs show higher redundancy and are preferentially pruned, suggesting lower capacity needs in later stages.
  • In hierarchical ViTs like Swin-Ti, shallower layers within each stage preserve more hidden dimensions, indicating higher capacity needs after token merging.
  • The single-path search space reduces search cost and optimization difficulty compared to multi-path NAS, enabling efficient joint search over MSA and FFN pruning.
Figure 2: Overview of our weight-sharing scheme, which expresses the bottleneck convolution with MSA parameters. First, we restrict the value and output projections in the MSA layer to only process the features within local regions. Then, we learn to ensemble the value projections with a parameteriz
Figure 2: Overview of our weight-sharing scheme, which expresses the bottleneck convolution with MSA parameters. First, we restrict the value and output projections in the MSA layer to only process the features within local regions. Then, we learn to ensemble the value projections with a parameteriz

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.