Lune

PPoPP2023顶会

Dynamic N: M Fine-Grained Structured Sparse Attention Mechanism

Zhaodong Chen, Zheng Qu, Yuying Quan, Liu Liu, Yufei Ding, Yuan Xie

摘要

Transformers are becoming the mainstream solutions for various tasks like NLP and Computer vision. Despite their success, the high complexity of the attention mechanism hinders them from being applied to latency-sensitive tasks. One opportunity to accelerate the attention mechanism is leveraging the sparsity in the attention weight matrix. However, due to the dilemma between "dynamic" and "fine-grained", previous studies fail to achieve speedup on GPUs under moderate sequence lengths. They also require costly retraining to recover accuracy. In this paper, we present DFSS, the first GPU-friendly dynamic fine-grained pruning mechanism, to address this dilemma. DFSS dynamically prunes the full attention score matrix to N:M fine-grained structured sparse pattern. Our key insight is that on the dynamic side, N:M sparsity is friendly to pruning and encoding the sparse matrix on GPU. On the fine-grained side, it always preserves the dominant entries in each row. We develop a dynamic sampled dense-dense matrix multiplication kernel, first of its kind, that multiplies the query and key matrices, prunes the result, and encodes the compressed sparse matrix without overhead. Compared with previous studies, DFSS achieves speedup in arbitrary sequence lengths. It only takes a few fine-tuning epochs to reach on-par accuracy with full attention mechanism. We provide both theoretical and empirical evidence to demonstrate DFSS is a good approximation of the full attention mechanism. We evaluate the 1:2 and 2:4 sparsity under different settings and achieve 1.38 1.86× speedups over the full-attention on A100 GPU. On tasks from various domains with sequence lengths from 384 to 4096, its accuracy is on par with the full attention after only a couple of finetuning epochs from the dense pre-trained model.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 10 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention 引用了 Reformer: The Efficient Transformer
  • Long Range Arena : A Benchmark for Efficient Transformers 引用了 Big Bird: Transformers for Longer Sequences
  • Long Range Arena : A Benchmark for Efficient Transformers 引用了 Reformer: The Efficient Transformer
  • Big Bird: Transformers for Longer Sequences 引用了 Reformer: The Efficient Transformer
  • Skeleton-of-Thought: Prompting LLMs for Efficient Parallel Generation 引用了 Big Bird: Transformers for Longer Sequences
  • Skeleton-of-Thought: Prompting LLMs for Efficient Parallel Generation 引用了 Reformer: The Efficient Transformer
  • Samoyeds: Accelerating MoE Models with Structured Sparsity Leveraging Sparse Tensor Cores 引用了 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Samoyeds: Accelerating MoE Models with Structured Sparsity Leveraging Sparse Tensor Cores 引用了 VENOM: A Vectorized N: M Format for Unleashing the Power of Sparse Tensor Cores
  • FlashMo: Geometric Interpolants and Frequency-Aware Sparsity for Scalable Efficient Motion Generation 引用了 Big Bird: Transformers for Longer Sequences
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper10

  1. Skeleton-of-Thought: Prompting LLMs for Efficient Parallel GenerationXuefei Ning, Zinan Lin, Zixuan Zhou, Zifu Wang 等ICLR 2024 · 105 次引用
  2. VENOM: A Vectorized N: M Format for Unleashing the Power of Sparse Tensor CoresRoberto L. Castro, Andrei Ivanov, Diego Andrade, Tal Ben-Nun 等SC 2023 · 22 次引用
  3. FlashMo: Geometric Interpolants and Frequency-Aware Sparsity for Scalable Efficient Motion GenerationZeyu Zhang, Yiran Wang, Danning Li, Dong Gong 等NeurIPS 2025 · 12 次引用
  4. Samoyeds: Accelerating MoE Models with Structured Sparsity Leveraging Sparse Tensor CoresChenpeng Wu, Qiqi Gu, Heng Shi, Jianguo Yao 等EuroSys 2025 · 5 次引用
  5. The Sparsity-Aware LazyGPU ArchitectureChangxi Liu, Miao Yu, Yifan Sun, Trevor E. CarlsonISCA 2025 · 1 次引用

它引用的 Paper15

  1. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn 等ICLR 2021 · 21,477 次引用
  2. Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie 等NeurIPS 2020 · 3,159 次引用
  3. Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 次引用
  4. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 次引用
  5. Long Range Arena : A Benchmark for Efficient TransformersYi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen 等ICLR 2021 · 881 次引用

相关 Paper

  1. DynaX: Sparse Attention Acceleration with Dynamic X: M Fine-Grained Structured PruningXiao Xiong, Zhaorui Chen, Yue Liang, Minghao Tian 等ASPLOS 2025 · 3 次引用
  2. Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token SelectionDongwon Jo, Beomseok Kang, Jiwon Song, jae-joon kimICML 2026 · 1 次引用
  3. Efficient Transformer Inference with Statically Structured Sparse AttentionSteve Dai, Hasan Genc, Rangharajan Venkatesan, Brucek KhailanyDAC 2023 · 11 次引用
  4. E.T.: re-thinking self-attention for transformer models on GPUsShiyang Chen, Shaoyi Huang, Santosh Pandey, Bingbing Li 等SC 2021 · 13 次引用
  5. Sparse GPU kernels for deep learningTrevor Gale, Matei Zaharia, Cliff Young, Erich ElsenSC 2020 · 170 次引用
黄昏的海面,两侧是细线勾勒的悬崖