Linear Attention via Orthogonal Memory

Jun Zhang, Shuyang Jiang, Jiangtao Feng, Lin Zheng, Lingpeng Kong · Submission to ICLR 2024 · Rejected

TL;DR

Standard linear attention mechanisms often suffer from "efficiency degradation," reverting to quadratic time complexity or incurring massive recurrent overhead when constrained by causal masking in autoregressive language models. LAVO (Linear Attention Via Orthogonal memory) preserves true $O(n)$ complexity by compressing context into a fixed set of orthogonal basis vectors, combining global orthogonal memory with local windowed attention and relative position embeddings. It scales cleanly to context lengths up to 128K tokens on a single 80GB A100 GPU without requiring specialized I/O kernel engineering.

What Problem Does This Paper Address?

While Transformers excel across modalities, vanilla self-attention scales quadratically, $O(n^2)$, with sequence length $n$. Numerous efficient linear attention mechanisms have been developed to bypass this bottleneck, but most were designed for bidirectional (noncausal) contexts.

When applied to autoregressive generation (causal modeling where token $t$ cannot look into the future), many of these techniques experience efficiency degradation:

  • Segmented low-rank approaches (e.g., Long-Short Transformer) divide contexts into chunks, causing causal complexity to degenerate back to $O(n^2 / l)$.
  • Kernel- or recurrence-based models often incur heavy memory overhead or large constant factors during incremental causal decoding.
  • Under unbounded contexts ($n \to \infty$), block-level approaches degrade to quadratic time.

Methods

LAVO tackles these bottlenecks with three core mechanisms:

  1. Context Compression via Orthogonal Decomposition (CODE):
  2. Context is compressed into a compact, fixed-size memory of $r$ vectors.
  3. A set of orthogonal bases $B \in \mathbb{R}^{r \times d}$ is initialized. Token representations are projected into these orthogonal subspaces to maximize feature distinguishability and minimize redundancy.
  4. In causal mode, the running global projection vector $H_t \in \mathbb{R}^{r \times 1}$ is updated incrementally in constant time: $$H_t = \frac{(t-1)H_{t-1} + B \cdot x_t}{t}$$
  5. Queries attend directly to this bounded orthogonal memory with $O(rn)$ linear complexity.
  6. Context Dissecting (Local + Global Hybrid):
  7. While orthogonal memory captures coarse global context, fine-grained details can be blurred.
  8. LAVO splits the context into sliding windows of length $w$. Tokens perform exact local attention within their window ($O(wn)$) while simultaneously querying the orthogonal memory for global features ($O(rn)$), running in total $O((w + r)n)$ time.
  9. Embedded Position Encoding:
  10. To support length extrapolation, relative position embeddings are integrated strictly into the local window attention ($O(wn)$ time, $O(w)$ space), avoiding the quadratic explosion typical of standard relative position encodings.
  11. Cross-Attention Extension:
  12. Because queries and keys need no structural alignment, LAVO applies CODE to compress source sequences into orthogonal memory, enabling linear-time cross-attention ($O(r(n + m))$).

Datasets

LAVO was benchmarked across diverse modalities:

  • Language Modeling: PG-19 (Project Gutenberg books) for long-range causal language modeling and extrapolation up to 128K tokens.
  • Text-to-Speech: LJSpeech evaluated on Mel Cepstral Distortion (MCD) and Mel Spectral Distortion (MSD).
  • Summarization: Multi-News evaluated via ROUGE scores under both causal and noncausal settings.
  • Point Cloud Completion: PCN dataset using PoinTr.
  • Time-Series Forecasting: ETT (ETT-h1, ETT-h2, ETT-m1) and Weather datasets using Informer.
  • Long-Sequence Benchmark: Long Range Arena (LRA) across Text, ListOps, Retrieval, Pathfinder, and Image tasks.

Key Insights and Ideas

  • Orthogonality beats naive pooling: Enforcing mutual orthogonality among basis memory units preserves feature entropy and distinguishability, allowing a small fixed memory budget ($r = 64$) to summarize tens of thousands of tokens without severe information collapse.
  • True length extrapolation: On PG-19, models trained at an 8,192 context length usually see perplexity explode when tested on longer contexts (e.g., FlashAttention + RoPE perplexity climbs from 15.09 to 34.84 at 16K). In contrast, LAVO’s perplexity actually improves (19.43 at 8K down to 19.40 at 16K), proving it effectively utilizes distant context.
  • Linear generation advantage: At long sequence lengths (16,384 tokens), LAVO achieves a 20.81× autoregressive generation speedup over vanilla attention, outpacing even FlashAttention (15.01×) because its computational graph is fundamentally linear rather than quadratic exact attention.

Key Results

  • Language Modeling (PG-19): LAVO achieved the best perplexity among linear-complexity models (19.40 at 16K context length, compared to 22.16 for local attention and 147.43 for ABC).
  • Unbounded Contexts (128K tokens): In zero-shot context length scaling up to 128K on an 80GB A100 GPU, LAVO was the only model capable of running without out-of-memory errors (excluding specialized I/O implementations like FlashAttention), with perplexity decreasing monotonically as sequence length grew.
  • Summarization & Cross-Attention: On Multi-News noncausal summarization, LAVO significantly outperformed vanilla attention (+4.4 ROUGE-1, +4.42 ROUGE-2). In cross-attention tasks, it achieved state-of-the-art results on point cloud reconstruction (Chamfer Distance L1: 7.200 vs. vanilla 7.425) and multivariate time-series forecasting.
  • Long Range Arena: LAVO attained the highest overall average score across the benchmark suite (59.74 AVG), leading on Text, ListOps, and Pathfinder.

Limitations and Future Work

  • Short-Sequence Overhead: On relatively short sequences, LAVO lags slightly behind hardware-optimized exact attention (such as FlashAttention) due to the absence of dedicated GPU kernel and SRAM-level I/O optimizations.
  • Future Directions: The authors highlight integrating IO-aware hardware optimizations directly into the orthogonal decomposition and local window calculations to bridge the speed gap on short-to-medium sequence lengths.

Summary updated

BibTeX
@misc{zhang2023linear,
  author = {Jun Zhang and Shuyang Jiang and Jiangtao Feng and Lin Zheng and Lingpeng Kong},
  title = {{Linear Attention via Orthogonal Memory}},
  year = {2023},
  eprint = {2312.11135},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.11135},
}
Figure