Trellis: Learning to Compress Key-Value Memory in Attention Models
Mahdi Karami, Ali Behrouz, Praneeth Kacham, Vahab Mirrokni
TL;DR
Trellis tackles the inefficiency of Transformer attention by introducing a bounded-memory transformer that learns to compress its key-value memory at test time. It uses a two-pass, non-linear compression with an online gradient-descent updater and a forget gate to store and selectively forget contextual information in a fixed-size memory. Across language modeling, commonsense reasoning, recall-heavy tasks, and time-series data, Trellis outperforms strong baselines and shows stronger gains as context length increases, highlighting its suitability for long-context settings. This approach enables efficient memory management and scalable inference without sacrificing performance, with promising directions for future integration with non-linear recurrent architectures and pretrained models.
Abstract
Transformers, while powerful, suffer from quadratic computational complexity and the ever-growing Key-Value (KV) cache of the attention mechanism. This paper introduces Trellis, a novel Transformer architecture with bounded memory that learns how to compress its key-value memory dynamically at test time. Trellis replaces the standard KV cache with a fixed-size memory and train a two-pass recurrent compression mechanism to store new keys and values into memory. To achieve this, it leverages an online gradient descent procedure with a forget gate, enabling the compressed memory to be updated recursively while learning to retain important contextual information from incoming tokens at test time. Extensive experiments on language modeling, common-sense reasoning, recall-intensive tasks, and time series show that the proposed architecture outperforms strong baselines. Notably, its performance gains increase as the sequence length grows, highlighting its potential for long-context applications.
