paper-with-me

홈 › Papers

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

2022-05-27 · Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, Christopher Ré

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 requires fewer HBM accesses than standard attention, and is optimal for a range of SRAM sizes. We also extend FlashAttention to block-sparse attention, yielding an approximate attention algorithm that is faster than any existing approximate attention method. FlashAttention trains Transformers faster than existing baselines: 15% end-to-end wall-clock speedup on BERT-large (seq. length 512) compared to the MLPerf 1.1 training speed record, 3$\times$ speedup on GPT-2 (seq. length 1K), and 2.4$\times$ speedup on long-range arena (seq. length 1K-4K). FlashAttention and block-sparse FlashAttention enable longer context in Transformers, yielding higher quality models (0.7 better perplexity on GPT-2 and 6.4 points of lift on long-document classification) and entirely new capabilities: the first Transformers to achieve better-than-chance performance on the Path-X challenge (seq. length 16K, 61.4% accuracy) and Path-256 (seq. length 64K, 63.1% accuracy).

📄 PDF Abstract BibTeX arXiv:2205.14135

Code (13)

dao-ailab/flash-attention 공식 구현 pytorch
ROCm/flash-attention pytorch
alibaba/megatron-llama pytorch
answerdotai/modernbert pytorch
csguoh/fastvar pytorch
facebookresearch/xformers/blob/main/xformers/ops/fmha/flash.py pytorch
hazyresearch/flash-attention pytorch
latkins/trifast jax
lucidrains/block-recurrent-transformer-pytorch pytorch
lucidrains/flash-cosine-sim-attention pytorch
microsoft/chunk-attention pytorch
pytorch/pytorch/blob/main/torch/nn/functional.py jax
softmax1/flash-attention-softmax-n pytorch

Tasks

16k4kDocument ClassificationGPUImage ClassificationLanguage Modelling

Methods 이 논문이 사용한 방법론

What is the best way to complain to Expedia?*BestWaysToComplain What is the best way to complain to Expedia? The best way to complain to Expedia is by calling + 1 ⥭ 888 ⥂829 ⥭ 0881 or + 1 ⥭ 888 ⥂ 829 ⥭ 0881 or using their Help Center.…
Attention 설명 없음
Feedforward Network A Feedforward Network, or a Multilayer Perceptron (MLP), is a neural network with solely densely connected layers. This is the classic neural network architecture of the…
Grouped-query attention 설명 없음
Multi-Query Attention 설명 없음
Rotary Embeddings Rotary Position Embedding, or RoPE, is a type of position embedding which encodes absolute positional information with rotation matrix and naturally incorporates explicit…
Linear Layer A Linear Layer is a projection $\mathbf{XW + b}$.
SPEED The monocular depth estimation (MDE) is the task of estimating depth from a single frame. This information is an essential knowledge in many computer vision tasks such as scene…

Similar Papers 제목 키워드 기반

FastAttention: Extend FlashAttention2 to NPUs and Low-resource GPUs

2024-10-22 · Haoran Lin, Xianzhi Yu, Kang Zhao, Lu Hou 외

FlashAttention series has been widely applied in the inference of large language models (LLMs). However, FlashAttention series only supports the high-level GPU architectures, e.g., Ampere and Hopper. At present, FlashAtt…

CPUGPU

INT-FlashAttention: Enabling Flash Attention for INT8 Quantization

2024-09-25 · Shimao Chen, Zirui Liu, Zhiying Wu, Ce Zheng 외

As the foundation of large language models (LLMs), self-attention module faces the challenge of quadratic time and memory complexity with respect to sequence length. FlashAttention accelerates attention computation and r…

GPUQuantization

FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning

2023-07-17 · Tri Dao

Scaling Transformers to longer sequence lengths has been a major problem in the last several years, promising to improve performance in language modeling and high-resolution image understanding, as well as to unlock new …

GPULanguage ModelingLanguage Modelling

Exact Causal Attention with 10% Fewer Operations

2025-10-05 · Dmitry Rybin, Yushun Zhang, Ding Tian, Zhihang Lin 외 arxiv

We present Exact Causal Attention (ECA), a Strassen-style algorithm that computes exact Causal Attention using 10\% fewer operations. ECA improves a special class of matrix multiplications where either one operand or the…

The I/O Complexity of Attention, or How Optimal is Flash Attention?

2024-02-12 · Barna Saha, Christopher Ye

Self-attention is at the heart of the popular Transformer architecture, yet suffers from quadratic time and memory complexity. The breakthrough FlashAttention algorithm revealed I/O complexity as the true bottleneck in s…

GPU