Accelerating Sparse Convolution with Column Vector-Wise Sparsity

Yijun Tan, Kai Han, Kang Zhao, Xianzhi Yu, Zidong Du, Yunji Chen, Yunhe Wang, Jun YaoNeurIPS 2022

Abstract

Weight sparsity is a promising approach to reducing the model size and computation cost of convolutional neural networks (CNNs). However, non-zero weights often distribute randomly in sparse CNN models, introducing enormous difficulty in obtaining actual speedups on common hardware (e.g., GPUs) over their dense counterparts. Researchers have developed a novel "Outer-Vector-Wise" (OVW) sparsity pattern and a co-designed GPU kernel that finally makes sparse CNNs faster than dense ones, even at low sparsity levels. By pruning weights in $V \times 1$ column vectors and using offline channel reordering, this method achieves a 3.2$\times$ speedup over dense ResNet50 on an NVIDIA V100 with negligible accuracy loss.

The Hardware Gap in Weight Pruning

Weight pruning is a classic technique to shrink AI models, but it suffers from a persistent "hardware gap." While you can theoretically remove 90% of a model's weights, the remaining 10% are usually scattered randomly (unstructured sparsity).

GPUs are designed for massive, contiguous blocks of data and struggle with random memory accesses. Consequently, unstructured sparse models often run slower than their dense counterparts unless the sparsity is extreme (over 95%). Conversely, existing "structured" solutions (like pruning entire filters or large blocks) make the hardware happy but severely degrade the model's accuracy.

Comparison of different sparsity patterns: Element-Wise, Inter-Vector-Wise, Outer-Vector-Wise (OVW), and Block-Wise.

This research tackles the challenge of finding a "Goldilocks" sparsity pattern: structured enough for GPU speedups, but flexible enough to maintain high accuracy.

Methodology: A Co-Designed Approach

The authors introduce a two-pronged approach involving a new sparsity pattern and a specialized software kernel:

1. The Outer-Vector-Wise (OVW) Pattern

Instead of pruning individual weights, the method prunes $V \times 1$ vectors (columns) within the weight matrix. The key insight is that "vertical" vector integrity allows the GPU to maintain continuous memory access during convolution, which is critical for performance. While many patterns focus on horizontal rows, column-wise (vertical) vectors are the secret to preserving memory consistency when mapping 3D convolutions to 2D matrix operations on a GPU.

2. Implicit GEMM Kernel

To execute this pattern efficiently, the authors implemented a custom GPU kernel that performs "implicit" matrix multiplication. Unlike standard methods that create a massive intermediate matrix (IM2COL) in memory, this kernel calculates memory offsets on the fly, drastically reducing memory overhead.

Architecture of the proposed implicit GEMM kernel for processing OVW sparse convolutions.

3. Clustering-based Channel Permutation

To minimize the accuracy loss caused by forcing weights into rigid vectors, the authors propose an offline transformation step. They use a "Balanced K-Means" clustering algorithm to reorder the network's channels. By grouping similar rows together before pruning, they ensure that the most important weights are preserved within the $V \times 1$ blocks. Reordering channels is mathematically equivalent to the original network—it just changes the order of operations. This "free lunch" flexibility allows the structured OVW pattern to mimic the accuracy of unstructured pruning without adding any cost to inference time.

Key Results and Insights

The authors evaluated their method on standard computer vision benchmarks, including CIFAR-100 and ImageNet, across architectures like VGG19, ResNet18/50, SqueezeNet, and MobileNetV2.

  • The 10% Threshold: Most sparse acceleration libraries only start showing gains at 60-70% sparsity. Remarkably, the OVW method begins outperforming dense convolutions at just 10% sparsity, making it useful for a much wider range of applications.
  • Speed: On an NVIDIA V100 GPU, the OVW method achieved a 3.2$\times$ speedup over the dense cuDNN library and a 1.7$\times$ speedup over previous state-of-the-art sparse solutions at 75% sparsity.
  • Accuracy: On ImageNet with ResNet50, the method maintained a 73.35% top-1 accuracy at 70% sparsity, significantly outperforming other structured patterns.
  • Efficiency: The custom kernel reduces the run time of ResNet50 convolution layers by roughly 10% simply by optimizing how filter location information is stored and recovered.

Limitations and Future Work

While highly effective, the approach has a few limitations:

  • Hardware Specificity: The current implementation is heavily optimized for NVIDIA GPUs (specifically the V100). Its performance on other architectures, like AMD GPUs or specialized AI accelerators, remains to be validated.
  • Depthwise Convolutions: The method struggles with specialized layers like depthwise convolutions (common in MobileNet), where data reuse is naturally limited. In these cases, the vector length $V$ often has to be reduced to 1, reverting to less efficient processing.
  • Kernel Stability: Speedup measurements are compared against cuDNN, which is a proprietary "black box." Future changes in underlying vendor libraries could affect the relative speedup gains.

Summary updated

BibTeX
@inproceedings{tan2022accelerating,
  author = {Yijun Tan and Kai Han and Kang Zhao and Xianzhi Yu and Zidong Du and Yunji Chen and Yunhe Wang and Jun Yao},
  title = {{Accelerating Sparse Convolution with Column Vector-Wise Sparsity}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=Q5kXC6hCr1},
}
Figure