preprintarXiv (Cornell University)May 27, 2022GREEN OA

FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness

Indexed inarxivdatacite

Abstract

Transformers are slow and memory-hungry on long sequences, since the time and memory complexity of self-attention are quadratic in sequence length. Approximate attention methods have attempted to address this problem by trading off model quality to reduce the compute complexity, but often do not achieve wall-clock speedup. We argue that a missing principle is making attention algorithms IO-aware -- accounting for reads and writes between levels of GPU memory. We propose FlashAttention, an IO-aware exact attention algorithm that uses tiling to reduce the number of memory reads/writes between GPU high bandwidth memory (HBM) and GPU on-chip SRAM. We analyze the IO complexity of FlashAttention, showing that it…

Citation impact

458
total citations
FWCI
Percentile
References
0
Citations per year

Authors

5

Topics & keywords

Keywords
  • Speedup
  • Computer science
  • Parallel computing
  • Perplexity
  • FLOPS
  • Memory bandwidth
  • Algorithm
  • Language model
No related works found for this paper.