Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
41 tokens/sec
GPT-4o
60 tokens/sec
Gemini 2.5 Pro Pro
44 tokens/sec
o3 Pro
8 tokens/sec
GPT-4.1 Pro
50 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Faster Causal Attention Over Large Sequences Through Sparse Flash Attention (2306.01160v1)

Published 1 Jun 2023 in cs.LG, cs.AI, and cs.CL

Abstract: Transformer-based LLMs have found many diverse applications requiring them to process sequences of increasing length. For these applications, the causal self-attention -- which is the only component scaling quadratically w.r.t. the sequence length -- becomes a central concern. While many works have proposed schemes to sparsify the attention patterns and reduce the computational overhead of self-attention, those are often limited by implementations concerns and end up imposing a simple and static structure over the attention matrix. Conversely, implementing more dynamic sparse attentions often results in runtimes significantly slower than computing the full attention using the Flash implementation from Dao et al. (2022). We extend FlashAttention to accommodate a large class of attention sparsity patterns that, in particular, encompass key/query dropping and hashing-based attention. This leads to implementations with no computational complexity overhead and a multi-fold runtime speedup on top of FlashAttention. Even with relatively low degrees of sparsity, our method improves visibly upon FlashAttention as the sequence length increases. Without sacrificing perplexity, we increase the training speed of a transformer LLM by $2.0\times$ and $3.3\times$ for sequences of respectively $8k$ and $16k$ tokens.

User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (4)
  1. Matteo Pagliardini (15 papers)
  2. Daniele Paliotta (8 papers)
  3. Martin Jaggi (155 papers)
  4. François Fleuret (78 papers)
Citations (19)