Lattice: Learning to Efficiently Compress the Memory
Mahdi Karami, Razvan Pascanu, Vahab Mirrokni
TL;DR
Lattice tackles the memory and compute bottlenecks of attention by compressing an unbounded key-value cache into a fixed set of memory slots and updating them via an online gradient step that writes only information orthogonal to each slot's current state. By normalizing memory slots and using a decoding/encoding framework with latent codes, it yields a stable, interpretable orthogonal state recurrence with sub-quadratic complexity. The approach is grounded in online optimization and connects to dictionary learning and Riemannian optimization, delivering improved perplexity on long-context language modeling tasks and robust ablations that highlight normalization as a key factor. These results suggest Lattice as a scalable alternative or complement to Transformers for long-context sequence modeling and potential for test-time adaptation and efficient fine-tuning.
Abstract
Attention mechanisms have revolutionized sequence learning but suffer from quadratic computational complexity. This paper introduces Lattice, a novel recurrent neural network (RNN) mechanism that leverages the inherent low-rank structure of K-V matrices to efficiently compress the cache into a fixed number of memory slots, achieving sub-quadratic complexity. We formulate this compression as an online optimization problem and derive a dynamic memory update rule based on a single gradient descent step. The resulting recurrence features a state- and input-dependent gating mechanism, offering an interpretable memory update process. The core innovation is the orthogonal update: each memory slot is updated exclusively with information orthogonal to its current state hence incorporation of only novel, non-redundant data, which minimizes the interference with previously stored information. The experimental results show that Lattice achieves the best perplexity compared to all baselines across diverse context lengths, with performance improvement becoming more pronounced as the context length increases.
