Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction

Ziyang Wu, Tianjiao Ding, Yifu Lu, Druv Pai, Jingyuan Zhang, Weida Wang, Yaodong Yu, Yi Ma, Benjamin D. Haeffele

TL;DR

The Token Statistics Transformer (TOST) introduces a novel attention mechanism that operates in linear time and space, completely bypassing the traditional requirement of computing pairwise token similarities. Derived mathematically from a new variational formulation of the Maximal Coding Rate Reduction ($MCR^2$) principle, TOST matches the performance of standard transformers across vision, language, and long-sequence tasks while dramatically reducing computational overhead.

What Problem Does This Paper Address?

The defining feature of the Transformer architecture is the self-attention mechanism, which allows models to capture long-range dependencies across data tokens (like words or image patches). However, standard self-attention comes with a major flaw: it requires computing the similarity between every single pair of tokens. This causes both computational time and memory footprint to scale quadratically ($O(n^2)$) with the sequence length ($n$).

As a result, processing long documents, high-resolution images, or extended video sequences becomes prohibitively expensive. While various "efficient" attention approximations exist (such as low-rank projections or local windows), the authors of this paper tackle a deeper conceptual question: Is computing pairwise token similarity even necessary for effective attention?

Methods

Instead of heuristically modifying standard attention, the authors use a "white-box" design approach called algorithmic unrolling. This framework treats the layers of a neural network as sequential optimization steps designed to minimize a specific mathematical objective.

The authors build upon the principle of Maximal Coding Rate Reduction ($MCR^2$), which aims to map data into structured, low-dimensional subspaces where features belonging to the same category are compressed together, while different categories are pushed apart.

The key technical innovations include:

  1. A New Variational Formulation: The authors derive a novel variational upper bound for the spectral functions of large matrices. This allows them to rewrite the complex $MCR^2$ compression objective into an equivalent form that can be optimized via simple diagonal operations.
  2. Token Statistics Self-Attention (TSSA): By unrolling gradient descent steps on this new variational objective, they naturally arrive at a brand-new attention operator. Instead of computing token-to-token similarities, TSSA softly clusters tokens into groups and computes an empirical second-moment statistic for each group. It then applies a data-dependent low-rank projection that preserves directions with high "power" and suppresses noisy ones.
Figure 3: One layer ℓof the proposed Token Statistics Transformer (TOST). Notably, the self-attention of TOST transforms tokens Zℓefficiently to Zℓ+1, via multiplying each row of the projected token by only a scalar. This leads to reduced complexity of the attention (cf. Table 1): it has O(p) space and O(pn) time complexity, where p is the dimension of the projected tokens of each head, and n is the number of tokens.

For language modeling, the authors also introduce Causal-TOST, which utilizes efficient cumulative sums (cumsum) to ensure tokens only attend to past timesteps without sacrificing linear complexity.

Datasets

The authors evaluated TOST across three distinct domains:

  • Vision: Pre-trained on ImageNet-1k, and evaluated via transfer learning on CIFAR-10, CIFAR-100, Oxford Flowers-102, and Oxford-IIT-Pets.
  • Long Sequences: The Long-Range Arena (LRA) benchmark, which includes challenging long-context tasks like ListOps, byte-level Text classification, document Retrieval, Image classification, and Pathfinder.
  • Language: Autoregressive language modeling on the OpenWebText dataset.

Key Insights and Ideas

  • Moving Beyond Pairwise Similarities: The paper challenges the conventional wisdom that transformer success hinges on token-to-token dot products. TOST proves that global token statistics and low-rank projections can achieve comparable results.
  • Asymptotic Efficiency: Because it avoids the $O(n^2)$ similarity matrix, a TSSA attention head operates with $O(pn)$ time complexity and $O(p)$ space complexity (where $p$ is the projected head dimension).
  • Inherent Interpretability: Because TOST is derived from an explicit clustering and compression objective, its internal representations are mathematically interpretable. The attention maps naturally perform object segmentation and clustering without needing self-supervised training or pixel-level annotations.

Key Results

  • Massive Speed and Memory Gains: In empirical benchmarks on an NVIDIA H800 GPU, TOST demonstrated dramatic savings. For sequences of 10,000 tokens, TOST ran approximately 10x faster and used nearly 100x less GPU memory than a standard Vision Transformer (ViT).
Figure 1: Our TOST architecture, from unrolling a novel varia- tional form of MCR2, is faster and uses less memory than stan- dard transformer architectures such as ViT (note the log-scale y- axes) and is based on a dramatically different notion of attention.
  • Competitive Performance:
  • On ImageNet-1k, TOST-Medium achieved a top-1 accuracy of 80.3%, performing on par with standard ViT-Small (79.8%) and the efficient XCiT-Small (80.5%).
  • On the Long-Range Arena benchmark, TOST achieved an average score of 59.90%, outperforming standard Transformers (59.24%) as well as popular efficient variants like Performer (51.18%) and Linformer (50.46%).
  • In language modeling, swapping standard attention for Causal-TOST preserved competitive zero-shot cross-entropy loss while scaling cleanly to longer context windows.

Limitations and Future Work

  • Scale Restrictions: Due to computational resource constraints, the authors only evaluated TOST up to medium-sized models (655M parameters for language, 68M for vision). Its competitive edge at massive scales (e.g., billions of parameters) remains to be verified.
  • The MLP Bottleneck: This work focused entirely on replacing the attention block, leaving the standard Multi-Layer Perceptron (MLP) sub-layers unchanged. The authors noted that alternative white-box blocks (like the ISTA block used in CRATE) underperformed when paired with TOST, leaving the design of a complementary, mathematically principled MLP replacement as an open problem for future research.

Summary updated

BibTeX
@inproceedings{wu2025token,
  author = {Ziyang Wu and Tianjiao Ding and Yifu Lu and Druv Pai and Jingyuan Zhang and Weida Wang and Yaodong Yu and Yi Ma and Benjamin D. Haeffele},
  title = {{Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=lXRDQsiP2v},
}
Figure