Progressive Gradient Flow for Robust N:M Sparsity Training in Transformers

Abhimanyu Rajeshkumar Bambhaniya, Amir Yazdanbakhsh, Suvinay Subramanian, Sheng-Chun Kao, Shivani Agrawal, Utku Evci, Tushar Krishna

TL;DR

This paper tackles the challenge of maintaining model accuracy when applying aggressive N:M structured sparsity to large transformer models. The authors introduce "decaying-based" training recipes that progressively control gradient flow, significantly improving performance at high sparsity levels and even reducing training FLOPs compared to existing methods.

What Problem Does This Paper Address?

Modern deep learning models, especially transformers, are becoming increasingly large, leading to significant computational and memory overhead. Sparsity, particularly N:M structured sparsity, offers a promising solution by reducing these costs while aiming to preserve model accuracy. However, existing N:M sparsity training methods often struggle to maintain performance when sparsity levels exceed 80%. The authors identify that this degradation is primarily caused by noisy gradients during training, which are exacerbated at higher sparsity. They aim to develop training strategies that can effectively handle high N:M sparsity without sacrificing model quality.

Methods

The core of the paper's contribution lies in its novel "decaying-based" sparse training recipes:

  • Mask Decay Gradient Flow (MDGF): This method introduces a decaying mask value that transitions from 1 to 0 over time, allowing gradients to flow more smoothly through pruned weights. Two variants are proposed:
  • MDGF-Linear: The decay rate is linear with respect to training steps.
  • MDGF-Exponential: The decay rate is exponential with respect to training steps.
  • Structure Decay Gradient Flow (SDGF): Instead of decaying mask values, this approach gradually alters the sparsity pattern itself, increasing sparsity over time. Two implementations are offered:
  • SDGF-Stepwise: Sparsity levels are increased in discrete steps.
  • SDGF-Geometric: Sparsity levels are increased by maintaining a constant ratio.

Crucially, these methods do not modify the gradient update rules themselves but rather control the flow of gradients through the sparsity mask and structure.

Datasets

The paper evaluates its methods on several standard datasets:

  • ImageNet-1K: Used for image classification tasks with ViT-Base and SwinV2 models.
  • CIFAR-10: Used for image classification with ViT-tiny models.
  • GLUE: A benchmark for natural language understanding tasks, used with T5X-Base models.
  • WMT-17 (English-German): Used for machine translation tasks with an encoder-decoder transformer model.

Key Insights and Ideas

  • Gradient Noise is the Culprit: The paper strongly suggests that the primary reason for performance degradation at high sparsity levels is the increased noise in gradient magnitudes, particularly during the early stages of training.
  • Gradient Flow is Key: By carefully controlling the flow of gradients through decaying masks or structures, the authors demonstrate a path to robust high-sparsity training. This "gradient flow is all you need" philosophy is central to their approach.
  • Occam's Hill Phenomenon: For some models and tasks, modest sparsity levels actually improve accuracy, suggesting sparsity can act as a form of regularization.
  • Hardware-Friendly Sparsity Pays Off: The paper highlights that fine-grained N:M structured sparsity, especially when implemented efficiently, can lead to significant speedups on real hardware due to reduced memory movement.

Key Results

  • Improved Accuracy: The proposed MDGF and SDGF methods achieve up to 2% and 5% accuracy improvement in vision and language models, respectively, at high sparsity regimes (>80%).
  • Reduced Training FLOPs: At iso-training FLOPs, the decaying-based methods yield up to 2% better accuracy than conventional sparse training recipes.
  • Efficiency Gains: MDGF-Exponential with 1:16 sparsity achieves comparable accuracy to SR-STE with 2:4 sparsity, but with 60% fewer inference FLOPs and 30% fewer parameters.
  • Real Hardware Speedup: Experiments show substantial speedups (up to 8.62x on V100, 5.87x on A100) for N:M sparsity variants over dense models, primarily due to memory savings and optimized kernels.
  • Robustness Across Models: The effectiveness of the proposed methods is demonstrated across different model architectures (ViT, SwinV2, T5X, ResNet-50) and tasks (image classification, language understanding, translation).

Limitations and Future Work

  • Theoretical Foundation: The paper acknowledges that while empirically effective, the exact theoretical underpinnings of why gradient decay alleviates sparsity effects are not fully explored.
  • Dynamic Scenarios: The current methods focus on static sparsity during training and may not directly extend to dynamic scenarios like KV cache compression in autoregressive models.
  • Autoregressive Models: Adapting these techniques to autoregressive models, which have high inference costs and memory constraints, is identified as a promising future direction.
  • Combining Methods: The authors suggest that combining MDGF and SDGF across different training regions might yield even better model quality.

Summary updated

BibTeX
@inproceedings{bambhaniya2025progressive,
  author = {Abhimanyu Rajeshkumar Bambhaniya and Amir Yazdanbakhsh and Suvinay Subramanian and Sheng-Chun Kao and Shivani Agrawal and Utku Evci and Tushar Krishna},
  title = {{Progressive Gradient Flow for Robust N:M Sparsity Training in Transformers}},
  booktitle = {CPAL (Proceedings Track)},
  year = {2025},
  url = {https://openreview.net/forum?id=HJjauwys0B},
}
Figure