Dynamic Long Context Reasoning over Compressed Memory via End-to-End Reinforcement Learning

Zhuoen Chen, Dongfang Li, Meishan Zhang, Baotian Hu, Min ZhangarXiv 2026

TL;DR

LycheeMemory introduces a cognitively inspired framework that tackles the massive computational overhead of long-context LLMs by combining chunk-wise KV-cache compression with dynamic, state-dependent memory recall. By jointly training a compressor and reasoner via end-to-end reinforcement learning, it scales context processing up to 1.75M tokens while achieving a 6× speedup and 2× memory reduction over existing agentic baselines.

What Problem Does This Paper Address?

Processing ultra-long contexts in Large Language Models (LLMs) is notoriously expensive due to the quadratic scaling of self-attention ($O(N^2)$). Existing solutions fall short: sparse attention mechanisms lose fine-grained details, Retrieval-Augmented Generation (RAG) suffers from "context fragmentation" that breaks multi-hop reasoning, and recurrent architectures (like MemAgent) require slow, sequential autoregressive updates for every single text chunk.

The authors aim to bridge the gap between explicit retrieval and implicit parametric memory, enabling efficient multi-hop reasoning over million-token contexts without exploding latency or memory usage.

Methods

LycheeMemory mimics human memory by separating long-term storage (a compressed memory bank) from short-term processing (an evolving plaintext working memory). As shown in the framework overview below, the architecture consists of three core components:

Figure 1: LycheeMemory achieved the best performance and latency. Left: Relative performance comparison of various methods on the Qwen2.5-7B model across different LongBench datasets. Right: Inference time comparison across different context lengths of 128 samples.
  1. Compressor ($\Phi_{comp}$): Splits the long document into chunks (e.g., 4096 tokens) and compresses them into compact KV-cache style representations by interleaving trainable "memory tokens" that absorb semantic information during a single parallel forward pass.
  2. Gate ($\Phi_{gate}$): A lightweight LoRA-augmented classifier acting as a dynamic filter. Crucially, it decides whether a compressed chunk is relevant based on both the user query and the current state of the working memory.
  3. Reasoner ($\Phi_{reason}$): Iteratively processes the selected chunks to update a fixed-length plaintext working memory and ultimately generate the final answer.

Optimization: The Compressor and Reasoner are jointly optimized end-to-end via Reinforcement Learning (using Group Sequence Policy Optimization, or GSPO) to ensure the compressed representations are perfectly tailored for downstream reasoning. The Gate is trained separately as a binary classifier.

Datasets

  • Pre-training: 1B tokens sampled from the RedPajama corpus to pre-optimize the compressor's text reconstruction and summary capabilities.
  • Downstream Training & Evaluation: Long-document QA datasets synthesized from HotpotQA (mixing gold evidence with distractors to scale from 7K to 1.75M tokens).
  • Zero-Shot Evaluation: Evaluated on multi-hop reasoning benchmarks including RULER-HQA, 2WikiMultihopQA, and StreamingQA.
  • Out-of-Distribution (OOD) Generalization: Tested on long-document summarization tasks from LongBench (GovReport and MultiNews).

Key Insights and Ideas

  • State-Dependent Retrieval is Essential for Multi-Hop QA: Traditional RAG ranks chunks using static query-chunk similarity. LycheeMemory's Gate conditions retrieval on the evolving working memory state ($P(\text{Chunk} \mid Q, m_t)$). This allows the model to discover "late-hop" evidence that only becomes relevant after intermediate clues have been uncovered.
  • Working Memory Saturation: Instead of growing linearly or unboundedly, the plaintext working memory length naturally stabilizes (saturating at ~500 tokens). The model actively learns to regulate its memory state, discarding noise and retaining only task-critical content.
  • The Danger of Feature Collapse: High compression ratios (e.g., 16×) lead to "feature collapse" where distinct entities with similar semantic embeddings (like close dates or family members) merge in latent space, causing attribute-swapping hallucinations. A 4× compression ratio was found to be the sweet spot for near-lossless performance.

Key Results

  • Massive Efficiency Gains: LycheeMemory exhibits a nearly flat inference latency curve as context scales. At 128K tokens, it achieves a 6× speedup over MemAgent and a 3.5× speedup over its own "without Gate" baseline, while cutting peak GPU memory usage by 2×.
  • Strong Extrapolation: It successfully maintains competitive accuracy when scaling context lengths from 7K all the way up to 1.75M tokens, outperforming standard long-context models and RAG baselines on multi-hop tasks.
Figure 1: LycheeMemory achieved the best performance and latency. Left: Relative performance comparison of various methods on the Qwen2.5-7B model across different LongBench datasets. Right: Inference time comparison across different context lengths of 128 samples.

Limitations and Future Work

  • Unidirectional Dependency Mismatch (35% of errors): Because LycheeMemory processes text in a single streaming pass, it cannot backtrack. If an early piece of evidence is filtered out by the Gate because its relevance is only revealed by a bridge entity much later in the document, that information is permanently lost.
  • Premature Inference Anchoring (21% of errors): The model sometimes suffers from confirmation bias, aggressively locking onto a partial match early in the working memory and ignoring or misinterpreting subsequent contradictory evidence.
  • Future Directions: The authors suggest developing bidirectional scanning or backtracking mechanisms to resolve dependency mismatches, alongside exploring dynamic compression ratios based on chunk information density.

Summary updated

BibTeX
@misc{chen2026dynamic,
  author = {Zhuoen Chen and Dongfang Li and Meishan Zhang and Baotian Hu and Min Zhang},
  title = {{Dynamic Long Context Reasoning over Compressed Memory via End-to-End Reinforcement Learning}},
  year = {2026},
  eprint = {2602.08382},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.08382},
}
Figure