TL;DR
Modern recurrent neural networks (RNNs) compress their entire history into a fixed-size state in a single causal pass, forcing them to compromise on what details to keep before knowing how they will be used. This paper introduces dynamic compression, a method where the model retains a lossless raw token log and selectively re-scans relevant past tokens to update and sharpen its recurrent state on demand. This introduces a powerful computation-memory tradeoff, allowing smaller recurrent states to achieve the performance of massive single-pass models.
What Problem Does This Paper Address?
While Transformers scale linearly ($O(t)$) in memory and compute per token due to their Key-Value (KV) cache, modern recurrent architectures (like Mamba, RWKV, or Gated DeltaNet) maintain a constant-sized state ($O(1)$), making them highly efficient for long contexts.
However, this fixed-size state creates a fundamental bottleneck: the model must decide how to compress an input token before knowing which details future tasks will require. If a long sequence contains multiple independent pieces of information—such as different skills or functions learned in-context—a standard single-pass RNN must compress all of them at a uniformly high fidelity. As the number of tasks or functions grows, the required size of this task-agnostic hidden state explodes exponentially, making single-pass static compression prohibitively expensive.
Methods
The authors propose Dynamic Compression, implemented on top of Gated DeltaNet (a linear-attention RNN utilizing a gated delta rule).
Instead of relying strictly on a single left-to-right pass, the model retains the observed sequence as a lossless raw record. When a later context (like a few-shot prompt) reveals what information is currently relevant, the model uses a dual-head setup:
- Selection Head: Predicts which past tokens or blocks are relevant to the current task.
- Prediction Head: Outputs the final answer after the state has been updated.
Once the selection head identifies the correct past context, the model re-scans those specific tokens. This second pass acts as a targeted write operation, revising and sharpening the fixed-size recurrent state specifically for the active task.
To eliminate the need for ground-truth labels of what to re-scan, the authors develop a self-supervised codebook approach:
- They train a "repeat model" on sequences where the entire prefix is replayed.
- They observe the model's internal gate update strengths ($\beta$) during the repeat pass to see what it naturally chooses to overwrite when it already knows the query.
- They cluster these $\beta$ patterns using $k$-means to form a "re-scan codebook."
- Finally, they train the dynamic model to predict these codebook selections directly from the initial pass, making the policy entirely label-free.
Datasets
The authors evaluate their method on a controlled, synthetic continual function-reuse task designed to isolate functional memory:
- Basis Phase: The model sequentially observes $K$ different linear functions (represented as $d \times d$ matrices, where $d=8$) along with one-hot identifiers.
- Query Phase: The model encounters a series of few-shot blocks containing unlabeled input-output pairs from one of the functions, followed by a prompt query vector $x_{qry}$. The model must identify the correct function from the few-shot examples and accurately predict the output matrix multiplication.
Key Insights and Ideas
- The Computation-Memory Tradeoff: Instead of scaling the physical size of the hidden state to store everything at high fidelity, models can maintain a small hidden state and spend extra compute (re-scanning) at inference time to dynamically recompress the past.
- Coarse-to-Fine Representations: Dynamic compression fundamentally changes how the model utilizes its memory. On the first pass, the state only needs enough capacity to maintain a coarse representation sufficient for identifying the function later. The high-fidelity details are filled in later during the re-scan pass.
- Gating Signals as Unsupervised Targets: An RNN's internal write-gate activations ($\beta$) during a repeated sequence provide an elegant, built-in supervisory signal for attention, showing exactly what the network "wants" to look at when given a second chance.
Key Results
- 30x State Size Reduction: For a task with $K=3$ functions, the dynamic re-scanning model with a tiny 111k-element state achieved lower validation error than a standard single-pass model requiring a 3.1M-element state.
- Superior Scaling Laws: As the number of stored functions $K$ scales up, the error of single-pass models grows aggressively (with a power-law fit exponent of $\approx 6.1$). In contrast, the dynamic re-scanning model scales much more gracefully (exponent of $\approx 2.3$).
- Effective Self-Supervision: The unsupervised "codebook dynamic" model successfully closed a substantial portion of the performance gap between the single-pass baseline and the oracle-supervised upper bound.
Limitations and Future Work
- Synthetic Constraints: The current evaluation is restricted to clean, well-delineated linear functions with known block boundaries.
- Scaling to Natural Language: Extending dynamic compression to real-world LLM pretraining remains an open challenge. It will require more flexible ways to parameterize the re-scan space (e.g., letting the model drop its own "bookmarks" or navigate via relative movements) when tasks are not explicitly separated.
- Reinforcement Learning: The authors note that post-training via reinforcement learning could be an excellent way to let large models discover optimal, open-ended re-scanning policies directly from data.
Summary updated