TL;DR
PIT is a deep learning compiler that tackles the "misalignment" problem in dynamic sparsity—where sparse data patterns don't match GPU-efficient hardware tiles. By leveraging the mathematical property of Permutation Invariant Transformation, PIT packs sparsely located data into dense, high-performance tiles at runtime with negligible overhead, achieving up to 5.9x speedups in inference and training for large-scale models.
What Problem Does This Paper Address?
Modern deep learning models are increasingly sparse, meaning many of their tensor values are zero. While static sparsity (like fixed model weights) can be optimized at compile-time, dynamic sparsity—where the pattern of zeros changes based on the input—is a nightmare for performance. This occurs in Mixture-of-Experts (MoE) models, dynamic attention mechanisms, and models with variable sequence lengths.
The core challenge is a trade-off between computation waste and hardware efficiency. GPUs perform best when processing data in large, regular "tiles." As shown in Figure 1, if you use tiles that perfectly fit the sparse data, they are often too small or irregular for the GPU to handle efficiently (low utilization). If you use large, GPU-friendly tiles, you end up "computing" a vast number of zeros (high waste). Existing libraries like cuSPARSE often incur high "conversion overhead" when trying to reformat this data on the fly, sometimes making sparse execution slower than just running the dense version.
Methods
The authors introduce PIT, a compiler that uses a "sparse-to-dense" transformation strategy. Its secret weapon is the Permutation Invariant Transformation (PIT) property.
- Permutation Invariance: Many deep learning operators (like Matrix Multiplication or Convolution) have axes where the order of elements doesn't affect the final result. For example, in $C = A \times B$, you can shuffle the rows of $A$ as long as you shuffle the rows of $C$ the same way.
- Micro-tiles: PIT breaks tensors into "micro-tiles"—small units (e.g., 1x8 blocks) that match the GPU's memory transaction size.
- SRead and SWrite: Instead of a slow, separate data conversion step, PIT uses two new primitives.
SReadgathers non-zero micro-tiles from global memory and packs them into a dense tile in the GPU's fast shared memory. After computation,SWriteputs them back in their original (sparse) logical positions. This "piggybacks" the rearrangement onto the standard data movement already required for computation. - Online Sparsity Detector: PIT includes a high-speed, parallelized index builder that identifies non-zero micro-tiles at runtime.
- JIT Kernel Generation: The compiler generates specialized GPU kernels that implement these PIT rules, choosing the best micro-tile size based on the model's current sparsity ratio.
Datasets
The researchers evaluated PIT across a wide range of models and tasks:
- Natural Language Processing: BERT, OPT (13B and 30B), Switch Transformer, Longformer, and Museformer.
- Computer Vision: Swin-MoE.
- Benchmarks/Datasets: MNLI (GLUE), ImageNet, Alpaca, IMDB, Multi-XScience, and Multi-News.
- The paper uses these to demonstrate PIT's versatility across different types of dynamic sparsity, such as MoE routing, ReLU activations, and variable sequence lengths.
Key Insights and Ideas
- The "Aha!" Moment: You don't have to keep sparse data in its original order. If the math allows reordering, you can "compact" the data into dense blocks for free during the memory load phase.
- Breaking the Dilemma: PIT achieves the "best of both worlds" shown in Figure 1: the high utilization of dense tiles with the low waste of sparsity-aligned tiles.
- Sparsity is Fleeting: The authors found that dynamic sparsity patterns almost never repeat (Figure 20 in the paper). This invalidates "caching" strategies and proves that a fast, online approach like PIT is necessary.
- Zero-Copy Rearrangement: By integrating the data shuffling into the
SRead/SWriteprimitives, PIT avoids the massive memory copy overheads that plague other sparse libraries.
Key Results
- End-to-End Inference: PIT achieved speedups of up to 5.9x (average 2.43x) over state-of-the-art compilers and libraries like DeepSpeed, TurboTransformer, and MegaBlocks.
- Training Speedups: For large language model training (OPT), PIT provided up to 1.8x speedup. In sparse training scenarios, it reached 2.4x.
- Memory Efficiency: By avoiding the heavy padding required by dense frameworks to handle variable sequence lengths, PIT significantly reduced the GPU memory footprint.
- Low Overhead: The "conversion" cost (detecting sparsity and building indices) was reduced to just 0.7%–1.1% of total execution time, compared to the massive overheads seen in cuSPARSE.
Limitations and Future Work
- Axis Constraints: Currently, PIT primarily exploits reordering along a single axis. The authors mention that more complex rules involving multiple axes are possible but were left for future work.
- Hardware Integration: While PIT works on standard GPUs, the authors suggest it could be even more powerful if combined with hardware-specific features like NVIDIA’s 2-in-4 Sparse Tensor Cores.
- Profiling Time: The initial offline profiling to build the performance look-up table can take several hours, though this is a one-time cost per GPU type.
Summary updated