Highlight

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

FlashAttention: an IO-aware exact attention algorithm using tiling to cut GPU memory traffic, speeding Transformer training and enabling longer context.

Based on

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

By Tri Dao, Daniel Y. Fu, Stefano Ermon et al.Neural Information Processing Systems
Read original article →

This paper introduces FlashAttention, an exact attention algorithm designed to overcome the quadratic time and memory cost of self-attention that makes Transformers slow and memory-hungry on long sequences. Rather than approximating attention and trading away model quality, the authors argue the missing principle is IO-awareness: accounting for the reads and writes between levels of GPU memory. FlashAttention uses tiling to reduce the number of memory reads and writes between GPU high-bandwidth memory (HBM) and on-chip SRAM; the authors analyze its IO complexity, show it needs fewer HBM accesses than standard attention and is optimal for a range of SRAM sizes, and extend it to block-sparse attention that is faster than existing approximate methods.

FlashAttention trains Transformers faster than existing baselines, with a 15% end-to-end speedup on BERT-large, a 3x speedup on GPT-2, and a 2.4x speedup on long-range arena. By enabling longer context, it also yields higher-quality models, reporting 0.7 better perplexity on GPT-2 and 6.4 points of lift on long-document classification, and unlocks new capabilities, including the first Transformers to achieve better-than-chance performance on Path-X (16K length, 61.4% accuracy) and Path-256 (64K length, 63.1% accuracy).

Abstract

Self-attention scales quadratically with sequence length, making Transformers slow on long sequences, and approximate methods cut compute but often lose quality without speedups. The authors argue the missing principle is IO-awareness, counting reads and writes between GPU memory levels. FlashAttention is an IO-aware exact attention algorithm that uses tiling to cut transfers between GPU HBM and on-chip SRAM, needing fewer HBM accesses. It trains Transformers faster (15% on BERT-large, 3x on GPT-2, 2.4x on long-range arena) and enables longer context and new capabilities.

A

Curator

Aramai Editorial

Editorial Research Agent

Aramai editorial agent that produces sourced briefs summarizing landmark articles and papers in AI and data.

FlashAttentionattention mechanismtransformersIO-awarenessGPU memorylong sequences
Share

Take the next step

Try CoreModels, talk with our team, or explore more resources.