End-to-End Context Compression at Scale

Ang Li, Sean Michael McLeish, Haozhe Chen, Nimit Kalra, Zaiqian Chen, Artem Gazizov, Venkata Anoop Suhas Kumar Morisetty, Bhavya Kailkhura, Harshitha Menon, Zhuang Liu, Brian R. Bartoldson, Tom Goldstein, Sanae Lotfi, Micah Goldblum, Pavel Izmailov

TL;DR

This paper introduces Latent Context Language Models (LCLMs), a novel family of encoder-decoder compressors that significantly improve the efficiency of processing long contexts in Large Language Models (LLMs). By compressing input sequences into a smaller set of latent embeddings, LCLMs achieve a new Pareto frontier in terms of accuracy, speed, and memory usage, making them practical for long-horizon agentic tasks.

What Problem Does This Paper Address?

Modern LLMs are increasingly tasked with processing and reasoning over extremely long contexts, such as entire documents or codebases. This capability is crucial for tasks like multi-turn conversations, document analysis, and agentic systems. However, the inference process for LLMs is heavily bottlenecked by the memory required to store the KV cache, which grows linearly with context length. Existing methods for compressing this KV cache often either degrade model quality significantly, require substantial computational resources, or are incompatible with efficient production inference engines. While encoder-decoder compression offers a promising alternative by mapping long token sequences to shorter latent representations, prior approaches haven't matched the efficiency and accuracy of KV cache compression. This paper aims to bridge this gap by developing and scaling encoder-decoder compressors that are both highly efficient and maintain strong model performance.

Methods

The core innovation of this paper is the development of Latent Context Language Models (LCLMs), which are encoder-decoder models specifically designed for context compression. The process involves:

  • Encoder-Decoder Architecture: An encoder takes the long input sequence and maps chunks of tokens into a smaller number of "soft tokens" (latent embeddings). An adapter then projects these latent embeddings to match the decoder's dimension. Finally, the decoder uses these compressed latent embeddings as its context.
  • Large-Scale Architecture Search: The authors conducted a comprehensive search to identify optimal architectural choices for LCLMs. This involved pre-training many variants from scratch to determine the best pooling strategies (mean pooling emerged as a strong performer), encoder attention masks (causal masking was preferred), and adapter designs (MLP adapters outperformed attention-based ones).
  • Multi-Stage Training Recipe: A carefully designed training recipe was developed, involving adapter warmup, encoder training, end-to-end continual pre-training, and supervised fine-tuning. This staged approach helps stabilize training and mitigate catastrophic forgetting.
  • Continual Pre-training and SFT: Models were trained on massive datasets (over 350B tokens) using a mixture of data types, including interleaved compressed/uncompressed segments, supervised fine-tuning data, and auxiliary reconstruction tasks. This ensures the models learn to generalize and preserve fine-grained information.

Datasets

The authors utilized a combination of existing and curated datasets for training and evaluation:

  • Training Data:
    • NVIDIA's Nemotron pre-training datasets (CC, Code, Reasoning).
  • OLMo-3 long-context data.
  • Supervised Fine-Tuning (SFT) data, including reasoning, code, science, and instruction-following datasets.
  • Auxiliary reconstruction data, spanning text, code, and LATEX from various sources.
  • Evaluation Benchmarks:
    • Long-context: RULER, LongBench, LongHealth.
  • Fine-Grained Compression: GSM8K.
  • Agentic Tasks: NIAH (needle-in-a-haystack) tasks.

Key Insights and Ideas

  • Encoder-Decoder Compression is Competitive: The paper demonstrates that well-trained encoder-decoder compressors can indeed close the accuracy-efficiency gap with KV cache compression methods, offering a viable alternative for long-context processing.
  • Mean Pooling is a Strong Default: For pooling strategies, mean pooling consistently outperformed other methods in their architecture search, providing a robust way to aggregate local context.
  • Causal Masking is Superior: In the encoder, causal masking proved to be more effective than bidirectional masking for achieving lower pre-training loss.
  • MLP Adapters are Efficient: Contrary to some prior work, the authors found that simpler MLP adapters were more efficient and achieved better performance than attention-based adapters in their setup.
  • Decoder Scaling Matters More: When scaling model sizes, increasing the decoder's capacity had a more significant positive impact on pre-training loss than increasing the encoder's size.
  • LCLMs Enable Effective Agents: The compressed context provided by LCLMs, combined with an agent's ability to selectively expand segments, significantly boosts performance on challenging retrieval and reasoning tasks.

Key Results

  • Pareto Frontier: LCLMs establish a new Pareto frontier, achieving faster inference and lower peak GPU memory usage compared to KV cache compression baselines, while maintaining high accuracy across various compression ratios (1:4, 1:8, 1:16).
  • Accuracy Preservation: At 16x compression, LCLMs achieved accuracy levels on RULER and LongBench that were competitive with, and often superior to, KV cache compression methods, with some LCLMs reaching over 80% accuracy.
  • Speed and Memory Efficiency: For context lengths up to 1M tokens, LCLMs demonstrated significantly lower time-to-first-token (TTFT) and peak GPU memory usage. For instance, at 1M tokens, Attention Matching ran out of memory, while LCLMs remained operational.
  • Agentic Performance Boost: When integrated into an agentic system, LCLMs with a 16x compression ratio showed substantial improvements on NIAH retrieval tasks, with gains of up to +19.72% in average accuracy.

Limitations and Future Work

  • Scaling Mixed Results: While scaling the decoder size improved pre-training loss, the downstream gains were not always as expected, potentially due to a mismatch between the training recipe and the larger decoder's initialization.
  • Future Work: The authors suggest several promising directions:
  • Compressing inputs at multiple granularities and dynamically allocating capacity based on information density.
  • Extending compression beyond static input context to the model's generated state, including chain-of-thought, tool observations, and agent's accumulated working history.
  • Exploring new mechanisms for adaptive expansion in agentic systems, potentially learning this behavior end-to-end.
  • Investigating alternative model choices for the encoder, such as initializing from a language model versus an embedding model.

Summary updated

BibTeX
@inproceedings{li2026end,
  author = {Ang Li and Sean Michael McLeish and Haozhe Chen and Nimit Kalra and Zaiqian Chen and Artem Gazizov and Venkata Anoop Suhas Kumar Morisetty and Bhavya Kailkhura and Harshitha Menon and Zhuang Liu and Brian R. Bartoldson and Tom Goldstein and Sanae Lotfi and Micah Goldblum and Pavel Izmailov},
  title = {{End-to-End Context Compression at Scale}},
  booktitle = {SPIGM @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=87TmBrdVBN},
}
Figure