Accelerated Sparse Neural Training: A Provable and Efficient Method to Find N:M Transposable Masks

Itay Hubara, Brian Chmiel, Moshe Island, Ron Banner, Joseph Naor, Daniel Soudry

TL;DR

Researchers have developed a way to double the speed of neural network training by creating "transposable" sparsity masks. By ensuring that both a weight matrix and its transpose follow the same fine-grained sparsity pattern, they enable hardware acceleration for both the forward and backward passes of training with virtually no loss in accuracy.

The Bottleneck in Sparse Training

Pruning—removing unnecessary weights from a neural network—is a standard way to reduce a model's memory footprint. However, most pruning is "unstructured," meaning zeros are scattered randomly. Modern hardware, like GPUs, struggles to accelerate these random patterns.

Recently, hardware like the Nvidia A100 introduced support for N:M fine-grained block sparsity (specifically 2:4), where two out of every four weights must be zero. This speeds up the forward pass (inference) by 2x. However, it doesn't help much with training. During training, the "backward pass" requires multiplying by the transpose of the weight matrix ($W^T$). Even if the original matrix $W$ follows a 2:4 pattern, its transpose usually doesn't. This means the backward pass remains slow, bottlenecking the entire training process.

Transposable sparsity ensures both the forward and backward passes maintain the N:M structure, allowing hardware acceleration for both.

Key Innovations

The authors propose several major innovations to bridge this gap:

1. Mask Diversity (MD)

The researchers introduced a combinatorial metric called Mask Diversity to rank different sparsity patterns. MD measures the number of possible unique masks a specific constraint allows. They hypothesized—and proved—that higher mask diversity strongly correlates with higher final model accuracy. By expanding the block size (e.g., moving from 2:4 to 4:8), you can satisfy transposable constraints while maintaining high enough diversity to preserve accuracy.

There is a clear correlation between Mask Diversity (MD) and model accuracy across different sparsity constraints.

2. Transposable N:M Masks

They defined a new constraint where both $W$ and $W^T$ must satisfy the N:M sparsity requirement. To find the best mask, they formulated the problem as a minimum-cost flow problem. Instead of just picking the largest weights (magnitude pruning), treating mask selection as a graph theory problem provides a mathematically provable way to find the optimal structured mask.

3. Fast Approximation Algorithm

Because the optimal flow algorithm is too slow to run during every step of training, they developed a greedy 2-approximation algorithm. This algorithm runs in near-linear time, making it feasible to update sparsity masks dynamically as the model learns.

4. AdaPrune

To solve the problem of switching between different structure constraints, they introduced AdaPrune. This lightweight optimization method converts a pre-trained unstructured sparse model into a structured N:M model with minimal accuracy loss, avoiding the need for expensive retraining.

Experimental Validation and Results

The researchers validated their approach across standard benchmarks in Computer Vision (ImageNet with ResNet/VGG, COCO with MaskRCNN) and Natural Language Processing (SQuAD v1.1 with BERT).

  • 2x Speedup: The method enables a theoretical 2x acceleration in matrix multiplications during both the forward and backward passes.
  • Zero Accuracy Loss: On ImageNet, the 4:8 transposable mask achieved results comparable to (and sometimes better than) dense baselines. For example, ResNet50 achieved 77.1% accuracy with a 4:8 transposable mask, compared to 77.3% for the dense baseline.
  • High Efficiency: The 2-approximation algorithm added only about 14% overhead to the training time, significantly lower than the 180% overhead of a naive integer programming approach.
  • Seamless Conversion: Using AdaPrune, unstructured models were converted to structured ones with less than 1% accuracy degradation in most cases.

Limitations and Future Work

  • Hardware Dependency: The 2x speedup relies on hardware that supports these specific N:M patterns. While Nvidia's A100 supports 2:4, future hardware iterations are needed to fully exploit the 4:8 transposable patterns suggested here.
  • Training Instability: Accelerating training can sometimes lead to numerical issues that require careful monitoring in sensitive applications, though the authors did not observe instability in their tests.
  • Memory Footprint: This method focuses on computational speedup. It still maintains a dense copy of weights in the background during training (to allow masks to change), meaning it doesn't reduce the memory required during training, only the final model size and training time.

Summary updated

BibTeX
@inproceedings{hubara2021accelerated,
  author = {Itay Hubara and Brian Chmiel and Moshe Island and Ron Banner and Joseph Naor and Daniel Soudry},
  title = {{Accelerated Sparse Neural Training: A Provable and Efficient Method to Find N:M Transposable Masks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=vRWZsBLKqA},
}
Figure