Spatial Re-parameterization for N: M Sparsity

Yuxin Zhang, Mingbao Lin, Yunshan Zhong, Mengzhao Chen, Fei Chao, Rongrong Ji

TL;DR

This paper introduces "Spatial Re-parameterization" (SpRe), a novel method to bridge the performance gap between N:M sparsity and unstructured sparsity in neural networks. By introducing an auxiliary branch that mimics the spatial sparsity distribution of unstructured sparsity during training, SpRe allows N:M sparse networks to achieve comparable performance without any additional inference cost.

What Problem Does This Paper Address?

Neural network sparsity is crucial for reducing model complexity and enabling efficient deployment. While unstructured sparsity offers high performance retention, it's computationally challenging to accelerate on hardware. N:M sparsity, on the other hand, provides practical speedups due to its structured nature and hardware support, but it historically lags behind unstructured sparsity in performance, especially at high sparsity rates. The core problem this paper addresses is understanding why N:M sparsity underperforms and proposing a method to close this performance gap without sacrificing its inherent acceleration benefits.

Methods

The paper's key innovation is Spatial Re-parameterization (SpRe). The authors observe that N:M sparsity enforces a uniform sparsity distribution across the spatial dimensions of convolution filters, while unstructured sparsity exhibits a more varied, "uneven" spatial sparsity. They hypothesize that this unevenness is critical for performance retention as it allows networks to prioritize salient features in different spatial locations.

SpRe tackles this by:

  • Introducing an Extra Branch: During training, SpRe adds a secondary branch to the N:M sparse network. This branch is trained to learn weights that follow the spatial sparsity distribution of an unstructured sparse network (obtained via magnitude pruning, for example).
  • Re-parameterization for Inference: After training, this extra branch is merged into the main N:M branch. This is achieved through a process called structural re-parameterization, where the weights and biases of the extra branch are combined with the main branch's weights. Crucially, this merging process does not introduce any additional parameters or computational overhead during inference.
  • BN-Induced Optimization Decoupling: The paper highlights that the presence of Batch Normalization (BN) layers in each branch allows for independent optimization of their parameters. This decoupling is key to enabling the extra branch to learn the desired spatial sparsity distribution without interfering with the main N:M branch's training.

Datasets

The paper evaluates its method on several standard computer vision datasets:

  • CIFAR-10: Used for image classification experiments with ResNet-32.
  • ImageNet-1K: Used for image classification experiments with ResNet-18, ResNet-50, MobileNet-V1, and MobileNet-V2.
  • COCO: Used for object detection (Faster R-CNN) and instance segmentation (Mask R-CNN) tasks.

Key Insights and Ideas

  • Spatial Sparsity Variation is Key: The most significant insight is that the variability in spatial sparsity distribution, as seen in unstructured sparsity, is crucial for robust performance retention, especially at high sparsity levels. N:M sparsity's uniform spatial sparsity is a bottleneck.
  • Mimicking Unstructured Sparsity: SpRe effectively "borrows" the beneficial spatial sparsity distribution from unstructured sparsity methods and applies it to N:M sparse networks during training.
  • Inference Cost Neutrality: The clever re-parameterization step ensures that SpRe adds no computational burden during inference, making it a highly practical enhancement for N:M sparse models.
  • BN as an Enabler: The paper demonstrates that Batch Normalization plays a vital role in allowing the two branches (N:M and the extra spatial sparsity branch) to be trained independently and effectively.

Key Results

SpRe consistently improves the performance of various N:M sparsity methods across different benchmarks:

  • Image Classification:
    • On CIFAR-10, SpRe boosts the Top-1 accuracy of SR-STE by up to 1.3% for the 1:16 sparsity pattern on ResNet-32.
  • On ImageNet-1K, SpRe improves SR-STE on ResNet-50 by 1.2% at 1:16 sparsity, even surpassing the unstructured sparse method GraNet by 0.4%.
  • For lightweight networks like MobileNet-V1/V2, SpRe provides substantial gains, e.g., enhancing ASP on MobileNet-V1 by up to 7.6% at 1:16 sparsity.
  • Object Detection and Instance Segmentation:
    • SpRe improves mAP for Faster R-CNN on COCO by up to 0.5% at 1:16 sparsity.
  • Similar improvements are observed for Mask R-CNN on COCO.
  • Convergence: SpRe also leads to faster convergence and improved final accuracy compared to N:M methods without SpRe.

Limitations and Future Work

  • Training Overhead: SpRe introduces a slight additional overhead during the training phase due to the extra branch. The authors acknowledge this and suggest future work could focus on developing more efficient methods to mitigate this.
  • Generalization to Non-CNN Architectures: The current work focuses on CNNs. The authors propose that exploring similar re-parameterization strategies for other architectures like Vision Transformers (ViTs) and BERT, by investigating distributional disparities between unstructured and N:M sparsity, could be a promising future direction.
  • Mitigating Spatial Sparsity Lack: Further research into more efficient ways to address the inherent lack of spatial sparsity variability in N:M sparsity is also suggested.

Summary updated

BibTeX
@article{zhang2023spatial,
  author = {Yuxin Zhang and Mingbao Lin and Yunshan Zhong and Mengzhao Chen and Fei Chao and Rongrong Ji},
  title = {{Spatial Re-parameterization for N: M Sparsity}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2023},
  url = {https://openreview.net/forum?id=CqckFNpgXT},
}
Figure