How does linear attention achieve sub-quadratic complexity compared to softmax attention?
Last updated
Softmax is replaced by a kernel feature map φ, and associativity lets
φ(K)^T Vbe computed first as a small d×d summary. Cost drops from O(N²d) to O(Nd²) with no N×N matrix.In causal form it becomes an RNN with a fixed-size state, giving constant time and memory per decoding step and no growing KV cache.
Trade-offs: it only approximates softmax, attention is less sharp, and the fixed state hurts exact recall. Gated variants (RetNet, Mamba-style, GLA) narrow the gap.