NeurIPS 2026Coming to NeurIPS in Sydney?Explore papers, orals & directions

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

Sangyun Lee, Sean Michael McLeish, Tom Goldstein, Giulia FantiNeurIPS 2026

TL;DR

Modern language models struggle to deeply reason over old information once it drops out of their active attention window, even when equipped with compressed long-term memory states. Taking a cue from biology, the authors introduce "sleep" for LLMs: whenever a model’s short-term context fills up, it pauses to run multiple recurrent passes over those tokens, organizing them into useful long-term weights before wiping the slate clean. This allows the model to answer complex, multi-step questions later in a single, instantaneous pass—shifting heavy mental lifting offline so real-time responses stay fast.

What Problem Does This Paper Address?

Transformers have great recall thanks to their Key-Value (KV) cache, which stores past tokens for future reference. Unfortunately, attention compute grows quadratically with sequence length, making infinite caches impractical. To fix this, frontier architectures increasingly use hybrid models that interleave standard attention (high-fidelity short-term memory) with State-Space Models or SSMs (which compress older, evicted tokens into fixed-size matrices called "fast weights").

Here is the catch: scalable memory is not the same as scalable reasoning. Prior work blamed hybrid model failures on limited memory capacity—trying to stuff too many tokens into a fixed-size matrix. The authors demonstrate something more subtle: even when the amount of information is small and completely fixed, hybrid models fail when a task requires deep sequential computation over evicted tokens. Compressing raw tokens in a single pass simply doesn't give the network enough compute steps to organize that information for future reasoning.

Methods

Inspired by hippocampal replay in sleeping animals—where short-term experiences are reactivated and consolidated into cortical weights while offline—the authors propose LLM Sleep.

They start with a standard SSM-attention hybrid model operating under a strict context window limit $L$. Instead of immediately deleting the KV cache when those $L$ tokens fill up, the model enters an offline consolidation phase ("sleep"):

  1. Offline Recurrence: With external inputs paused, the model loops over the accumulated $L$-token chunk $N$ times through its layers.
  2. Fast-Weight Refinement: During each loop, the SSM blocks iteratively update and refine their persistent fast weights via a learned local rule (like Gated Delta Networks or Jet layers).
  3. Hard Eviction & Wake: After $N$ passes, the KV cache and refined feature vectors are discarded; only the updated fast weights survive into the next window.
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.

Unlike standard depth-recurrent ("looped") transformers that loop at prediction time (slowing down user-facing responses) or use Chain-of-Thought tokens, LLM Sleep spends extra compute strictly offline. At "wake" time, answers are generated in a single forward pass. The entire pipeline—consolidation, eviction, and prediction—is trained end-to-end via backpropagation through the fast weights.

Datasets

To cleanly separate reasoning depth from memory capacity, the authors evaluate across three distinct settings (without introducing new benchmarks, instead adapting existing formalisms to strict cache-eviction rules):

  • Rule 110 Cellular Automaton: A synthetic 1D binary string evolution task that is P-complete (no parallel shortcuts exist). Sequence length is held fixed at 100 tokens while varying evolution steps $t$ to dial up sequential compute difficulty.
  • Depo: A synthetic $k$-hop graph traversal benchmark where shuffled directed graph edges are fragmented across four evicted cache windows before the model is queried to find nodes $k \in [1, 16]$ steps away.
  • GSM-Infinite: A procedurally generated, natural-language math word problem dataset modeled after GSM8K, padded with realistic distractor text (2,000–3,300 tokens) and evaluated without Chain-of-Thought traces across 1 to 8 arithmetic operations.

Key Insights and Ideas

  • Consolidation is an iterative algorithm: Turning raw observations into structured, query-ready knowledge is a nontrivial computation—much like gradient descent, it benefits from multiple iterative steps rather than a single pass.
  • Compute bottlenecks masquerade as memory bottlenecks: In controlled tests where an SSM easily has enough capacity to store four 24-bit strings, vanilla hybrids still collapse as rollout depth $t$ grows. The bottleneck isn't storage space; it's the compute depth needed to transform evicted context into a useful state.
  • Amortizing latency offline: By decoupling thinking depth from answering speed, models can prepare for complex queries during idle/consolidation boundaries without violating strict real-time latency constraints at inference.

Key Results

Across both from-scratch synthetic runs and fine-tuned pre-trained LLMs (Jet-Nemotron 2B and Ouro 1.4B), longer sleep ($N > 1$) consistently accelerates learning and unlocks harder reasoning regimes:

  • Rule 110 ($t=32$ steps): After ~5B training tokens, a standard non-looped hybrid ($N=1$) stalls near random guessing at ~10% exact accuracy. Adding sleep pushes accuracy to ~20% with 2 loops, and above 30% with 3 and 4 loops.
Figure 2: Increasing N improves performance on cellular automaton. Left: Each curve represents a different number of rollout steps t for a hybrid attention-SSM architecture, as in the motivating example section. Increasing t makes the task harder for a vanilla attention-GDN hybrid model. We early-stop 4- and 8-step runs as they converge earlier. Right: For a challenging reasoning task (t = 32), additional offline sleep loops improve accuracy while preserving single-pass wake-time prediction.
  • Depo ($k$-hop traversal): On deeper graph traversals, 1-loop models stall at 4-hop queries and 2-loop models stall at 8-hop queries. Within the training budget, only the 4-loop model begins solving 16-hop tasks.
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.
  • GSM-Infinite (Pre-trained LLMs): While easy 2- and 4-operation math problems saturate regardless of sleep, gaps widen sharply on deeper problems. On 6- and 8-operation problems, 6 sleep loops boost Jet-Nemotron 2B accuracy from 74.2% to 81.2% and 35.1% to 38.8%, respectively. For Ouro 1.4B (augmented with lightweight SSM layers), 4 loops jump 6-op accuracy from 41.9% to 61.5% (a 47% relative gain) and 8-op accuracy from 21.0% to 27.2%.

Limitations and Future Work

While wake-time inference stays fast, training gets heavier and trickier:

  • Sequential & Deep Training Costs: Because window $j+1$ depends on the fast weights refined during window $j$'s sleep, training loses full sequence-axis parallelism across windows, and compute cost scales roughly linearly with sleep duration $N$. (Though large window sizes $L$ can still keep GPUs saturated).
  • Optimization Instability: Backpropagating through $N$ deeper passes across evicted boundaries can make training slow and unstable. Future work could integrate recurrent-depth stabilization techniques, such as implicit gradients or truncated backpropagation through time.

Summary updated

Abstract

Transformer-based large language models are increasingly used for long-horizon tasks; however, their attention mechanism scales poorly with context length. To handle this, we study a sleep-like consolidation mechanism in which a model periodically converts recent context into persistent fast weights before clearing its key-value cache. During the sleep, the model performs N offline recurrent passes over the accumulated context and updates the fast weights in its state-space model (SSM) blocks through a learned local rule. During inference, this shifts extra computation to the sleep while preserving the latency of wake-time prediction. We test our method on controlled synthetic tasks, including cellular automata and multi-hop graph retrieval, as well as a realistic math reasoning task, on which SSM-attention hybrid models fail. We then show that increasing sleep duration N for our models improves performance, with the largest gains on examples that require deeper reasoning. Code available at https://github.com/sangyun884/llm-sleep
BibTeX
@inproceedings{lee2026do,
  author = {Sangyun Lee and Sean Michael McLeish and Tom Goldstein and Giulia Fanti},
  title = {{Do Language Models Need Sleep? Offline Recurrence for Improved Online Inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=9iKWH7TwxX},
}
Figure