The Kernel Zoo: Performers, Fast Weight Programmers, and the Capacity-Approximation Tradeoff in Linear Attention
How to choose the feature map φ in linear attention — the capacity bound that says a state of dimension d_φ stores at most d_φ orthogonal key-value pairs, the Performer's FAVOR+ that approximates softmax with positive orthogonal random features, the DPFP map that grows capacity deterministically through ReLU-gated quadrant projections, and the capacity-versus-approximation tradeoff that defines the design space, with the linear-attention recurrence reframed as a 1990s fast weight programmer.
Linear attention replaces the softmax similarity with an inner product for some feature map . Once that swap is made, the matrix-product associativity collapses the attention matrix into a constant-size state , and the layer becomes an RNN that runs in linear time. The framework is fully general — every linear-attention method is just a different choice of .
So the design question is not whether to linearize but which to pick. And the choice of controls two things at once. It sets the capacity of the memory: a state of dimension can store at most orthogonal key-value pairs before retrieval starts to interfere. And it sets the approximation fidelity: how closely tracks the actual softmax similarity that the original Transformer was trained to use. Make low-dimensional and the layer is cheap but the memory saturates fast. Make it high-dimensional and the memory is roomier but the constants on the cost grow. Make it carefully designed (random features, orthogonal projections, positive maps) and the same dimension can target either capacity or fidelity — but not both equally well.
We derive insights from two papers that approach the feature map question from opposite directions:
-
Schlag, Irie, and Schmidhuber (2021), “Linear Transformers Are Secretly Fast Weight Programmers” (ICML 2021): reframes linear attention as a fast weight programmer from the 1990s, derives the capacity limitation that the state can store at most orthogonal associations (where is the output dimension of ), and proposes DPFP — a deterministic kernel that increases without random sampling.
-
Choromanski et al. (2021), “Rethinking Attention with Performers” (ICLR 2021): asks a different question — instead of designing a new kernel, can we approximate the actual softmax kernel with a finite-dimensional feature map? They propose FAVOR+ (Fast Attention Via positive Orthogonal Random features), which uses random projections with provable approximation guarantees.
The first paper says: design to maximize memory capacity. The second says: design to approximate softmax. Both are valid goals, and the tension between them defines the design space for linear attention kernels.
The Running Example
We continue with the same tiny example from the Why Replace Attention, RetNet, and Gated DeltaNet blogs:
- tokens, , single head
From the Why Replace Attention blog, the ELU+1 feature maps are:
For the capacity analysis, we use the model parameters from the series:
- , heads, , layers, fp16
For the random feature demonstrations (FAVOR+), we will need a specific random matrix, which we fix at the start of that section.
1. Linear Attention Is a Fast Weight Programmer
1.1 Fast weight programmers: the 1990s idea
Schlag et al. (2021) make a historical observation: the linear attention recurrence derived in the Why Replace Attention blog is not new. It is a special case of fast weight programmers (FWPs), a concept introduced by Schmidhuber in 1991.
The idea of fast weights is to make the weights of a neural network change at test time — unlike standard “slow weights” which are fixed after training. A fast weight programmer (FWP) is a two-network system: a “slow” network (trained by gradient descent) generates instructions that program the fast weights of a second network. The fast weights change with every input token, while the slow weights remain fixed during inference.
The concept was called synaptic modulation by von der Malsburg (1981). Von der Malsburg defined the effective weights as a superposition of conventional, context-independent slow weights and fast-changing, context-dependent fast weights. Hinton and Plaut (1987) studied the additive superposition of two sets of weights with different learning rates. But before 1991, no network learned by gradient descent to compute the changes of the fast weight storage of another network or of itself.
1.2 The FWP recurrence
A fast weight programmer processes a sequence , , and produces an output sequence , as follows. At each step , it:
- Computes key, value, and query projections:
- Updates the fast weight matrix:
- Reads from the fast weight matrix:
where denotes the outer product and .
The outer product is a matrix — the same shape as the state matrix from the Why Replace Attention blog. The “programming instruction” at each step is: store the association between key and value by adding their outer product to the fast weight matrix.
1.3 The equivalence
This is the part that confuses almost everyone when first encountering the FWP perspective, because the notation differs between the two communities.
Let us line up the two recurrences. From the Why Replace Attention blog, linear attention without normalization has:
wait — there is an inconsistency in the transpose convention. Let us be precise. The Why Replace Attention blog defines and computes .
The FWP defines . Now means the matrix where element . This gives . And retrieval is .
Expanding:
This is exactly the linear attention numerator from the Why Replace Attention blog (without the kernel ): . Setting (no feature map), the FWP and unnormalized linear attention are identical.
With a feature map , linear attention replaces with and with :
These are the same computation with different notational conventions: , (with applied before storage), and the output is a matrix-vector product either way.
The difference is normalization. The FWP as stated in Schmidhuber (1991) has no normalization — the output is directly. Linear attention (Katharopoulos et al., 2020) divides by , where . Schlag et al. (2021) call this the difference between the FWP and the “linearised Transformer” — they are the same up to this normalisation.
1.4 Numerical verification
Let us trace the FWP for our running example (no feature map, no normalisation, causal masking).
Step : , , .
Step : , , .
Numerical check: with causal masking, .
Step : , , .
Step : , , .
Now let us verify with the feature map and normalisation from the Why Replace Attention blog. The causal output at step 4 was computed there as . The FWP output at step 4 is . These differ because: (a) the FWP uses no feature map (), and (b) the FWP has no normalisation. The FWP perspective is a generalisation — linear attention is the special case with a specific and normalisation.
1.5 Interpretation
The formal equivalence is: linear Transformers are outer product-based Fast Weight Programmers from the 1990s, with the addition of normalisation. The memories of such FWPs contain key-value associations (stored as outer products), and an FWP learns to reprogram these through sequences of differentiable elementary instructions — which are the additive outer product updates invented by the FWP.
This is not merely a historical curiosity. The FWP perspective gives us two concrete analytical tools that the kernel perspective alone does not:
-
Capacity analysis: the theory of associative memory and tensor product representations (Smolensky, 1990) tells us exactly when the memory will fail — when we try to store more associations than the dimension allows.
-
Update rule design: viewing the state as a programmable memory suggests that the purely additive instruction may not be the best programming instruction. This insight motivated the delta rule of the Gated DeltaNet blog.
We now derive the first of these tools.
2. The Capacity Limit
2.1 The memory as a sum of outer products
From the FWP perspective, the state matrix after processing tokens is:
where is the output dimension of (the codomain dimension). For , . For other feature maps, may differ.
This matrix stores associations. Querying with retrieves:
If we want to retrieve exactly, we need for all , and . In other words, the mapped keys must be orthonormal in .
2.2 The orthogonality constraint
In , there can be at most mutually orthogonal vectors. This is a fundamental fact from linear algebra — any set of more than vectors in must be linearly dependent, and linearly dependent vectors cannot all be mutually orthogonal.
Therefore:
When — that is, when the sequence length exceeds the state dimension — the model enters an overcapacity regime. The mapped keys cannot all be orthogonal, so retrieval produces interference: the retrieved value for key is contaminated by the values stored with other keys.
2.3 Numerical example: orthogonal keys
In our running example, and preserves the dimension (). So the capacity is . We have tokens — twice the capacity. Let us see the interference.
After step 2, the state (using features, no normalisation, causal) is:
Query with :
We wanted but got . Even with just 2 stored associations, the retrieval is inaccurate because and are not orthogonal: .
The crosstalk (Smolensky, 1990) is the interference from the non-orthogonal key. The retrieved value decomposes as:
The first term is the desired signal (scaled by 5). The second term is crosstalk (scaled by 4). The signal-to-crosstalk ratio is — barely above 1. With normalisation, the output would be , a blend of and .
2.4 When keys ARE orthogonal
Now consider what happens if we had keys with orthogonal feature maps. Suppose (hypothetically) and . Then:
Query with :
Perfect retrieval, zero crosstalk. But this required orthogonal keys — and we can have at most of them.
2.5 The capacity formula
Schlag et al. (2021) formalise this using tensor product representations (Smolensky, 1990). A tensor product representation stores a structured symbolic expression as a sum of outer products of “role” and “filler” vectors — which translate directly to keys and values in our context.
The capacity result is:
For the feature maps discussed so far:
| Feature map | Capacity | |
|---|---|---|
| No feature map () |
With (our model parameters), the capacity is 64. Any sequence longer than 64 tokens exceeds the capacity, and retrieval errors accumulate.
2.6 Numerical check at model scale
With and heads, each head has capacity 64. The total capacity across all heads is not simply , because the heads operate independently — each head stores its own associations, and they cannot share capacity. But if different heads focus on different associations (which multi-head attention encourages), the effective capacity of the full model at one layer is loosely bounded by .
For a sequence of tokens, the overcapacity ratio is:
The model must compress 2,000 tokens worth of information into 1 token’s worth of state — per head. This is an extreme compression ratio, and it explains the quality gap between linear and softmax attention on long sequences.
2.7 Interpretation
The capacity limit reveals a fundamental tradeoff: to store more associations without interference, we need a larger . But increasing increases the state size () and the per-step compute (). The feature map controls , so choosing is really choosing a point on the capacity-efficiency curve.
This observation motivates two different strategies:
- Increase with a deterministic projection — the DPFP approach from Schlag et al. (2021), which we derive in Section 5.
- Approximate the softmax kernel as closely as possible — the FAVOR+ approach from Choromanski et al. (2021), which we derive in Sections 3 and 4.
We start with the approximation approach, because it answers a natural question: can we have the best of both worlds — linear complexity with the exact attention distribution that made transformers dominant?
3. Approximating Softmax with Random Features
3.1 The goal
The Why Replace Attention blog showed that is a valid kernel with an infinite-dimensional feature map. We cannot compute this feature map exactly. But what if we could approximate it with a finite-dimensional feature map such that:
If the approximation is good enough, we get linear complexity (from the associativity trick) with nearly the same attention distribution as softmax.
This is the central idea of Choromanski et al. (2021). They call it FAVOR+: Fast Attention Via positive Orthogonal Random features.
3.2 Random feature maps: the general framework
The connection between kernels and random features comes from Rahimi and Recht (2007). A random feature map is a function of the form:
where are random vectors drawn independently from some distribution over , are deterministic functions, and is a deterministic scaling function. The output has dimension .
This is Equation 5 of Choromanski et al. (2021). The idea is that if , , and are chosen correctly, then:
where K is the target kernel. This is a consequence of Bochner’s theorem for shift-invariant kernels (or its generalisation for other kernel families): any positive-definite kernel can be written as an expectation of products of random features.
3.3 The softmax kernel
The softmax kernel (omitting the scaling for clarity — it can be absorbed into the keys) is:
We want to find such that .
Choromanski et al. (2021) start with the observation that can be decomposed. Using the exponential identity :
Let us verify this identity. Expanding :
Multiplying by :
The and cancel. The and cancel. What remains is .
Now is the Gaussian kernel , which is a standard shift-invariant kernel. The classical random feature construction for the Gaussian kernel uses random Fourier features (Rahimi and Recht, 2007) with trigonometric functions.
3.4 The trigonometric approach (and why it fails)
The classical approach uses , , , , and . This gives:
The factor absorbs the Gaussian-to-softmax conversion from Section 3.3.
The problem is that and output values in . This means can be negative. In the attention context, a negative similarity score means a negative attention weight, which breaks the interpretation of attention as a weighted average. More practically, negative weights cause the normaliser to become very small or even negative, leading to catastrophic numerical instability.
Choromanski et al. (2021) demonstrate this empirically: trigonometric random features lead to NaN values during training, and when they do converge, the model underperforms significantly compared to positive features. The issue is worst for critical regions where the kernel value is small (i.e., when and are far apart) — these are exactly the entries where the attention weights should be near zero, but the trigonometric estimator has high variance and can produce large positive or negative values.
3.5 Numerical illustration of the variance problem
Let us illustrate with our running example. Take and . The true softmax similarity (without scaling) is:
With one random vector (drawn from ), the trigonometric estimator gives:
The true value is 1. The single-sample estimate is 5.516 — off by a factor of 5.5. Worse, with a different , the estimate could be negative. The high variance comes from the scaling factor, which amplifies the oscillations of the trigonometric functions.
4. FAVOR+: Positive Orthogonal Random Features
4.1 The key insight: positive random features
Choromanski et al. (2021) observe that the softmax kernel admits a decomposition using positive random features — no trigonometric functions needed. This is Lemma 1 of their paper, and it is the theoretical foundation of FAVOR+.
Lemma 1 (Positive Random Features for Softmax). For , , and :
Let us prove this. Define:
Then the expected value becomes:
where . We used the exponential product rule: .
Now we need the moment generating function of a Gaussian. If , then (since is a linear combination of independent standard normals with coefficients , giving variance ). For a random variable :
This is the moment generating function of the normal distribution evaluated at . Applying it with :
Expanding :
Multiplying by :
The terms cancel. The terms cancel. What remains:
4.2 The positive feature map
Lemma 1 tells us that the softmax kernel decomposes as where:
This function is always positive: the exponential function maps . No trigonometric oscillations, no negative values, no sign cancellations.
With random samples , the feature map is:
The output dimension is , and every component is positive.
The approximation is:
By the law of large numbers, as , this converges to .
4.3 Numerical example
Let us compute for our running example with random projections. We fix:
These are concrete realisations from , chosen for easy arithmetic.
For : , so .
Every component is positive.
For : , so .
For : , so . Same projections as :
(Since , their feature maps are identical.)
Approximation check for :
True value: .
The estimate is — off by a factor of 2. With only random projections, this level of error is expected. As increases, the estimate converges to the true value.
Approximation check for :
True value: .
The estimate is vs the true . With , the approximation is rough. The Performers paper recommends — for , this gives .
4.4 Why positive features have lower variance
This is the part that matters most, and it is easy to gloss over. The key claim of Choromanski et al. (2021) is that positive features are not just “nicer” (no negative weights) but provably lower variance than trigonometric features in the critical regime.
Lemma 2 (Choromanski et al., 2021). For independent random samples :
where MSE stands for the mean squared error.
The critical comparison: when (meaning , so the tokens are very dissimilar), the trigonometric MSE contains , which blows up to infinity. The positive MSE contains , which shrinks to zero.
In plain language: for tokens that should have near-zero attention weight, the trigonometric estimator has high variance (it wildly over- or under-estimates), while the positive estimator has low variance (it estimates near-zero accurately). Since most token pairs in a long sequence are dissimilar (attention is typically sparse), the positive estimator is dramatically better in practice.
4.5 Interpretation
The positive random feature map is an unbiased estimator of the softmax kernel: . The trigonometric estimator is also unbiased. But unbiased estimators can still have very different variances — and in the attention context, high variance is catastrophic because it cascades through the model’s layers, amplified by the Lipschitz constant of the subsequent MLP and normalisation layers.
5. Orthogonal Random Features
5.1 The variance reduction idea
The positive random feature map from Section 4 uses independent random vectors . Choromanski et al. (2021) propose a further improvement: instead of sampling the independently, make them exactly orthogonal.
An orthogonal random feature (ORF) construction (Yu et al., 2016) works as follows. Draw a random matrix with i.i.d. Gaussian entries, then apply the Gram-Schmidt orthogonalisation procedure to obtain an orthogonal matrix (with ). The rows of are the orthogonal random vectors .
Each individual still has the correct marginal distribution (each row of the orthogonalised matrix is distributed as a random vector on the sphere of radius , which matches the direction of a Gaussian vector), but the rows are correlated — they are constrained to be mutually orthogonal. This is a form of antithetic sampling, a classical variance reduction technique from Monte Carlo methods.
5.2 The variance reduction guarantee
Theorem 2 (Choromanski et al., 2021). Let denote the positive softmax estimator with orthogonal random features, and the same estimator with independent (IID) random features. Then for any :
The second term is always non-negative (since ), which means:
Orthogonal features are always at least as good as independent features, and strictly better whenever — which is the case unless .
The improvement factor grows with , reaching approximately when . For , this gives an improvement of about per entry — small per entry, but compounded across the entries of the attention matrix, the cumulative effect is significant.
5.3 Numerical illustration
For our running example with , we construct orthogonal random features by orthogonalising our first two random vectors and .
Step 1: Normalise .
Step 2: Subtract the projection of onto (this is the Gram-Schmidt process).
Step 3: Normalise .
Step 4: Scale both to have the correct norm. For the ORF construction, the rows are scaled to have norm :
Verification of orthogonality: .
Now computing for with these two orthogonal projections ():
The components are still positive, as guaranteed. The orthogonal construction ensures that the two random projections “cover” the 2D space more efficiently than two independent random directions would.
5.4 The complete FAVOR+ mechanism
Putting together positive features (Section 4.2) and orthogonal features (Section 5.1), the FAVOR+ feature map is:
where are orthogonal random vectors. The output dimension is .
With this feature map, the linear attention approximation becomes:
where and , exactly as in the recurrent form from the Why Replace Attention blog.
The capacity of the FAVOR+ feature map is . The Performers paper recommends , giving a capacity of about — larger than the capacity of by a factor of .
5.5 The Performer architecture
A Performer is a Transformer where every attention layer is replaced by FAVOR+. All other components — the MLP layers, residual connections, layer norms, positional encodings — remain identical. This means:
- A Performer can be initialised from a pretrained Transformer by transferring all weights except the attention mechanism.
- After a small amount of fine-tuning, the Performer recovers most of the pretrained model’s accuracy (Choromanski et al., 2021, Figure 5).
This backward compatibility is a significant practical advantage: it means FAVOR+ can be deployed as a drop-in replacement for softmax attention in existing models, without retraining from scratch.
5.6 Redrawing random features
One subtlety: during training, the random matrix is redrawn periodically (e.g., every few hundred gradient steps). This serves two purposes:
- It prevents the model from overfitting to a specific set of random features.
- It improves the overall approximation quality across the training run.
Choromanski et al. (2021) show that redrawing is crucial for achieving performance matching the regular Transformer on larger datasets (PG-19), while on smaller datasets (LM1B), even a fixed random matrix works well.
6. DPFP: Deterministic Parameter-Free Projection
6.1 A different philosophy
FAVOR+ asks: how can we approximate the softmax kernel? Schlag et al. (2021) ask a different question: how can we increase the memory capacity without random sampling?
Their answer is the Deterministic Parameter-Free Projection (DPFP): a feature map that deterministically projects -dimensional keys into a higher-dimensional space of dimension , increasing the number of orthogonal directions available for storing associations.
6.2 Design goals
From the capacity analysis (Section 2) and the kernel requirements (Section 5.1 of the FWP paper), the feature map should satisfy:
-
Positivity: all components of must be non-negative, so that and attention weights are non-negative.
-
Increased dimension: , to increase the capacity beyond .
-
Orthogonality promotion: keys that are different in should map to vectors that are as orthogonal as possible in , minimizing crosstalk.
-
Determinism: no random sampling required, avoiding the variance inherent in FAVOR+.
-
Efficiency: the function should be cheap to compute, ideally parallelisable across dimensions.
6.3 The construction
The DPFP construction works in two steps.
Step 1: Concatenate and ReLU. Given an input vector , form the concatenation and apply the element-wise rectifier function (also known as ReLU):
This vector has the property that for each dimension of the original key, exactly one of or is non-zero (assuming ). Positive components land in the first positions, negative components land in the second positions (with their sign flipped).
Step 2: Pairwise products with circular shifts. The hyperparameter controls the capacity. For shift value , define a shifted copy:
Then the DPFP- feature map is the concatenation of element-wise products for all shifts:
where denotes the Hadamard (element-wise) product. The output dimension is:
6.4 Why this promotes orthogonality
The key insight is that the pairwise products partition the input space into non-overlapping regions. For a given shift , the product is non-zero only if both and . Since , this means both the -th and -th elements of must be positive.
For two keys and , the product involves terms like . This is zero unless all four factors are positive — meaning both keys have the same sign pattern in the relevant dimensions. If and differ in the sign of any component involved in a product, that product contributes zero to the dot product. This is a much stronger orthogonality condition than the raw dot product .
6.5 Numerical example
Let us compute DPFP- for our running example. With and , the output dimension is .
For : The concatenation is .
Circular shift by 1: shifted: take element at positions of , giving .
For : .
Shifted: .
For : .
Shifted: .
For : .
Shifted: .
6.6 Why our example is degenerate — and the lesson
Three of our four keys map to the zero vector under DPFP-. This is not a bug — it reveals an important property of the DPFP construction: it requires keys with mixed-sign components to produce non-zero features. A component pair produces a non-zero DPFP-1 output only when both and (or their negated counterparts) are positive, which requires consecutive positive entries in .
Our running example has all non-negative key components — , , , — so the only key with two consecutive positive entries in is , which has .
In practice, keys are the output of the projection , which produces both positive and negative values. To demonstrate DPFP properly, consider keys with mixed signs:
For : . . Shifted: .
For : . . Shifted: .
Now and are orthogonal:
The DPFP has mapped two non-orthogonal keys () to orthogonal feature vectors. This is precisely the orthogonality promotion that increases capacity.
6.7 Capacity comparison
| Feature map | for | Capacity |
|---|---|---|
| ELU+1 | 64 | |
| DPFP-1 | 128 | |
| DPFP-2 | 256 | |
| DPFP-3 | 384 | |
| FAVOR+ () | 266 |
Schlag et al. (2021) verify experimentally that these capacity limits are tight: on a synthetic key-value retrieval task, each model fails exactly when the number of unique keys exceeds (Figure 2 of the FWP paper). Linear Attention () begins to fail at 60 keys. DPFP-1, -2, -3 fail at 128, 256, and 384 keys respectively. Softmax attention handles over 500 keys without failing, confirming its theoretically infinite capacity.
7. Sum Normalisation
7.1 The problem with attention normalisation
The standard normalisation for linear attention divides by (the denominator from the Why Replace Attention blog). This is attention normalisation: the output is a weighted average of stored values, with weights summing to 1.
Schlag et al. (2021) identify a problem with this normalisation when combined with the delta update rule (the Gated DeltaNet blog). The accumulator grows monotonically — it only ever increases, because is non-negative. But the delta update rule removes old associations from the state . This means the numerator can decrease (as old values are erased), while the denominator continues to grow. The result: the output shrinks over time, approaching zero as the denominator accumulates.
7.2 Sum normalisation
Schlag et al. (2021) propose a simpler alternative: divide each feature vector by the sum of its components before using it. For the query:
and similarly for the key. Since all components of are non-negative (by design), the sum is positive, and the normalised vector has components that sum to 1. The output of the matrix-vector multiplication is then a weighted sum of the columns of where the weights sum to 1 — a proper convex combination.
7.3 Numerical example
For with : . Sum: .
For with : . Sum: .
Normalised similarity: .
The un-normalised similarity was . The normalisation reduces the magnitude but preserves the relative ordering of similarities.
7.4 Why sum normalisation works with the delta rule
With sum normalisation, the output is:
This is a weighted sum of the columns of , where the weights are the components of and they sum to 1. There is no separate denominator that can diverge. When the delta rule modifies (erasing and rewriting), the output responds directly to the modified state — there is no growing denominator to dampen the signal.
Schlag et al. (2021) verify experimentally that sum normalisation outperforms attention normalisation on both synthetic retrieval tasks and language modelling. On WikiText-103, the best configuration uses sum normalisation without attention normalisation and without absolute positional encoding (Table 3 of the FWP paper): validation perplexity 28.1, test perplexity 31.1.
8. The Unified View: Comparing Feature Maps
8.1 The design space
We have now encountered four feature maps for linear attention:
| Feature map | Type | Key property | |
|---|---|---|---|
| Identity () | Deterministic | No transformation; FWP baseline | |
| ELU+1 | Deterministic | Simple, element-wise, preserves dimension | |
| DPFP- | Deterministic | Increases capacity by ReLU-gated quadrant projection | |
| FAVOR+ | Stochastic | Approximates softmax with provable guarantees |
These span two axes of the design space:
Axis 1: Deterministic vs. stochastic. DPFP and ELU+1 produce the same output every time. FAVOR+ depends on the random matrix , introducing variance into the model’s output. During training, this variance is managed by periodic redrawing. During inference, the random features are fixed once.
Axis 2: Approximation vs. capacity. FAVOR+ is designed to approximate softmax attention as closely as possible — its quality improves with and converges to exact softmax as . DPFP makes no claim about approximating softmax. Instead, it increases the capacity of the associative memory, allowing the model to store more associations without interference. The two goals are related (softmax attention has infinite capacity) but distinct (a high-capacity kernel can still produce very different attention distributions from softmax).
8.2 Experimental evidence: synthetic retrieval
Schlag et al. (2021) test all feature maps on a synthetic key-value retrieval task (Section 6.1 of the FWP paper). The model must memorise a sequence of key-value pairs and retrieve the correct value when queried. The results (Figure 2 of the FWP paper):
- Softmax attention: perfect retrieval up to 500+ keys (limited only by training, not capacity)
- Linear Attention (ELU+1, ): fails at approximately 60 keys
- FAVOR+ with 64 random features: fails to achieve zero loss at any sequence length
- FAVOR+ with 128 random features: fails at approximately 60 keys (same as Linear Attention, since capacity is unrelated to the approximation quality of FAVOR+ in this setting)
- FAVOR+ with 512 random features: slight improvement but still limited
- DPFP-1 (): fails at approximately 128 keys
- DPFP-2 (): fails at approximately 256 keys
- DPFP-3 (): fails at approximately 384 keys
The results confirm the capacity analysis exactly: each model fails when the number of keys exceeds .
8.3 Experimental evidence: machine translation
On the WMT14 English-to-German translation task (Table 1 of the FWP paper), with and 8 heads:
| Model | Test BLEU | |
|---|---|---|
| Standard Transformer | — | 27.7 |
| Linear Transformer (ELU+1) | 64 | 26.8 |
| Performer () | 256 | 25.3 |
| Performer () | 512 | 27.7 |
| DPFP (ours) | 256 | 26.9 |
| DPFP (ours) | 512 | 27.1 |
The Performer matches the standard Transformer when is large enough (, so ). DPFP outperforms the Linear Transformer and reaches 27.1 BLEU at . But this comes at a cost: the state matrix is instead of — 8 times larger.
8.4 Experimental evidence: language modelling
On WikiText-103 language modelling (Table 2 of the FWP paper), comparing update rules. The small configuration has , (40M parameters) and the medium has , (90M parameters). Both are in the overcapacity regime:
| Model | Update rule | Small (test PPL) | Medium (test PPL) |
|---|---|---|---|
| Transformer | — | 34.1 | 29.6 |
| Linear Transformer | sum | 38.3 | 33.0 |
| Delta Network | delta | 35.5 | 31.5 |
| Performer | sum | 39.6 | 33.8 |
| Performer | delta | 37.2 | 31.8 |
Two observations. First, the delta update rule from the Gated DeltaNet blog improves both the Linear Transformer and the Performer in both configurations. For the Linear Transformer, the delta rule reduces test perplexity from 38.3 to 35.5 (small) and from 33.0 to 31.5 (medium). For the Performer, it reduces perplexity from 39.6 to 37.2 (small) and from 33.8 to 31.8 (medium). Second, the Performer is slightly worse than the Linear Transformer (ELU+1) in both configurations (39.6 vs 38.3 in small, 33.8 vs 33.0 in medium), suggesting that for language modelling in the overcapacity regime, the simplicity of ELU+1 may outweigh the theoretical elegance of softmax approximation.
8.5 The capacity-approximation tradeoff
The experimental evidence reveals a tension:
-
When capacity is the bottleneck (short sequences, synthetic tasks): increasing via DPFP or large gives the clearest improvements. The feature map matters more than the update rule.
-
When approximation quality matters (real-world tasks, long sequences): the Performer with large can match softmax attention on translation. But on language modelling, the simpler ELU+1 kernel is competitive, suggesting that the model learns to work with whatever kernel it is given.
-
The update rule matters independently: regardless of the feature map, the delta update rule improves over the simple sum update. This confirms the insight from the Gated DeltaNet blog — the feature map () and the update rule (sum vs. delta vs. gated delta) are orthogonal design choices that compound.
9. Backward Compatibility and Practical Considerations
9.1 Performers as drop-in replacements
A distinctive feature of the Performer is backward compatibility with pretrained Transformers. Because FAVOR+ approximates the actual softmax kernel, a Performer initialised with a pretrained Transformer’s weights produces an output that approximates the original model’s output.
Choromanski et al. (2021) demonstrate this (Figure 5 of the Performers paper): transferring weights from a pretrained Transformer into a Performer produces an initial non-zero accuracy (0.07 on LM1B), and after fine-tuning for a fraction of the original training steps, the Performer recovers accuracy close to the original Transformer. This is impossible with ELU+1 or DPFP, because those kernels produce different attention distributions that bear no approximation relationship to softmax.
9.2 Complexity comparison
All methods have the same asymptotic complexity: per layer, linear in sequence length . The practical differences are in the constant:
| Method | State size per head | Extra cost | |
|---|---|---|---|
| ELU+1 | None | ||
| DPFP- | ReLU + element-wise products | ||
| FAVOR+ () | Random projections ( matrix multiply) |
For the small language modelling configuration from the FWP paper (, heads, ), the wall-clock speeds are:
- Linear Transformer (sum, no delta): 66K words/sec
- Linear Transformer (delta, no attention norm): 63K words/sec
The delta update rule adds only a 5% overhead. For the DPFP and Performer with larger , the state is proportionally larger and the per-step compute increases, but the model is still faster than softmax attention for sequences longer than .
9.3 Training without truncating context
Linear attention models can process arbitrarily long sequences because the state size is constant. Schlag et al. (2021) demonstrate this by training a Delta Network on WikiText-103 without truncating the context window (Table 4 of the FWP paper). They carry the fast weight memory from one training segment to the next, while still limiting the backpropagation span.
The results show that the Delta Network achieves validation perplexity 27.8 and test perplexity 29.4 — better than its truncated-context counterpart (29.7 / 31.5) and competitive with a Transformer-XL that uses 6.29M state size (validation 24.6, test 25.5). The Delta Network achieves this with a state size of only 0.13M — 48 times smaller.
Summary
The Why Replace Attention blog established the kernel framework: replace softmax with to get linear attention. This blog asked: what should be? The Fast Weight Programmer perspective (Schlag et al., 2021) reframes the question as memory capacity — the state can store at most orthogonal key-value associations, and the feature map determines , so choosing is choosing a point on the capacity-efficiency curve. The Performer perspective (Choromanski et al., 2021) reframes the question as softmax approximation — if can approximate well enough, we inherit the quality of softmax attention at linear cost. FAVOR+ achieves this with positive orthogonal random features that are provably unbiased and lower-variance than trigonometric alternatives. DPFP achieves increased capacity deterministically through ReLU-gated quadrant projections. The experimental evidence shows that the choice of feature map interacts with but is independent of the update rule: the delta rule (Gated DeltaNet blog) improves all feature maps, and the capacity analysis correctly predicts retrieval failures across all kernels — confirming that linear attention is, at its core, a fast weight programmer writing to a finite-capacity associative memory.
Previous: Targeted Memory: The Delta Rule, Gated DeltaNet, and Kimi Delta Attention
Enjoyed this post?
Subscribe to get notified when I publish new posts. No spam, unsubscribe anytime.