How Sparse Attention Approximates Exact Attention? Your Attention is Naturally $n^C$-Sparse
Abstract
Sparse Attention is a technique that approximates standard attention computation with sub-quadratic complexity. This is achieved by selectively ignoring smaller entries in the attention matrix during the softmax function computation. Variations of this technique, such as pruning KV cache, sparsity-based fast attention, and Sparse Transformer, have been extensively utilized for efficient Large Language Models (LLMs) deployment. Despite its widespread use, a theoretical understanding of the conditions under which sparse attention performs on par with traditional attention remains elusive. This work aims to . Our theoretical framework reveals several brand-new key insights: Attention is -sparse, implying that considering only the largest entries out of all entries is sufficient for sparse attention to approximate the exact attention matrix with decreasing loss. Here, represents the input length and is a constant. Stable -sparse attention, which approximates attention computation with or fewer entries, may not be feasible since the error will persist at a minimum of . An adaptive strategy () for the window size of efficient attention methods rather than a fixed one is guaranteed to perform more accurately and efficiently in a task for inference on flexible context lengths.
Keywords
Cite
@article{arxiv.2404.02690,
title = {How Sparse Attention Approximates Exact Attention? Your Attention is Naturally $n^C$-Sparse},
author = {Yichuan Deng and Zhao Song and Jing Xiong and Chiwun Yang},
journal= {arXiv preprint arXiv:2404.02690},
year = {2025}
}