Abstract
The energy consumption of large-scale machine learning models is increasingly dominated by data movement, as billions of parameters are shuffled across memory hierarchies. Sparsification offers a principled way to mitigate these costs by pruning redundant weights and activations. However, effective sparsification remains challenging: existing methods often incur significant accuracy degradation or performance overhead. We introduce (Bl)ock (a)nd (S)parse (T)ransformers (BLaST), a general and robust method for sparsification applicable to linear layers in all settings. BLaST iteratively sparsifies weight matrices into a block sparsity pattern optimized for efficient sparse matrix-matrix (SpMM) multiplication. Our method achieves up to 95% sparsity in MLP weights with negligible accuracy loss (majority <2.25%). We demonstrate a 2.2x inference speedup for Llama 3.2 and a 4.45x reduction in inference memory footprint, resulting in a 2.9x reduction in GPU setup and operating costs.
The Hardware-Algorithm Gap in Sparsification
Large Language Models (LLMs) are notorious for their massive memory footprints. While pruning redundant weights is a known solution, it typically presents a trade-off between hardware efficiency and model accuracy.
- Unstructured Pruning removes individual weights, preserving accuracy well but creating irregular memory access patterns that GPUs struggle to process efficiently.
- Structured Pruning removes entire blocks or channels. While hardware-friendly, it often causes significant drops in model performance.
BLaST bridges this gap by utilizing block sparsity. This approach provides enough structure for hardware optimization while maintaining the flexibility required to preserve model accuracy.
Methods: Iterative Pruning and Custom Kernels
BLaST introduces a unified solution consisting of two primary pruning strategies and a high-performance compute kernel.
Pruning Strategies
- Blocked Prune and Grow (P&G): An iterative method that prunes blocks based on magnitude and "regrows" them using gradient information. This allows the model to dynamically discover optimal connection patterns during training or fine-tuning.
- oLLM (Optimal LLM Pruning): A second-order method inspired by "Optimal Brain Surgeon." It uses Hessian-based curvature information to identify and prune blocks with the least impact on the model's output, preserving accuracy even at extreme sparsity levels.
The BSpMM Kernel
The researchers developed a custom Block-Sparse Matrix-Matrix Multiplication (BSpMM) kernel using the Triton programming language. This kernel uses a Blocked Compressed Sparse Column (BCSC) layout and "fuses" nonlinear activation functions (like ReLU, GeLU, or SiLU) directly into the matrix multiplication. This fusion eliminates the need to write intermediate results back to slow global memory, significantly reducing data movement.
Key Results and Performance
The framework was evaluated across a diverse set of 8 datasets and 11 model architectures, including Llama 3.2 (up to 405B), Qwen3, and BERT.
Extreme Sparsity and Accuracy
BLaST achieved up to 95% sparsity in MLP weights with a median relative accuracy drop of only 2.24%. The authors found that MLPs are particularly robust targets for sparsification, leading to massive memory reductions without the fragility often seen in sparsified attention mechanisms.
End-to-End Efficiency
- Inference Speedups: BLaST delivered a 1.6x speedup for Llama 3.2-1B and a 2.2x speedup for distributed inference of Llama 3.2-405B.
- Kernel Performance: The custom BSpMM kernel outperformed dense GEMM by up to 23x at high sparsity levels and achieved up to 16x speedup over standard dense matrix multiplication in a single transformer block.
- Cost Savings: For the Llama 3.2-405B model, BLaST reduced the inference memory footprint by 4.45x, allowing the model to run on 2.9x fewer GPUs (e.g., NVIDIA GH200s).
Conclusion and Future Work
BLaST demonstrates that block sparsity is a "Goldilocks zone" for LLM optimization. By combining hardware-aware algorithms with custom Triton kernels, it achieves significant speedups and cost reductions. While the current work focuses heavily on MLP layers and was optimized for NVIDIA's Grace Hopper architecture, future research may extend these high-performance block-sparse kernels to the Attention mechanism and a broader range of hardware platforms.
Summary updated