the.ai

Attention / Efficiency

verified

FlashAttention

Standard attention writes the whole score matrix to memory, then reads it back to apply the softmax, then reads it again for the weighted sum. FlashAttention never writes it at all: it works through the sequence in tiles small enough to stay in fast on-chip memory, accumulating the result as it goes. Identical answer, a fraction of the memory traffic.

Viz primitive · budget-splittile = 128

tile holds 50% of the budget; rest holds the remaining 50%.

Memory traffic saved by tiling against what a materialised score matrix would move. Drag the tile size to trade on-chip residency against the number of passes.

128

Reviewed by opendroid · 2026-08-04

  • arXiv:2205.14135 — FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • arXiv:2307.08691 — FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning