Learning N: M Fine-grained Structured Sparse Neural Networks From Scratch

Aojun Zhou, Yukun Ma, Junnan Zhu, Jianbo Liu, Zhijie Zhang, Kun Yuan, Wenxiu Sun, Hongsheng Li

Learning N:M Fine-grained Structured Sparse Neural Networks From Scratch

Deep Learning models are growing exponentially, making deployment on edge devices or efficient data center usage increasingly difficult. To mitigate this, researchers often employ weight pruning, or sparsity. Historically, this has presented a strict trade-off:

  1. Unstructured Sparsity: Pruning individual weights anywhere maintains high accuracy but is "hardware-unfriendly," as GPUs struggle with irregular memory access.
  2. Structured Sparsity: Pruning entire channels or blocks is highly efficient on hardware but often significantly degrades model accuracy.

The "Goldilocks" solution is N:M fine-grained structured sparsity. For example, 2:4 sparsity means exactly 2 out of every 4 consecutive weights are pruned. Modern hardware, such as the Nvidia Ampere architecture (A100), features dedicated "Sparse Tensor Cores" that provide a 2x speedup specifically for this pattern.

N:M Sparsity Concept

However, existing methods to achieve this (like Nvidia’s ASP) require a cumbersome three-step process: train a dense model, prune it, and then fine-tune it. This paper tackles the challenge of training these N:M models from scratch in a single stage, achieving a 2x hardware speedup with virtually no loss in accuracy.

Overcoming Training Instability

The authors identify that the main hurdle in one-stage sparse training is the "flickering" of the sparse mask—weights constantly switching between being pruned and active, which destabilizes learning. To address this, they introduce two key concepts:

1. Sparse-Refined Straight-Through Estimator (SR-STE) Standard training uses a Straight-Through Estimator (STE) to pass gradients through the non-differentiable pruning function. The authors improve this by adding a "sparse-refined" regularization term. This term penalizes weights that were pruned in the forward pass, effectively discouraging them from jumping back into the active set unless they have a very high magnitude. This stabilizes the network's topology.

SR-STE Architecture

2. Sparse Architecture Divergence (SAD) SAD is a novel metric introduced to measure how much the sparse mask (the "architecture") changes between training iterations. The authors use SAD to prove that high architectural instability correlates with poor final accuracy. By keeping SAD low, SR-STE ensures the model converges to a high-quality solution.

Experimental Validation and Insights

The researchers evaluated their method across a diverse range of benchmarks, including ImageNet-1K (classification), MS COCO 2017 (detection/segmentation), FlyingChairs (optical flow), and WMT’14 (machine translation).

Key Results: * Accuracy Preservation: On ImageNet, a ResNet-50 with 2:4 sparsity achieved 77.0% top-1 accuracy, nearly matching the dense baseline of 77.3%. * The 4:8 Advantage: Interestingly, 4:8 sparsity (which shares the same 50% sparsity ratio as 2:4) reached 77.4%, actually outperforming the dense model. A larger "M" value allows for more flexible "N" weight combinations, preserving more complex features in the convolution kernels. * Efficiency: The 2:4 sparse models achieve a 2x theoretical speedup on supported hardware. In practice, the method reduces FLOPs and parameters by roughly 50% for 2:4 patterns and 75% for 2:8 patterns. * State-of-the-Art Performance: SR-STE outperformed other popular pruning methods like RigL, SNFS, and STR, especially at high sparsity levels (e.g., 80% or 95% sparsity). It also proved versatile, achieving negligible BLEU score loss in machine translation while halving the parameter count.

Limitations and Future Work

While highly effective, the primary benefits of N:M sparsity are currently tied to specific hardware (Nvidia Ampere and newer). On older GPUs, these models might not see a real-world speedup. Furthermore, the paper focuses on uniform N:M sparsity across all layers. The authors suggest that exploring non-uniform N:M sparsity (varying N and M per layer) could potentially yield even better results, leaving an exciting open area for future exploration.

Summary updated

BibTeX
@inproceedings{zhou2021learning,
  author = {Aojun Zhou and Yukun Ma and Junnan Zhu and Jianbo Liu and Zhijie Zhang and Kun Yuan and Wenxiu Sun and Hongsheng Li},
  title = {{Learning N: M Fine-grained Structured Sparse Neural Networks From Scratch}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=tldg9aaNd-F},
}
Figure