Do Language Models Need Sleep? Offline Recurrence for Improved Online Inference

Sangyun Lee, Sean McLeish, Tom Goldstein, Giulia FantiarXiv 2026

TL;DR

State-space model (SSM)-attention hybrid language models struggle with deep reasoning over long contexts once information is evicted from their active memory cache. This paper introduces a "sleep" mechanism where the model performs multiple offline recurrent passes over context chunks to consolidate information into its internal weights before clearing the cache. This approach significantly boosts performance on complex reasoning tasks while maintaining fast, single-pass inference during prediction time.

What Problem Does This Paper Address?

Standard Transformers rely on a Key-Value (KV) cache to remember past tokens, but this cache scales poorly—demanding quadratically more compute and linearly more memory as context grows. To fix this, modern hybrid architectures interleave attention with State-Space Models (SSMs) to compress old context into fixed-size "fast weights" (hidden states).

However, the authors identify a critical bottleneck: these hybrid models fail at deep reasoning over context that has been evicted from the active cache. The issue isn't memory capacity, but a lack of compute during the compression phase. A single forward pass simply doesn't provide enough computational depth to transform complex, raw context into highly structured, useful internal representations.

Methods

The authors propose LLM Sleep, an offline recursive memory consolidation phase. The core idea mimics biological sleep: decoupling information processing from immediate external stimuli.

When the model's active context window fills up during inference or training, it enters a "sleep" state:

  1. Offline Recurrence: Instead of a standard single forward pass, the model executes $N$ recurrent passes over the accumulated context chunk.
  2. Fast Weight Updates: These passes iteratively update the fast weights (SSM states) via a learned local rule, giving the model more time to "think" and organize the data.
  3. Cache Eviction: After $N$ sleep loops, the KV cache is cleared (via hard eviction or a sliding window), and the model resumes normal operation.
  4. Wake-Time Prediction: Crucially, during the prediction phase, the model uses a single standard forward pass, preserving low inference latency.

The entire process is optimized end-to-end by backpropagating gradients directly through the sleep loops and the refined fast weights.

Figure 1: At the eviction boundary, an SSM-attention hybrid performs N offline recurrent passes over the current context before discarding the attention cache. These recurrent passes update the fast weights in the SSM blocks, allowing later predictions to use consolidated context without wake-time looping.

Datasets

The method was evaluated on three distinct benchmarks designed to isolate reasoning depth from simple retrieval:

  • Rule 110: A 1D binary cellular automaton task used to test deep sequential computation (a P-complete problem).
  • Depo: A multi-hop knowledge retrieval task involving graph traversal over a shuffled directed cycle, where difficulty scales with the number of hops ($k$).
  • GSM-Infinite: A procedurally generated synthetic math reasoning benchmark modeled after GSM8K, designed to test multi-step arithmetic reasoning over long contexts filled with distractor tokens.

Key Insights and Ideas

  • Recurrence for Consolidation, Not Just Prediction: Traditional recurrent models loop at prediction time (like Chain-of-Thought), which slows down user-facing inference. LLM Sleep shifts this recurrent compute to an offline phase, decoupling reasoning depth from prediction latency.
  • The Compute Bottleneck of Compression: Compressing information isn't passive storage; it requires active computation. Complex structures (like graphs or cellular automata) cannot be optimally compressed in a single forward pass.
  • End-to-End Gradient Flow Through Weights: Unlike standard depth-recurrent models where gradients flow through hidden feature vectors, LLM Sleep discards features post-sleep, forcing gradients to flow directly through the refined fast weights.

Key Results

  • Rule 110: On a challenging setting ($t=32$ rollout steps), the standard no-loop hybrid model fails completely, performing near random guessing (~10% accuracy). Introducing 4 sleep loops increases accuracy to over 30%.
  • Depo: Additional offline loops dramatically accelerate learning on complex multi-hop queries (4-hop, 8-hop, and 16-hop), where fewer loops cause the model to stall completely.
  • GSM-Infinite: Fine-tuning a pre-trained Jet-Nemotron 2B model with 6 sleep loops improved final accuracy on 6-operation problems from 74.2% to 81.2%, and on 8-operation problems from 35.1% to 38.8%. For the Ouro 1.4B model, 4 loops boosted 6-operation accuracy from 41.9% to 61.5%.
Figure 3: Increasing N improves performance on Depo. Test loss of a 4-layer GDN-attention hybrid on the k-hop knowledge retrieval task. Additional offline loops accelerate learning, especially for more reasoning-intensive, higher-hop queries.

Limitations and Future Work

  • Training Overhead: Performing $N$ forward and backward passes makes training computationally expensive and potentially unstable. The authors suggest exploring implicit gradients or truncated backpropagation through time (BPTT) to mitigate this.
  • Reduced Parallelism: Recurrence across context windows introduces a sequential dependency during training, preventing full parallelization along the sequence axis (though this is less problematic when the window size $L$ is large enough to saturate the GPU).

Summary updated

BibTeX
@misc{lee2026do,
  author = {Sangyun Lee and Sean McLeish and Tom Goldstein and Giulia Fanti},
  title = {{Do Language Models Need Sleep? Offline Recurrence for Improved Online Inference}},
  year = {2026},
  eprint = {2605.26099},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.26099},
}
Figure