LevAttention: Time, Space, and Streaming Efficient Algorithm for Heavy Attentions
Not on the map. Why?
Abstract (arXiv)
A central problem related to transformers can be stated as follows: given two n × d matrices Q and K, and a non-negative function f, define the matrix A as follows: (1) apply the function f to each entry of the n × n matrix Q KT, and then (2) normalize each of the row sums of A to be equal to 1. The matrix A can be computed in O(n2 d) time assuming f can be applied to a number in constant time, but the quadratic dependence on n is prohibitive in applications where it corresponds to long context lengths. For a large class of functions f, we show how to find all the ``large attention scores", i.e., entries of A which are at least a positive value varepsilon, in time with linear dependence on n (i.e., n · textrmpoly(d/varepsilon)) for a positive parameter varepsilon > 0. Our class of functions include all functions f of the form f(x) = |x|p, as explored recently in transformer models. Using recently developed tools from randomized numerical linear algebra, we prove that for any K, there is a ``universal set" U subset [n] of size independent of n, such that for any Q and any row i, the large attention scores Ai,j in row i of A all have j ∈ U. We also find U in n · textrmpoly(d/varepsilon) time. Notably, we (1) make no assumptions on the data, (2) our workspace does not grow with n, and (3) our algorithms can be computed in streaming and parallel settings. We call the attention mechanism that uses only the subset of keys in the universal set as LevAttention since our algorithm to identify the universal set U is based on leverage scores. We empirically show the benefits of our scheme for vision transformers, showing how to train new models that use our universal set while training as well, showing that our model is able to consistently select ``important keys'' during training.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 26 of its 38 references that are in the map. First posted on arXiv 7 Oct 2024.
Builds on
26 of 38 references.
References · 26
- 2020An Image is Worth 16x16 Words: Transformers for Image Recognition at Scalecited by 29,915
- 2014ImageNet Large Scale Visual Recognition Challengecited by 8,441
- 2020Longformer: The Long-Document Transformercited by 3,362
- 2020Big Bird: Transformers for Longer Sequencescited by 1,673
- 2020Reformer: The Efficient Transformercited by 1,658
- 2020Rethinking Attention with Performerscited by 1,584
- 2019Generating Long Sequences with Sparse Transformerscited by 1,523
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,462
- 2018Image Transformercited by 770
- 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 468
- 2021Random Feature Attentioncited by 350
- 2014Sketching as a Tool for Numerical Linear Algebracited by 285
14 more
- 2020Sparse Sinkhorn Attentioncited by 250
- 2021LambdaNetworks: Modeling Long-Range Interactions Without Attentioncited by 107
- 2023Fast Attention Requires Bounded Entriescited by 102
- 2023HyperAttention: Long-context Attention in Near-Linear Timecited by 85
- 2021KVT: k-NN Attention for Boosting Vision Transformerscited by 64
- 2021Memory-efficient Transformers via Top-k Attentioncited by 59
- 2023KDEformer: Accelerating Transformers via Kernel Density Estimationcited by 58
- 2015Optimal approximate matrix product in terms of stable rankcited by 37
- 2023PolySketchFormer: Fast Transformers via Sketching Polynomial Kernelscited by 33
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Timecited by 30
- 2023Solving Attention Kernel Regression Problem via Pre-conditionercited by 20
- 2016Online Row Samplingcited by 15
- 2019Dimensionality Reduction for Tukey Regressioncited by 12
- 2023Hardness of Low Rank Approximation of Entrywise Transformed Matrix Productscited by 3
Built on by
Citing papers per year: 2025: 1; 2026: 2.
3 papers.