First Principles of LLMs & RL · Article 09 · Previous article
The previous article ended with a bill still to pay.
A KV cache spares the model from recomputing old positions, but it does not make the history shorter. Every generated token adds one more Key and Value to every layer, and every new Query reads that history position by position. The longer the context, the more there is to store and the more there is to read.
People do not keep track of a conversation that way. After listening to someone for twenty minutes, we do not hold every sentence word for word, ready to scan from the start. We keep a running summary instead: who asked for what, which issue is still open. When a new question comes up, we look in the summary.
A summary has one clear advantage: it does not grow with time. Its weakness is just as clear: what goes into it gets squeezed together, and details can be overwritten.
This article asks: can attention also keep a fixed-size summary, instead of every position’s full K/V? If it can, what does that cost?
1. First, count what pairwise reading costs
Go back to one read inside one head. The new position brings a Query q. The history holds T positions, each with a Key kᵢ and a Value vᵢ.
Standard attention takes three steps:
- match q with every kᵢ to get T scores;
- turn the scores into weights wᵢ with Softmax;
- add the T Values using those weights.
(The $\sqrt{d_k}$ scaling is omitted; it does not affect the argument here.)
Both the work and the storage follow T: T matches, T Values read, T K/V pairs stored. That is not an inefficient implementation; it is the shape of the formula. Each weight depends on q together with one particular kᵢ, so every kᵢ has to be kept.
A fixed-size summary would need something else: a way to process the history before q arrives.
2. Remove Softmax and see what happens
Start with an experiment that is not quite reasonable but is revealing: drop Softmax and use the dot products directly as weights.
\[o=\sum_{i=1}^{T} (q^\top k_i)\, v_i.\]Here is an example small enough to compute by hand. To give the numbers somewhere to stand, wrap them in a small ordering story. The two Key coordinates say what a sentence mentions, [coffee, dessert]; the two Value coordinates say how much was ordered, [cups, pieces].
| Position | What was said | Key kᵢ | Value vᵢ |
|---|---|---|---|
| 1 | coffee only | (1, 0) | (2, 0) |
| 2 | dessert only | (0, 1) | (0, 3) |
| 3 | a coffee-and-dessert set | (1, 1) | (1, 1) |
These labels are only a memory aid. In a real model, Key and Value coordinates are learned, and a single coordinate usually does not correspond to a nameable idea such as “coffee”. None of the arithmetic below depends on the story.
The new Query is q = (1, 2).
Method one: read pair by pair. The dot products of q with the three Keys are 1, 2, and 3. Weighting the Values by these scores gives:
\[o = 1\cdot(2,0) + 2\cdot(0,3) + 3\cdot(1,1) = (5,\ 9).\]Method two: summarize first, then read. Notice that $q^\top k_i$ is just a number, so it can move to the other side of vᵢ:
\[(q^\top k_i)\,v_i = v_i\,(k_i^\top q).\]Therefore
\[o=\sum_{i}v_i\,k_i^\top q=\Big(\underbrace{\sum_{i}v_i\,k_i^\top}_{S}\Big)\,q.\]The S in parentheses does not contain q. Each position contributes one outer product $v_i k_i^\top$, a small 2×2 matrix:
\[v_1k_1^\top=\begin{bmatrix}2&0\\0&0\end{bmatrix},\quad v_2k_2^\top=\begin{bmatrix}0&0\\0&3\end{bmatrix},\quad v_3k_3^\top=\begin{bmatrix}1&1\\1&1\end{bmatrix}.\]One way to picture an outer product: a drawer with a keyhole. The keyhole has the shape kᵢ; the drawer holds vᵢ. When a q comes to open it, $(v_ik_i^\top)\,q=v_i\,(k_i^\top q)$: first check how well q fits the keyhole, then release vᵢ in that proportion.
Add the three drawers:
\[S=\begin{bmatrix}3&1\\1&4\end{bmatrix},\qquad S\,q=\begin{bmatrix}3\cdot1+1\cdot2\\1\cdot1+4\cdot2\end{bmatrix}=(5,\ 9).\]Both methods give the same result. What differs is when q is needed:
- pairwise reading has to wait for q before it can match anything;
- summarizing first can press the history into S in advance; when q arrives, one matrix multiplication is enough.
S has size $d_v\times d_k$, however many positions the history holds. However long the history becomes, S stays 2×2. The moment we add them, the three drawers are flattened and stacked into one small box.
That is the mathematical shape of a summary: writing adds an outer product $v_ik_i^\top$; reading multiplies S by a Query.
In matrix form this is associativity. Stack the Keys and Values as rows of T×d matrices:
\[(qK^\top)\,V = q\,(K^\top V).\]The left side first produces a row of T scores; the right side first produces a $d_k\times d_v$ matrix. The order of multiplication changes; the result does not; the size of the intermediate result changes completely.1
Summarizing first is not always cheaper. For one read, the pairwise method needs roughly $T\cdot d$ multiplications; reading from a summary needs roughly $d^2$. When the history is shorter than the dimension ($T<d$), the pairwise method is actually cheaper. The new order pays off only when T is long.
Figure 1: Route A needs the Query first and keeps one score per stored position. Route B writes each pair into the same 2×2 summary before the Query arrives, then reads once. Both give (5, 9). The lengths shown at the end of the animation are illustrative.
3. Why standard attention cannot be rewritten this way
The catch is that we removed Softmax. Put it back:
\[w_i=\frac{\exp(q^\top k_i)}{\sum_j \exp(q^\top k_j)}.\]The rewrite in Section 2 rests on one fact: the matching score splits into a sum of products of a q-part and a k-part. The dot product $q^\top k_i=\sum_m q_m k_{i,m}$ has exactly that shape, which is why q could be pulled out of the sum.
The exponential welds q and k inside one nonlinear shell. $\exp(q^\top k)$ cannot be written as a finite sum of “a number that depends only on q” times “a number that depends only on k”. To see why intuitively, expand it as a Taylor series:
\[\exp(q^\top k)=1+q^\top k+\frac{(q^\top k)^2}{2!}+\frac{(q^\top k)^3}{3!}+\cdots\]Each term can be split, but there are infinitely many terms, and later terms need ever more “features”. An exact summary computed in advance would need infinitely many summary quantities.2
The denominator has the same problem: $\sum_j\exp(q^\top k_j)$ depends on q too, so it can only be computed once q arrives.
So there is a line that has to be drawn clearly:
Linear attention is not an equivalent rewrite of standard Softmax attention. It replaces the matching function.
What does the replaced part do? Look at the example again, with the same scores 1, 2, 3:
| Position | Score | Normalized in proportion to the score | Softmax weight |
|---|---|---|---|
| 1 | 1 | 0.167 | 0.090 |
| 2 | 2 | 0.333 | 0.245 |
| 3 | 3 | 0.500 | 0.665 |
With only three positions, the difference looks small. Make the history longer and the role of the exponential shows.
Mental arithmetic: one needle, a hundred pieces of straw
Suppose the history has 100 irrelevant positions, all scoring 1, and one position holding the answer, scoring 10.
- Normalized in proportion to the score: the answer receives $10/(100+10)\approx 9.1\%$ of the weight; the other 90.9% is spread over the hundred irrelevant positions.
- Softmax: $e^{10}\approx 22026$, while $100\times e^{1}\approx 272$. The answer receives about 98.8% of the weight.
Both use the same scores. The point is only to see how the exponential magnifies differences between scores. Real linear attention first passes through the φ of the next section, so its scores are not these, and this does not show that it “gets only 9%”.
4. Choose a matching function that does split
Since $\exp(q^\top k)$ cannot be split, replace it with a matching function that can. Transform the Query and the Key separately with a function φ, then take a dot product:
\[\operatorname{sim}(q,k)=\phi(q)^\top\phi(k).\]φ is called a feature map. It may be nonlinear, but it acts on q and on k separately and never mixes the two. That is what makes the split possible.
To keep the result a weighted average, normalize:
\[o=\frac{\sum_i \phi(q)^\top\phi(k_i)\;v_i}{\sum_j \phi(q)^\top\phi(k_j)}.\]The numerator can be summarized in advance as in Section 2, and so can the denominator:
\[S=\sum_i v_i\,\phi(k_i)^\top,\qquad z=\sum_i \phi(k_i),\qquad o=\frac{S\,\phi(q)}{z^\top\phi(q)}.\]This needs one condition: no similarity may be negative. Dot products can be negative, so why not allow them? Take two positions. With scores +1 and −1, the denominator is $1+(-1)=0$ and the read cannot be computed at all. Even when the denominator is not zero, say with scores +2 and −1, the result is $\big(2v_1-v_2\big)/1$: no longer an average of two Values, but one Value minus another. Small changes in the scores near a zero denominator also make the result blow up.
Katharopoulos and colleagues use $\phi(x)=\operatorname{elu}(x)+1$, whose components are all positive, so the condition holds automatically.1
φ and S are easy to confuse, so it is worth separating them:
- φ is a fixed encoding rule. It decides how many dimensions the “address space” for Keys and Queries has, and how each one is placed in it. The 1st token and the 10,000th token are written with the same φ.
- S is an accumulating container. It adds up the history, one write at a time, inside the address space that φ defines. S has as many columns as φ has outputs.
Back to the example. To compute by hand, take the simplest choice, φ(x) = x. That works only here, because every Key and Query component is non-negative and no score is negative; in general this choice is not allowed.
\[z=k_1+k_2+k_3=(2,\ 2),\qquad z^\top q=2+4=6,\] \[o=\frac{(5,\ 9)}{6}\approx(0.833,\ 1.5).\]This is exactly the weighted average of the three Values with proportional weights 1/6, 2/6, and 3/6. For comparison, standard Softmax attention gives about (0.845, 1.399) on the same numbers. Close, but not the same: that is what replacing the matching function means.
5. Write the state one token at a time
In the example above, all three positions were visible to q. Generating text uses causal attention: position t can read only itself and earlier positions.
Summarizing first turns out to be especially natural here. The summary position t needs is the sum of the first t outer products, and it can be obtained from the previous summary by adding one term:
\[S_t=S_{t-1}+v_t\,\phi(k_t)^\top,\qquad z_t=z_{t-1}+\phi(k_t),\] \[o_t=\frac{S_t\,\phi(q_t)}{z_t^\top\phi(q_t)}.\]Give each position a Query: q₁ = (1, 0), q₂ = (1, 1), q₃ = (1, 2). Keep φ(x) = x.
| Step | S after writing | z | Read oₜ | Direct check |
|---|---|---|---|---|
| t=1 | $\begin{bmatrix}2&0\0&0\end{bmatrix}$ | (1, 0) | (2, 0) | only one position, so v₁ |
| t=2 | $\begin{bmatrix}2&0\0&3\end{bmatrix}$ | (1, 1) | (1, 1.5) | q₂ scores 1 against k₁ and k₂: half and half |
| t=3 | $\begin{bmatrix}3&1\1&4\end{bmatrix}$ | (2, 2) | (0.833, 1.5) | same as Section 4 |
Figure 2: The same three tokens in causal order. The cache gains one K/V pair per token; S and z change in place and keep their size. Rows for t = 4 and 5 carry no numbers; they only show the cache continuing.
Compare it with the KV cache from the previous article:
| Standard attention + KV cache | Linear attention state | |
|---|---|---|
| What each head stores | T pairs (kᵢ, vᵢ) | one S and one z |
| Storage as T grows | grows linearly | unchanged |
| Reading for a new token | match T Keys | one matrix–vector product |
| Result | Softmax attention | a different attention, with a new matching function |
This recurrence looks exactly like an RNN: a hidden state, updated once per input, from which the output is read. That is where the title of the paper by Katharopoulos and colleagues comes from: Transformers are RNNs.1
There is one difference from a classic RNN. During training, all tokens are given, so the prefix sums can be computed in parallel instead of step by step. During inference, the model can move forward like an RNN, carrying only a fixed-size state.
6. What the summary can remember, and what it must mix up
Now return to the worry from the beginning: will the summary squeeze out details?
One key, both write address and read address
When writing, vᵢ is placed along the direction $\phi(k_i)$; when reading, $\phi(q)$ retrieves along its own direction. The Key encoding decides both where something is stored and how it can be found later.
Write only the first two positions. The coffee and dessert Keys, (1, 0) and (0, 1), are orthogonal; the two keyholes do not overlap:
\[S_2=\begin{bmatrix}2&0\\0&3\end{bmatrix},\quad z_2=(1,\ 1),\qquad o(k_1)=\frac{S_2\,k_1}{z_2^\top k_1}=\frac{(2,\ 0)}{1}=v_1.\]Reading with k₁ returns exactly v₁; reading with k₂ returns exactly v₂.
First, avoid a trap
Now write the set order. Reading with k₁ gives something else:
\[o(k_1)=\frac{S_3\,k_1}{z_3^\top k_1}=\frac{(3,\ 1)}{2}=(1.5,\ 0.5)\neq v_1.\]It looks as if the set order has leaked into the coffee order. But do not blame the size of the state yet. In the story, k₁ asks about “orders that involve coffee”, and the set order does involve coffee. It ought to match.
Give the same question to Softmax attention, which keeps every K/V pair. To make it as picky as possible, scale the Query by β: the larger β, the more Softmax concentrates on the highest score. But k₁ scores 1 against both k₁ and k₃; they tie for first place. However large β becomes, Softmax can only split the weight between the two orders, and its result settles at the same (1.5, 0.5).
So this shows that “two Keys cannot be told apart by matching”, not that “the state is too small”. Testing capacity needs a different question.
The real test: read with k₃
Now ask about the set order. k₃ = (1, 1) scores 2 against itself and 1 against each of the other two orders; it is the only first place. Again scale the Query by β:
| β | Softmax (keeps every K/V pair) | Linear (keeps only S and z) |
|---|---|---|
| 1 | (1, 1.212) | (1, 1.25) |
| 3 | (1, 1.045) | (1, 1.25) |
| 10 | (1, 1) = v₃ | (1, 1.25) |
As β grows, Softmax concentrates more and more weight on the third order and finally recovers v₃ exactly. The linear read stays at (1, 1.25) throughout, however large β becomes.
Move the Key angles, choose which Key to query, and raise β. The lab uses unit-length Keys on a quarter circle, so its numbers differ from the hand calculation above. Open the interactive lab · Marimo source.
Two different things are mixed together here, and they should be separated.
First: why does β have no effect at all? That comes from choosing φ(x) = x. Reading with βq multiplies the numerator $S(\beta q)$ and the denominator $z^\top(\beta q)$ by the same β, and they cancel. With a φ that does not have this property, β can change the result. “β has no effect” is a feature of this example, not a general law of linear attention.
Second: could a different φ, or a different writing rule, recover v₃? Not in this example, and this has nothing to do with β. The reason is that k₃ = k₁ + k₂. As long as φ is linear, whatever numbers S and z hold, the read for k₃ must lie on the segment between o(k₁) and o(k₂). If k₁ and k₂ read back (2, 0) and (0, 3) exactly, then k₃ can only read some point on that segment, and v₃ = (1, 1) is not on it. (The proof is in the mathematical notes.)
In other words: no 2×2 state, whatever rule wrote it, can let all three Keys read back their own Values exactly. That is the hard capacity limit.
In general, the limit comes from φ’s output dimension $d_\phi$. A $d_\phi$-dimensional space has at most $d_\phi$ linearly independent directions. After more than $d_\phi$ positions have been written, some $\phi(k_i)$ must be linear combinations of the others, and what they read is tied to what the others read. Enlarging the capacity means giving φ more dimensions, and S grows with it. Capacity and state size are bound together. This also links back to Section 3: the exponential in Softmax behaves like an infinite-dimensional φ, which no finite state can hold exactly.
For a sense of scale: one head often has only 64 or 128 dimensions, while the context can hold tens of thousands of tokens. That does not mean a model gets “crushed”; real models have many heads and layers, and φ can also add dimensions. But “every position can retrieve its own Value exactly with its own Key” stops being possible once more than $d_\phi$ positions have been written.
Softmax attention has no such limit because it does not compress at all: every kᵢ is still there. The price is the ever-longer KV cache from the previous article.
This limit is not a new discovery. Analyzing linear Transformers as “fast weight” programmers, Schlag and colleagues derived a memory capacity limitation of this kind of state.3 Later work also reports that linear-attention-style models still often underperform standard Transformers on tasks that require retrieving information from context.4 The linear-algebra argument here explains why a capacity limit exists. It does not, by itself, tell us when that limit starts to dominate in real language modeling.
An easy confusion: linear attention versus FlashAttention
Both are often described as “not explicitly storing the full attention matrix”, but they do completely different things.
- FlashAttention still computes standard Softmax attention, with the same mathematical result as a standard implementation. What it changes is how the computation is organized on a GPU: reading in tiles and updating Softmax’s normalizer on the fly, so that the T×T score matrix is never written to GPU memory. A new Query still reads the entire K/V history.5
- Linear attention replaces the matching function, so it changes the model itself. It can compress the history into a fixed-size state precisely because it is no longer Softmax attention.
One solves the same problem with another algorithm. The other changes the problem.
7. What “linear” refers to
Finally, the name.
The “linear” in linear attention means that for fixed dimensions, the computation grows linearly with the sequence length T: each position performs one write and one read of fixed size, T times in total. Standard attention makes each position read every earlier position, so its total grows with T squared.
It does not mean the whole computation is linear in its inputs. φ can be nonlinear, normalization is a division, and the rest of the network still has its FFNs and nonlinear activations.
This line of thought continues further. The writing rule in Section 5 adds blindly: $S_t=S_{t-1}+v_t\,\phi(k_t)^\top$, and old content is never erased. The delta rule writes differently: before writing, use kₜ to read what is already stored at that address, then write only the difference between the desired vₜ and what is already there, a kind of erase-then-write. Gating multiplies the old state by a forgetting factor, so outdated content fades. Both can ease the overwriting conflicts seen in Section 6, but neither removes the capacity limit of a $d_\phi$-dimensional state.3 4 Each deserves its own discussion; here we stop at the most basic version.
Back to the summary
This article started from a simple question: can attention, like a person, carry only a summary forward?
The answer: yes, but only by replacing Softmax. The dot product splits into a q-part and a k-part, so associativity lets us summarize first and read later. Softmax’s exponential does not split, so linear attention replaces it with a matching function that does. What it gains is a fixed-size state; what it pays is capacity: however many dimensions the state has, that is how many positions can stay free of interference.
We have now followed a language model all the way from text to vectors, from vectors to a distribution, and from the distribution to the next token, and we have seen two ways of remembering the past.
One question has been set aside all along. When choosing tokens in the previous article, we used greedy decoding: always take the most probable token. If we sample from the probabilities instead, the same question gets a different answer each time. So how do we judge whether a whole answer is good, and how should that judgement flow back to each choice along the way? From here, we turn toward reinforcement learning.
Mathematical notes
Conventions
Column vectors throughout. $q, k_i\in\mathbb{R}^{d_k}$, $v_i\in\mathbb{R}^{d_v}$, $\phi:\mathbb{R}^{d_k}\to\mathbb{R}^{d_\phi}$, state $S\in\mathbb{R}^{d_v\times d_{\phi}}$, $z\in\mathbb{R}^{d_\phi}$. In this article’s example, φ(x) = x and $d_\phi=d_k=2$. If K and V are stacked as rows, as in the papers, the state corresponds to $\phi(K)^\top V\in\mathbb{R}^{d_\phi\times d_v}$, the transpose of S here.
The full rewrite
\[o=\frac{\sum_i \big(\phi(q)^\top\phi(k_i)\big)v_i}{\sum_j \phi(q)^\top\phi(k_j)} =\frac{\sum_i v_i\,\phi(k_i)^\top\phi(q)}{\big(\sum_j\phi(k_j)\big)^\top\phi(q)} =\frac{S\,\phi(q)}{z^\top\phi(q)}.\]The first step uses only the fact that a scalar can change places with a vector; the second is distributivity of matrix multiplication over addition. Conditions: $\phi(q)^\top\phi(k_i)\ge0$ for every i, and $z^\top\phi(q)>0$.
Work
Per head and per position: one outer-product write, $O(d_v d_\phi)$, and one matrix–vector read, $O(d_v d_\phi)$. A sequence of length T costs $O(T\,d_v d_\phi)$ in total, with state storage $O(d_v d_\phi)$ independent of T. Standard causal attention costs $O(T^2 d)$ in total, with KV-cache storage $O(T d)$. When $d_\phi$ is large (for example, high-dimensional random features used to approximate Softmax), the constant factor can eat into the gain.
Why β has no effect in this example
If φ is homogeneous of degree one, $\phi(\beta q)=\beta\,\phi(q)$ (as φ(x) = x is), then for β > 0:
\[o(\beta q)=\frac{S\,\beta\phi(q)}{z^\top\beta\phi(q)}=o(q).\]$\operatorname{elu}(x)+1$ is not homogeneous, so scaling the Query changes the read. This note explains only why the linear column of the table in Section 6 does not change with β. It is separate from the capacity limit below.
The capacity limit: three reads must be collinear
Let φ be linear and $k_3=k_1+k_2$. Let S and z be any 2×2 state and any two-dimensional vector (they need not come from the writing rule of Section 5). Write $\alpha_i=z^\top k_i$, assume $\alpha_1,\alpha_2>0$, and $o(k_i)=S k_i/\alpha_i$. Then
\[o(k_3)=\frac{S k_1+S k_2}{\alpha_1+\alpha_2} =\frac{\alpha_1}{\alpha_1+\alpha_2}\,o(k_1)+\frac{\alpha_2}{\alpha_1+\alpha_2}\,o(k_2).\]Both coefficients are positive and sum to 1, so $o(k_3)$ is a convex combination of $o(k_1)$ and $o(k_2)$ and lies on the segment between them. If we require $o(k_1)=v_1=(2,0)$ and $o(k_2)=v_2=(0,3)$, that segment lies on the line $3x+2y=6$, while $v_3=(1,1)$ gives $3+2=5\ne6$. So no 2×2 state lets all three Keys read back their own Values exactly.
More generally, if $\phi(k_3)=c_1\phi(k_1)+c_2\phi(k_2)$ and $z^\top\phi(k_3)\ne0$, the same calculation gives $o(k_3)=\lambda\,o(k_1)+(1-\lambda)\,o(k_2)$ with $\lambda=c_1\alpha_1/(c_1\alpha_1+c_2\alpha_2)$: the three reads are collinear (the coefficients need not both be positive, so the point need not lie between the other two). Whenever the three target Values are not collinear, they cannot all be stored and retrieved exactly. In a $d_\phi$-dimensional feature space, any $d_\phi+1$ vectors $\phi(k_i)$ are linearly dependent, so once more than $d_\phi$ positions are written, constraints of this kind are unavoidable.
The unnormalized read $r(q)=S\phi(q)$ is constrained even more directly: $r(k_3)=c_1r(k_1)+c_2r(k_2)$. In the example, if $r(k_1)=v_1$ and $r(k_2)=v_2$, then $r(k_3)$ is forced to equal $v_1+v_2=(2,3)$.
-
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret, Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention, ICML 2020, PMLR 119:5156–5165. The paper writes self-attention as a dot product of kernel feature maps, uses the associativity of matrix products to reduce the complexity from quadratic to linear in sequence length, and points out the relation of the resulting iterative form to RNNs; $\operatorname{elu}(x)+1$ is the feature map it adopts. ↩ ↩2 ↩3
-
Precisely: no finite-dimensional φ satisfies $\exp(q^\top k)=\phi(q)^\top\phi(k)$ for all q and k. The one-dimensional case is enough. For distinct real numbers $x_1,\dots,x_N$, the matrix $G=[\exp(x_ix_j)]$ equals $\sum_{n\ge0}a_na_n^\top/n!$ with $a_n=(x_1^n,\dots,x_N^n)$. The first N vectors $a_n$ form an invertible Vandermonde matrix, so for any nonzero c at least one $c^\top a_n$ is nonzero and $c^\top Gc>0$; G has full rank. A finite-dimensional φ produces such matrices with rank at most its dimension, and N can be arbitrarily large. Methods such as Performer approximate this kernel with random features: an approximation, not an exact rewrite. ↩
-
Imanol Schlag, Kazuki Irie, and Jürgen Schmidhuber, Linear Transformers Are Secretly Fast Weight Programmers, ICML 2021, PMLR 139:9355–9366. The paper shows the formal equivalence of linearized self-attention and fast weight programmers (apart from normalization), derives a memory capacity limitation of linear Transformers from that view, and replaces the purely additive outer-product write with a delta-rule-like update. ↩ ↩2
-
Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, and Yoon Kim, Parallelizing Linear Transformers with the Delta Rule over Sequence Length, NeurIPS 2024. The paper notes that linear Transformers and state-space models still often underperform Transformers on tasks requiring in-context retrieval, and gives an algorithm for training delta-rule linear Transformers (DeltaNet) in parallel over sequence length; it also discusses linear-attention variants with data-dependent gating. ↩ ↩2
-
Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré, FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness, NeurIPS 2022. An IO-aware algorithm for exact attention that uses tiling to reduce reads and writes between GPU high-bandwidth memory and on-chip SRAM. ↩