Abstract
As neural network model sizes have dramatically increased, so has the interest in various techniques to reduce their parameter counts and accelerate their execution. An active area of research in this field is sparsity - encouraging zero values in parameters that can then be discarded from storage or computations. While most research focuses on high levels of sparsity, there are challenges in universally maintaining model accuracy as well as achieving significant speedups over modern matrix-math hardware. To make sparsity adoption practical, the NVIDIA Ampere GPU architecture introduces sparsity support in its matrix-math units, Tensor Cores. We present the design and behavior of Sparse Tensor Cores, which exploit a 2:4 (50%) sparsity pattern that leads to twice the math throughput of dense matrix units. We also describe a simple workflow for training networks that both satisfy 2:4 sparsity pattern requirements and maintain accuracy, verifying it on a wide range of common tasks and model architectures. This workflow makes it easy to prepare accurate models for efficient deployment on Sparse Tensor Cores.
Introduction: The Sparsity Paradox
Deep learning models are increasingly over-parameterized, leading to a surge in interest in pruning techniques to improve computational efficiency. However, a "Sparsity Paradox" has historically hindered adoption. Fine-grained (unstructured) sparsity allows for high accuracy by pruning arbitrary weights, but the resulting irregular memory access patterns are inefficient for modern GPUs. Conversely, coarse-grained (structured) sparsity, such as pruning entire channels, is hardware-friendly but often leads to significant accuracy degradation. NVIDIA researchers have addressed this by introducing a "Goldilocks" solution: the 2:4 structured sparsity pattern.
The 2:4 Structured Sparsity Pattern
The 2:4 pattern requires that for every group of four consecutive values in a weight matrix, at least two must be zero. This 50% sparsity level is high enough to provide significant hardware acceleration while remaining fine-grained enough to preserve model intelligence.
As shown in the figure above, this format allows the hardware to skip zero values during multiplication. By using a fixed 2:4 ratio, the storage overhead for tracking non-zero elements is minimized to just 2 bits per non-zero value. For 16-bit weights, this results in approximately 44% total storage savings.
Hardware Innovation: Sparse Tensor Cores
The NVIDIA Ampere architecture introduces Sparse Tensor Cores designed specifically to exploit this 2:4 pattern. These units effectively double the math throughput (peak TOPS) across FP16, BF16, and INT8 formats by performing twice as many operations in the same time interval as dense operations. The hardware uses the 2-bit metadata to select the matching elements from the dense input matrix (e.g., activations) to multiply with the non-zero weights.
Training Workflow
To facilitate the adoption of this technology, a straightforward three-step workflow is proposed that requires no hyperparameter tuning:
- Dense Training: The model is trained normally to completion.
- Pruning: A 2:4 mask is applied by keeping the two weights with the highest magnitude in every group of four.
- Retraining: The model is retrained using the original schedule and hyperparameters, with the pruning mask kept fixed.
As illustrated in the workflow diagram, the retraining phase recovers any accuracy lost during the initial pruning step. For particularly small models, a "Channel Permutation" technique can be used to prevent high-magnitude weights from being clumped together and lost during pruning.
Results and Discussion
The 2:4 sparsity approach was validated across a wide array of tasks, including image classification (ImageNet), object detection (COCO), and natural language processing (BERT, Transformer-XL).
- Accuracy Preservation: ResNet-50 achieved 76.2% accuracy (sparse) vs. 76.1% (dense). BERT-Large maintained an identical F1 score of 91.9 on SQuAD v1.1. Even generative models (GANs) showed stable FID scores, with some like Pix2Pix showing slight improvements.
- Performance Gains: Sparse Tensor Cores provide a 2x increase in peak throughput. When combined with INT8 quantization, this allows for massive models to run on significantly smaller hardware footprints without sacrificing quality.
While the current workflow doubles training time due to the retraining phase, it offers a robust path for doubling inference throughput without sacrificing model quality. Future work aims to accelerate the training process itself by satisfying sparsity constraints in both forward and backward passes.
Summary updated