Skip to main content
QUICK REVIEW

[Paper Review] Transformer Acceleration with Dynamic Sparse Attention

Liu Liu, Zheng Qu|arXiv (Cornell University)|Oct 21, 2021
Advanced Neural Network ApplicationsComputer Science26 references12 citations
TL;DR

This paper proposes Dynamic Sparse Attention (DSA), a method that dynamically identifies and exploits input-dependent sparse attention patterns in Transformers to reduce computational cost without sacrificing model accuracy. By using a lightweight prediction path on approximate attention scores, DSA achieves up to 95% sparsity and 4.35× theoretical computation reduction, with only 1.33% overhead, delivering 1.94× speedup on attention output and 14.6× on softmax computation on V100 GPU under 90% sparsity.

ABSTRACT

Transformers are the mainstream of NLP applications and are becoming increasingly popular in other domains such as Computer Vision. Despite the improvements in model quality, the enormous computation costs make Transformers difficult at deployment, especially when the sequence length is large in emerging applications. Processing attention mechanism as the essential component of Transformer is the bottleneck of execution due to the quadratic complexity. Prior art explores sparse patterns in attention to support long sequence modeling, but those pieces of work are on static or fixed patterns. We demonstrate that the sparse patterns are dynamic, depending on input sequences. Thus, we propose the Dynamic Sparse Attention (DSA) that can efficiently exploit the dynamic sparsity in the attention of Transformers. Compared with other methods, our approach can achieve better trade-offs between accuracy and model complexity. Moving forward, we identify challenges and provide solutions to implement DSA on existing hardware (GPUs) and specialized hardware in order to achieve practical speedup and efficiency improvements for Transformer execution.

Motivation & Objective

  • To address the high computational cost of self-attention in Transformers, especially under long sequence lengths.
  • To overcome the limitations of static sparse attention patterns that fail to capture input-dependent dynamic sparsity.
  • To develop a practical, hardware-efficient method that maintains full attention's representational power while reducing computation.
  • To enable efficient deployment of large-scale Transformers on existing and specialized hardware through dynamic sparsity and dataflow optimization.

Proposed method

  • Augmenting standard self-attention with a lightweight prediction path to identify dynamic sparse patterns in attention scores.
  • Using low-cost approximate attention scores as input to a sparsity predictor to reduce computational overhead.
  • Representing predicted sparsity as learnable binary masks to skip unnecessary computations in softmax and output computation.
  • Extending fine-grained dynamic sparsity to structural patterns such as block-wise and vector-wise sparsity for hardware optimization.
  • Designing customized kernels and leveraging data reuse opportunities to improve memory access efficiency on GPUs and specialized accelerators.
  • Integrating low-precision inference for sparsity prediction and enabling token-level parallelism through computation reordering.

Experimental results

Research questions

  • RQ1Can dynamic sparse patterns in self-attention be effectively identified and exploited to reduce computation without sacrificing model accuracy?
  • RQ2How does dynamic sparsity compare to static or fixed sparse patterns in terms of accuracy and efficiency trade-offs?
  • RQ3What is the practical performance gain of DSA on existing GPU architectures and specialized hardware accelerators?
  • RQ4How can algorithmic sparsity be co-designed with hardware to maximize speedup and energy efficiency?

Key findings

  • DSA achieves up to 95% sparsity in attention weights with no measurable loss in model accuracy on the LRA benchmark.
  • The sparsity prediction introduces only 1.17% to 1.33% additional computational overhead, enabling a theoretical 4.35× reduction in computation.
  • On NVIDIA V100 GPU, DSA delivers 1.15× speedup in attention score computation, 14.6× speedup in softmax computation, and 1.94× speedup in attention output computation under 90% sparsity.
  • With vector-wise sparsity and optimized kernel design, DSA reduces total memory access by up to 2.54× on specialized hardware.
  • The method maintains full attention’s expressive power by preserving important attention weights, unlike low-rank approximations or aggressive pruning.
  • Hardware specialization enables further gains through low-precision prediction, fine-grained sparse computation, and improved data locality.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.