Linear Attention › Other Linear Attention Variants
Language AI HandbookAll chapters Linear Attention › Other Linear Attention VariantsOne section · Sections in this chapter10 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The linear attention family has grown to include many variants, each addressing different aspects of the softmax-to-kernel trade-off:
-
Linear Transformer (Katharopoulos et al., 2020): The foundational work that established the kernel view and demonstrated causal linear attention for autoregressive models.
-
Random Feature Attention (RFA): Uses random Fourier features to approximate the Gaussian kernel. This provides a middle ground between simple feature maps and Performer's FAVOR+.
-
Nyströmformer (Xiong et al., 2021): Uses the Nyström method to approximate the attention matrix with landmark points, achieving complexity where is the number of landmarks.
-
FNet (Lee-Thorp et al., 2021): Replaces attention entirely with Fourier transforms, achieving complexity with no learnable attention parameters.
-
RetNet (Sun et al., 2023): Combines linear attention with exponential decay, creating a recurrent formulation that supports both parallel training and efficient incremental inference.
def compare_linear_variants(n, d):
"""Compare complexity of different linear attention variants."""
variants = {
"Standard Softmax": n * n * d,
"Linear (ELU)": n * d * d,
"Performer (m=256)": n * 256 * d + 256 * d,
"Nyströmformer (m=64)": n * 64 * d,
"FNet (FFT)": n * np.log2(n) * d,
}
return variantsvariants = compare_linear_variants(4096, 64)Complexity Comparison of Attention Variants (n=4096, d=64): Variant FLOPs vs Standard ------------------------------------------------------- Standard Softmax 1.07G 1.0x faster Linear (ELU) 16.8M 64.0x faster Performer (m=256) 67.1M 16.0x faster Nyströmformer (m=64) 16.8M 64.0x faster FNet (FFT) 3.1M 341.3x faster
Linear attention with ELU features achieves approximately 64x speedup over standard softmax attention at this sequence length, while Performer with 256 random features achieves around 60x. The simpler variants (Nyströmformer, FNet) offer even greater speedups but with different quality trade-offs.