BLOGLLM Logo
Go Pro
Guest
Not signed in
All BlogsCoursesPracticeInterview prepSeriesTagsBookmarksPricing
Log in
All BlogsCoursesPracticeTagsBookmarksPricing
BlogsCourses
Practice
My PrepProblemsStudy PlansResearch PapersRoadmapInterviewContestsLeaderboardGames
Articles
Practice / Research papers
Transformers and LLMs · 2022

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

Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, Christopher Ré

NeurIPS 2022 · arXiv 2205.14135 · Read the paper ↗

Exact attention computed tile by tile, so the full score matrix never touches slow memory.

5 steps · 0 solved

Start: Stable softmax →
  1. 1Stable softmaxSubtract the max before exponentiating.LLM sampling: turn logits into probabilities without overflowingEasy
  2. 2Online softmaxUpdate the max and sum one block at a time.Online softmax, the trick inside FlashAttentionHardPro
  3. 3Why tiling helpsCount memory traffic for naive and tiled matmul.Count global memory loads for naive vs tiled matmulMediumPro
  4. 4Tiled attention forwardPut it together for causal attention.FlashAttention-style tiled causal attention forward (Dao et al., 2022)HardPro
  5. 5Tiled backwarddK and dV block by block from the saved log-sum-exp.Compute dK and dV tile by tile from the saved log-sum-expHardPro

More transformers and llms papers

  • Attention Is All You Need 2017
  • LoRA: Low-Rank Adaptation of Large Language Models 2021
  • RoFormer: Enhanced Transformer with Rotary Position Embedding 2021
  • Direct Preference Optimization: Your Language Model is Secretly a Reward Model 2023
  • Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity 2021
  • Fast Inference from Transformers via Speculative Decoding 2022
  • LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale 2022
Goal
Tiled attention with online softmax
0 / 5 solved
Start: Stable softmax →
How it works

Solve the steps in order. Each one is a small function with tests that run in your browser. Later steps reuse ideas from earlier ones.

© BlogLLM, Bengaluru, IndiaAboutTermsPrivacyRefundsDMCAContactRSS