Abstract
Linear attention models offer subquadratic scaling by compressing past information into a fixed-size hidden state, but they often suffer from "memory collisions" that impair long-term retrieval. We present LoLA (Low-rank Linear Attention), a training-free inference strategy that identifies and caches tokens the model is likely to forget. By employing a novel "self-recall" metric, LoLA achieves near-perfect retrieval on long-context tasks while utilizing 4.6x less memory than standard Transformers.
Introduction
Standard Transformers face a significant hardware bottleneck as context length grows: the Key-Value (KV) cache expands linearly, leading to prohibitive memory requirements. While Linear Attention, RNNs, and State Space Models (SSMs) address this by using a fixed-capacity hidden state, this compression comes at a cost. The low-rank nature of the hidden state causes new information to overwrite older data, making these models struggle with "needle-in-a-haystack" retrieval tasks. Existing solutions like sliding windows only preserve local context, leaving the model "forgetful" of distant but critical information.
The LoLA Framework
LoLA introduces a three-tier memory management system for every attention head to balance efficiency with high-fidelity recall:
- Sliding Window Cache: Maintains the most recent KV pairs in full resolution using standard softmax attention.
- Linear Attention State: A recurrent matrix that stores easy-to-remember, generic information in a compressed format.
- Sparse Global Cache: A high-fidelity safety net for critical tokens that the linear state fails to represent accurately.
The core innovation is the Self-Recall Error (SRE) metric. As a token is evicted from the sliding window, the model performs a self-test: it attempts to retrieve the token's value using only its compressed linear state. If the error is high, indicating a memory collision, the token is deemed "difficult" and is stored in the Sparse Global Cache. This query-agnostic approach ensures the integrity of the memory itself rather than guessing future query relevance.
Visualizing Attention Patterns
LoLA effectively fills the gaps left by traditional linear models. By combining local sliding windows with a sparse global cache, it recovers the long-range dependencies that are typically lost during compression.
As shown in the comparison above, the base model (LoLCATs) only attends to the local diagonal. LoLA introduces sparse global connections (red blocks) that allow queries to access important historical tokens stored in the cache, while the remaining context is handled by the linear attention mechanism (grey blocks).
Experimental Evaluation
LoLA was evaluated across several benchmarks to test its retrieval and reasoning capabilities:
- Retrieval Accuracy: On the RULER S-NIAH-1 task (4K context), the base linear model achieved only 0.6% accuracy. LoLA boosted this to 97.4%.
- Memory Efficiency: LoLA-8B maintained high performance with a cache 4.6x smaller than that of Llama-3.1 8B.
- Reasoning: LoLA outperformed other subquadratic architectures, including Mamba2-8B and RWKV-6, on zero-shot commonsense reasoning tasks (PIQA, HellaSwag, MMLU).
Discussion and Conclusion
LoLA demonstrates that memory collisions in linear models are mathematically inevitable due to rank limitations, but they can be mitigated through intelligent, inference-time caching. While calculating SRE adds a minor computational overhead ($O(\lambda d)$), the resulting gains in long-context retrieval are substantial. Future work may explore non-linear key-value maps to further enhance the efficiency of the compressed memory tier, potentially reducing the required size of the sparse cache even further.
Summary updated