Blocking Techniques for Sparse Matrix Multiplication on Tensor Accelerators

Paolo Sylos Labini, Massimo Bernaschi, Francesco Silvestri, Flavio VellaarXiv 2022

Introduction

Tensor Cores have revolutionized high-performance computing by providing massive throughput for dense matrix operations. However, Sparse Matrix Multiplication (SpMM)—critical for Graph Neural Networks (GNNs) and pruned Deep Learning models—remains a bottleneck. Because sparse matrices involve irregular memory access and low arithmetic intensity, they often fail to utilize the full potential of tensor hardware. This paper proposes 1-SA, a one-dimensional similarity-based blocking algorithm designed to reorder sparse matrices into dense blocks compatible with Tensor Cores.

The Challenge: Sparse Data on Dense Hardware

Modern accelerators like NVIDIA’s Tensor Cores are optimized for "arithmetic intensity," requiring data in small, dense chunks. Sparse matrices, characterized by a high percentage of zeros, lead to fragmented execution and low computational density. While specialized sparse hardware exists, it is often inflexible. The goal of this work is to leverage ubiquitous dense tensor hardware to accelerate sparse workloads by transforming irregular sparsity into structured blocks.

The 1-SA Reordering Algorithm

The authors introduce a reordering strategy called 1-SA (1-dimensional Similarity-based blocking). The process involves several key steps:

  1. Column Partitioning: The matrix columns are divided into fixed-width strips ($\Delta_W$). A width of 64 was identified as optimal for NVIDIA Tensor Cores, aligning with warp-level granularity.
  2. Row Reordering and Similarity Merging: Rows are treated as "patterns" of non-zero blocks. Using the Jaccard similarity metric, the algorithm groups rows with similar non-zero column positions.
  3. Density Guarantees: A theoretical merging condition ensures that resulting blocks maintain a minimum density, preventing excessive "fill-in" (zeros treated as non-zeros) which would waste computational resources.
Visualization of the row grouping process based on sparsity patterns.

The resulting reordered matrix is stored in a Variable Block Row (VBR) format and processed using standard high-performance libraries like cuBLAS via multiple CUDA streams.

Experimental Evaluation

The approach was evaluated on an NVIDIA V100 GPU using three distinct datasets:

  • Synthetic Blocked Matrices: Used to test the algorithm's ability to recover latent dense structures.
  • RMAT Matrices: Synthetic graphs mimicking real-world power-law distributions.
  • The Network Repository: A collection of over 30 real-world sparse matrices from social networks and scientific computing.

Results and Insights

The 1-SA approach demonstrated significant performance gains over the industry-standard cuSPARSE library, with speedups ranging from 3x to 100x on real-world matrices.

Trade-off between block height and relative density after reordering.

A key insight is the Density/Size Trade-off: achieving perfect density is not always necessary. In many cases, a slightly larger block containing some zeros (fill-in) is faster because it allows Tensor Cores to operate at higher TFLOPS than a perfectly sparse but irregular kernel. Furthermore, by only reordering rows and keeping column partitions fixed, the authors avoid the need to reorder the dense matrix being multiplied, significantly reducing overhead.

Conclusion

The 1-SA algorithm provides a robust method for mapping sparse workloads onto dense tensor hardware. By providing theoretical density guarantees and aligning with hardware granularity, it achieves massive speedups even for matrices with overall density as low as 0.01%. Future work includes parallelizing the reordering process to support dynamic sparsity patterns in real-time applications.

Summary updated

BibTeX
@misc{labini2022blocking,
  author = {Paolo Sylos Labini and Massimo Bernaschi and Francesco Silvestri and Flavio Vella},
  title = {{Blocking Techniques for Sparse Matrix Multiplication on Tensor Accelerators}},
  year = {2022},
  eprint = {2202.05868},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2202.05868},
}
Figure