atlas

Research map / Learning theory and algorithms / Sample complexity

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

ICML 2024 · Learning theory and algorithms › Sample complexity · approach: Generalization and limits under data constraints · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proves matching I/O complexity lower bounds for exact attention (including with fast matrix multiplication, via a new communication-complexity matrix compression argument), showing FlashAttention is optimal for cache size M ≥ d^2.

Problem

Whether FlashAttention's I/O complexity O(N^2 d^2 / M) is optimal for attention on a two-level memory hierarchy, for all cache sizes M, including when fast matrix multiplication is used.

Approach

Uses red-blue pebble game partition arguments for standard matrix multiplication, and for arbitrary (including fast matrix multiplication) algorithms reduces I/O to a one-way communication complexity matrix-entry compression problem, using Vandermonde matrices (large field) and binary BCH codes (binary inputs) to get linear-independence constraints; also gives an algorithm with O(N^2 d / sqrt(M))

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Establish a matching lower bound for attention in the large-cache regime, including when fast matrix multiplication is allowedFlashAttention · Attention, large cache (M ≥ d²), q > NI/O complexity: \bigO{\frac{N^2 d^2}{M}}; \bigOmega{\min\left(\frac{N^2 d^2}{M}, N^2 \right)}No clear effect
Use square tiling instead of FlashAttentionAttention, small cache (M < d²) · Attention, small cacheI/O complexity: \bigO{\frac{N^2 d}{\sqrt{M}}} vs. \bigO{\frac{N^2 d^2}{M}}Helped
Restrict Q and K to binary matricesAttention with any matrix multiplication algorithm · Attention, binary inputsI/O complexity lower bound: \bigOmega{\min\left(\frac{N^2 d^2}{M \log^2 N}, N^2 \right)}Mixed

Surprising findings

Limitations

Experimental setup

Metrics: I/O complexity (asymptotic)

Baselines: FlashAttention

Builds on: FlashAttention red-blue pebble game Hong and Kung I/O model

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy