Preprint
Large Language Models

Seerattention: Learning intrinsic sparse attention in your llms

Yizhao Gao, Zhichen Zeng, Dayou Du, Shijie Cao, Peiyuan Zhou, Jiaxing Qi, Junjie Lai, Hayden Kwok-Hay So, Ting Cao, Fan Yang, Mao Yang
January 1, 2024

0

Citations

0

Influential Citations

Venue

2024

Year

Abstract

… Our block-sparse attention kernel achieves highly linear speedup over dense configurations, delivering a 7.3× speedup with 90% sparsity on sequences of 128k. The AttnGate …

Analysis

Why This Paper Matters

Long-context large language models (LLMs) are increasingly important for tasks like document summarization, code generation, and multi-turn conversations. However, the quadratic complexity of standard attention makes processing sequences beyond a few thousand tokens prohibitively expensive. Seerattention addresses this bottleneck by introducing a learned sparse attention mechanism that achieves near-linear speedup, enabling efficient inference on sequences up to 128k tokens.

The key insight is that attention patterns in LLMs are often intrinsically sparse—many token pairs contribute negligibly to the output. By learning to predict which blocks of the attention matrix are important, Seerattention avoids computing the full attention matrix, dramatically reducing both memory and computation. This is particularly valuable for deployment scenarios where latency and throughput are critical.

Technical Contributions

  • AttnGate: A lightweight neural module that predicts block-level importance scores for the attention matrix. It is trained jointly with the LLM and can be applied to any transformer-based model.
  • Block-Sparse Kernel: A custom CUDA kernel that leverages block sparsity to skip irrelevant blocks during attention computation. The kernel achieves highly linear speedup with respect to sparsity level.
  • End-to-End Training: The AttnGate is trained with a sparsity regularization loss to balance efficiency and model quality, ensuring minimal accuracy degradation.

Results

The paper reports a 7.3× speedup at 90% sparsity on sequences of length 128k compared to dense attention. The speedup scales linearly with sparsity, meaning higher sparsity yields proportionally larger gains. The method maintains competitive perplexity and downstream task performance, indicating that the learned sparsity patterns capture the essential attention structure.

Significance

Seerattention offers a practical path to scaling LLMs to longer contexts without quadratic cost. By making long-context inference more efficient, it enables new applications such as whole-document analysis, long-form question answering, and interactive agents with extended memory. The approach is complementary to other efficiency techniques like FlashAttention and can be integrated into existing LLM pipelines. Future work could explore adaptive sparsity levels and hardware-specific optimizations.