NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sparse GPU Kernels for Deep Learning

Trevor Gale, Matei Zaharia, Cliff Young, Erich Elsen · DOI

Abstract

Researchers from Stanford, Google Brain, and DeepMind have developed high-performance GPU kernels specifically for the "moderate" sparsity (70–95%) common in deep learning. Their approach achieves up to a 3.58× speedup over NVIDIA’s cuSPARSE, enabling sparse Transformer and MobileNet models to run faster and with significantly less memory without sacrificing accuracy.

The Challenge of Moderate Sparsity

Sparsity is often considered a "holy grail" in deep learning: theoretically, zeroing out 90% of a model's weights should yield a 10× speedup. In practice, however, sparse models frequently underperform compared to their dense counterparts on modern GPU hardware. This performance gap stems from two primary issues:

  1. The "Moderate" Sparsity Trap: Standard sparse libraries, such as NVIDIA's cuSPARSE, are optimized for extreme sparsity (e.g., 99.9% empty) typical of scientific simulations. Deep learning matrices typically fall into the 70–95% sparsity range. In this "moderate" zone, traditional sparse kernels often fail to outperform highly optimized dense kernels like cuBLAS.
  2. Unstructured vs. Structured Sparsity: To achieve hardware efficiency, many researchers resort to "structured" or "blocked" sparsity. While easier for hardware to process, forcing non-zero elements into specific blocks can significantly degrade model accuracy.
Figure 1: Comparison of runtime performance across different sparsity levels. The proposed approach (blue) outperforms dense cuBLAS (black) starting at 71% sparsity, whereas traditional sparse kernels (green) only surpass dense performance at 98% sparsity.

The authors addressed these challenges by building kernels that handle unstructured sparsity efficiently enough to provide real-world speedups at the moderate levels found in neural networks.

Technical Innovations

The researchers developed custom kernels for two critical operations: SpMM (Sparse Matrix-Dense Matrix Multiplication) and SDDMM (Sampled Dense-Dense Matrix Multiplication). Their implementation, released as the Sputnik library, relies on three key innovations:

  • Hierarchical 1-Dimensional Tiling: Instead of mapping an entire sparse row to a single GPU thread block, the output is sharded into 1D tiles. This strategy improves load balancing and allows the kernel to scale effectively across various matrix shapes and batch sizes.
  • Reverse Offset Memory Alignment (ROMA): GPUs perform best with "aligned" memory access in 32-byte chunks. Sparse data is naturally misaligned. ROMA shifts memory pointers to the nearest aligned address and uses bitmasking to ignore extraneous data, enabling the use of high-speed vector memory instructions.
  • Row Swizzle Load Balancing: To prevent "tail effects" where some GPU cores remain idle while others finish dense rows, the authors implemented a two-level re-ordering system (binning and bundling) to ensure uniform workload distribution across the GPU.

Why Deep Learning Matrices are Different

A core insight of this work is that deep learning matrices possess unique statistical properties compared to traditional scientific matrices. By analyzing a corpus of over 3,000 matrices from models like ResNet-50 and Transformer, the researchers found that DL matrices have significantly longer rows and roughly 25× less variation in row length than those in the SuiteSparse Matrix Collection.

Figure 2: Statistical comparison between deep learning matrices and traditional scientific matrices (SuiteSparse). Deep learning matrices (blue) exhibit more regular row lengths and higher average row lengths, characteristics that the Sputnik kernels exploit for optimization.

This relative regularity allows for more predictable memory access patterns and better load balancing, which the Sputnik kernels exploit to outperform general-purpose sparse libraries.

Key Results and Impact

Tested on NVIDIA V100 GPUs, the Sputnik kernels demonstrated significant performance gains:

  • SpMM Performance: Achieved a 3.58× geometric mean speedup over cuSPARSE, reaching 27% of the GPU's theoretical single-precision peak.
  • SDDMM Performance: Achieved a 2.19× geometric mean speedup over cuSPARSE.
  • End-to-End Efficiency:
    • A Sparse Transformer saw a 2.09× speedup and a 12.8× reduction in memory usage for attention layers.
  • Sparse MobileNetV1 models achieved speedups of 21–24% while maintaining the same accuracy as dense versions.

Limitations and Future Outlook

While these kernels represent a major step forward for unstructured sparsity, some bottlenecks remain. Performance on very large problems is currently limited by GPU shared memory bandwidth. Additionally, the SpMM kernel does not yet efficiently "fuse" matrix transpose operations, which adds overhead during model training. As hardware evolves—such as with NVIDIA's Ampere architecture and its native support for 2:4 structured sparsity—the trade-offs between unstructured and structured approaches will continue to shift.

Source Code: The implementation is available in the Sputnik library.

Summary updated

BibTeX
@inproceedings{gale2020sparse,
  author = {Trevor Gale and Matei Zaharia and Cliff Young and Erich Elsen},
  title = {{Sparse GPU Kernels for Deep Learning}},
  booktitle = {SC},
  year = {2020},
  doi = {10.1109/sc41405.2020.00021},
}
Figure