Papers · Architectures and attention · 2022
FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
The notation of the FlashAttention paper, explained: its 34 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.
Read from arXiv's HTML version: 34 displayed equations and 246 pieces of inline math. 43 symbols and constructs from the catalog, read as attention and transformers.
The paper's displayed equations
Open any of them in the decoder for a symbol-by-symbol reading.
Famous equations in this paper
Symbols, by category
Most used first. The examples are written as the paper writes them.
Notation conventions
- , ,
Italic letters (variables) 909 uses
A plain italic letter is a variable; conventions say what kind (x input, y target, W weights…).
- , ,
Subscript (index or label) 666 uses
A subscript picks an element (xᵢ), a time step (h_t), a named copy (W_q), or the parameters (p_θ).
- , ,
Superscript (power or label) 100 uses
Usually a power (x² = x·x), but a capital or a word up there is often just a label (W^Q).
Loss (ℒ) 76 uses
The loss: the number training tries to make small. Also written L, J(θ) or ℓ.
- , ,
Superscript in parentheses 61 uses
An index in a superscript: x⁽ⁱ⁾ is the i-th training example, W⁽ˡ⁾ the weights of layer l. Not a power.
- , ,
Tilde accent 58 uses
A modified version of the variable: noisy, corrupted, proposed or intermediate.
- ,
Dots (ellipsis) 31 uses
“And so on”: continue the pattern.
Greek letters
Theta 36 uses
The model’s parameters: all of its weights and biases, as one collection.
Tau 10 uses
A temperature that sharpens or flattens a softmax; in RL, a trajectory.
Phi 5 uses
The parameters of a second model (often the encoder q_φ), or a feature map φ(x).
Omega 4 uses
A frequency ω (positional encodings, Fourier features) or a weight; capital Ω is a regularizer, a sample space or big-Omega.
Vectors and matrices
- , ,
Bold uppercase (matrix) 422 uses
A bold capital letter is a matrix (or a higher-order tensor).
- , ,
Q, K, V (query, key, value) 288 uses
In attention: queries Q, keys K and values V, each a matrix with one row per token.
Times (cross) 159 uses
Usually the “by” in a shape (n × d); also plain multiplication or a cross product.
- , ,
Transpose 47 uses
Swap rows and columns. xᵀy is a dot product; xyᵀ is an outer product.
- , ,
Inverse 20 uses
The matrix inverse, A⁻¹A = I; for a function, its inverse function; for a number, 1/x.
Diag 19 uses
Build a diagonal matrix from a vector, or pull out the diagonal of a matrix.
Hadamard (elementwise) product 2 uses
Multiply two arrays of the same shape entry by entry.
Calculus and gradients
Infinity 5 uses
Infinity; as a norm subscript, ‖x‖_∞ is the largest absolute entry.
- , ,
Partial derivative 4 uses
A partial derivative: how one quantity changes when one input changes and the others are held fixed.
Probability and statistics
- , ,
Probability p(x) 74 uses
A probability or probability density; p is usually the true or model distribution, q an approximation.
- , ,
Exponential 52 uses
The exponential function eˣ, with e ≈ 2.718. Always positive.
Indicator function 2 uses
1 when the condition inside is true, 0 when it is false.
Logarithm 2 uses
A logarithm, almost always the natural log (base e) in ML papers.
Functions and operators
Arrow (maps to) 77 uses
Maps to (f: X → Y), tends to (x → 0), or implies (⇒).
- , ,
Fraction 48 uses
Division: the top divided by the bottom.
Big-O notation 27 uses
How a cost grows with size, ignoring constants: O(n²) means at most proportional to n² for large n.
- , ,
Floor and ceiling 20 uses
Round down (floor ⌊x⌋) or round up (ceiling ⌈x⌉) to a whole number.
Softmax 18 uses
Turns a vector of scores into probabilities: exponentiate each, then divide by the total.
- , ,
Summation 15 uses
Add up the expression for every value of the index, from the bottom limit to the top.
Assignment arrow 14 uses
Assignment in an algorithm: replace the variable on the left with the value on the right.
- , ,
Max and min 13 uses
The largest (or smallest) value, over the arguments or over the range in the subscript.
Composition (circle) 7 uses
Function composition: (f ∘ g)(x) = f(g(x)). Some papers use it for elementwise products.
- ,
Square root 2 uses
The square root. In attention, dividing by √d_k keeps dot products at a sensible scale.
Plus or minus 2 uses
Both signs at once: a ± b means a + b and a − b. In results tables, a mean and its spread.
Sets, shapes and definitions
Element of 110 uses
“Is in” or “belongs to”: x ∈ S says x is a member of the set S.
- , ,
Tensor shapes 101 uses
ℝ with a superscript of sizes joined by × declares an array’s shape: ℝ^{B×T×d} is a 3-axis tensor.
- , ,
Inequalities 29 uses
Less than / greater than (or equal). ≪ means “much smaller than”.
- ,
Set braces 5 uses
A set: a collection of items. {x | condition} is every x that satisfies the condition.
Defined as (:=) 4 uses
“Is defined as”: introduces a new name for the expression on the other side.
Real numbers (ℝ) and shapes 4 uses
The real numbers. ℝⁿˣᵈ is the set of n × d arrays of reals: it states a shape.
If and only if 2 uses
“If and only if”: each side implies the other, so they are true together or false together.
Not equal 1 use
The two sides are different.
5 things the catalog has no entry for yet
-
rowsum7 -
\cal7 -
dropout5 -
rowmax5 -
\}1
Formulas from arXiv's HTML version of the paper, © their authors; the explanations are this site's. Title and authors as arXiv lists them.
More architectures and attention papers
- Attention Is All You Need (Transformer, 2017)
- RoFormer: Enhanced Transformer with Rotary Position Embedding (RoPE, 2021)
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces (Mamba, 2023)
- Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer (Mixture of experts, 2017)
- Neural Machine Translation by Jointly Learning to Align and Translate (Bahdanau attention, 2014)
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (ViT, 2020)