TL;DR
Linear attention models scale efficiently but often fail to capture complex long-range patterns because they rely on a single token to correct historical predictions. This paper introduces Residual Linear Attention (RLA), a framework that uses an auxiliary recurrent state to accumulate and correct prediction errors over time. By explicitly fitting these residuals, RLA and its delta-rule variant (RDN) significantly boost performance on language modeling and recall tasks while maintaining linear time and memory scaling.
What Problem Does This Paper Address?
Transformers are the gold standard for language modeling, but their core self-attention mechanism suffers from quadratic computational complexity ($O(N^2)$), making long sequences incredibly expensive to process. Linear attention alternatives solve this by reformulating the computation into a linear-time recurrent process ($O(N)$).
However, linear attention models historically suffer from an expressivity bottleneck. The authors of this paper reveal why: existing linear attention variants can be mathematically decomposed into a "base prediction" (generated from historical states) and a "correction term" derived solely from the current token. Relying on just a single token to fix systematic historical errors limits the model's capacity to handle complex, long-range dependencies.
Methods
To break this bottleneck, the authors propose Residual Linear Attention (RLA). Instead of a stateless, single-token correction, RLA introduces an auxiliary recurrent state matrix ($R_t$) dedicated entirely to tracking and learning from past prediction errors (residuals).
The core process works as follows:
- Residual Error Computation: Calculate the error between the true value and the base prediction: $r_t = v_t - S_{t-1}k_t$.
- Huber-inspired Clipping: To prevent training instability from large, transient errors, the residual is clipped ($r_t = \text{Clip}_{[-c,c]}(...)$). This provides a robust alternative mathematically linked to Huber loss.
- Auxiliary State Update: The auxiliary state $R_t$ accumulates these clipped residuals over time.
- Decoupled Gating: A dedicated scalar correction factor ($\gamma_t$) dynamically scales the contribution of this error-correction state, decoupling it from the base state's update rate ($\beta_t$).
The authors apply this framework to standard linear attention (RLA) and the delta update rule, creating Residual Delta Net (RDN).
Datasets
All models (~1.5B parameters) were pretrained on 100 billion tokens. Evaluation spanned standard language modeling and reasoning benchmarks: WikiText, LAMBADA, ARC-Easy, ARC-Challenge, PIQA, MMLU, HellaSwag, Winogrande, and SocialIQA.
To test memory capacity, they evaluated on recall-intensive tasks including DROP, FDA, NQ, SQD, SWDE, TQA, and the Needle-in-a-Haystack (NIAH) retrieval task.
Key Insights and Ideas
- The Prediction-Correction Lens: Viewing linear attention as an online gradient descent process allowed the authors to see that current models throw away historical error context during the correction step.
- Gradient Boosting in State Space: RLA effectively applies online gradient boosting to recurrent neural networks. The auxiliary state acts as a secondary model trained specifically to predict and cancel out the errors of the primary model.
- Stability through Clipping: Directly optimizing robust losses like Huber loss leads to non-linear update rules that are hard to parallelize. RLA cleverly isolates this complexity inside the pseudo-residual calculation via simple clipping, keeping the core hardware-friendly Triton kernels highly parallelizable.
Key Results
- Performance Boost: RDN achieved a WikiText perplexity of 16.57, outperforming its baseline GDN (17.27) and even beating the standard Transformer (17.33) under the same evaluation conditions.
- Superior Recall: On the challenging Needle-in-a-Haystack task, RLA scored 83.6%, a substantial leap over its baseline sGLA (76.6%), demonstrating an enhanced capacity for information recall.
- Efficiency Maintained: Despite the dual-state tracking, custom Triton kernels ensure that computation time scales linearly, remaining vastly superior to quadratic FlashAttention on long sequences.
Limitations and Future Work
While RLA preserves linear scaling, the explicit residual fitting process does introduce additional computational overhead due to the extra state updates and matrix multiplications. Balancing this added expressivity against the computational cost remains an open area for future research.
Summary updated