Test-Time Forecasting: Recurrent Depth Enables In-Context Dynamics Prediction

Jeffrey B. Lai, John Quinn, Anthony Bao, William GilpinarXiv 2026

This paper introduces Test-Time Forecasting (TTF), a framework demonstrating that looped transformers can emulate gradient descent to predict unseen dynamical systems in-context. By establishing a theoretical link between linear attention and dynamic mode decomposition, the authors show that lightweight models can generalize to complex, out-of-distribution dynamics simply by increasing the number of recurrent iterations at inference time.

What Problem Does This Paper Address?

Foundation models for dynamical systems (like those for weather or physiology) have shown a remarkable ability for in-context learning (ICL)—the ability to adapt to new, unseen dynamics during inference based only on the provided input data. However, these models are typically massive (10M–100M parameters), and we lack a clear mechanistic understanding of how ICL emerges in continuous-valued forecasting.

The authors ask: Can ICL emerge without massive parameter scale? They investigate whether the "recurrent depth" paradigm—where a model repeatedly applies the same weight-tied layers—can serve as a theoretically grounded mechanism for test-time optimization and system identification.

Methods

The core of the paper is the Test-Time Forecasting (TTF) framework, which views the forward pass of a transformer as an iterative optimization process.

  1. Theoretical Link: The authors prove that a looped linear attention layer, when combined with specific short convolutions, is mathematically equivalent to performing gradient descent on the Dynamic Mode Decomposition (DMD) objective. This establishes that transformers don't just "memorize" patterns; they can act as numerical solvers.
  2. Two TTF Variants:
    • Implicit TTF (iTTF): The recurrence happens in the prediction space (latent states). The model updates its internal representation of the trajectory at each loop.
  3. Explicit TTF (eTTF): The recurrence happens in the parameter space. The model contains "fast weights" that are updated via an inner optimization loop (like AdamW) during the forward pass, while the "slow weights" (encoder/decoder) remain fixed.
  4. Training Strategy: To make the models robust to varying compute budgets, they are trained using a log-normal Poisson distribution for the number of loops. They also utilize Truncated Backpropagation Through Time (TBPTT) to manage the computational cost of training through recurrent iterations.
Figure 1: TTF as a flexible framework for designing forecasters with recurrent depth and in-context learning capability by embedding regression over a forecasting objective in latent space. (iTTF) Prediction space recurrence. (eTTF) Parameter space recurrence. The choice of iTTF block U, eTTF inner loss L, inner model F, encoder ϕ, and decoder χ are all task-dependent.

Datasets

The authors evaluate TTF across a spectrum of dynamical complexity:

  • Linear Dynamical Systems (LDS): 8D affine systems used to validate the theoretical link to DMD.
  • Forced Duffing Oscillator: A classic example of low-dimensional chaos used to test nonlinear generalization.
  • Partial Differential Equations (PDEs):
    • Advection-Diffusion (AD): A linear spatiotemporal PDE.
  • Korteweg-De Vries (KdV): A nonlinear PDE featuring soliton dynamics.
  • Kuramoto-Sivashinsky (KS): A highly chaotic 1D model of turbulence.

For each system, they sweep a "difficulty parameter" (like advection strength or domain length) to create distinct In-Distribution (ID) and Out-of-Distribution (OOD) sets.

Key Insights and Ideas

  • Recurrent Depth = Optimization: The most profound insight is that depth in a transformer can be explicitly designed to perform test-time regression. Instead of needing more parameters, you can often get better results by just "thinking longer" (looping more).
  • The Necessity of Convolutions: The paper highlights that short convolutions (window size 2) are not just a trick for stability; they are theoretically required to implement the time-shifting necessary for solving dynamics objectives in-context.
  • Extreme Parameter Efficiency: Because the model leverages optimization at test time, it can be incredibly small. The authors demonstrate an eTTF model for Advection-Diffusion with only 17 parameters that successfully performs system identification.
  • Scaling Laws for Loops: Performance (measured by spectral error or nRMSE) scales predictably with the number of loops. In linear systems, this scaling is linear; in chaotic systems, more loops allow the model to capture complex attractors that a single-pass model misses entirely.
Figure 2: Loop scaling improves LDS forecasting. (A) Across unseen systems, linear scaling of spectral error with loops. (B) For a single unseen system, convergence to the eigenvalues near the unit circle. (C) Example rollout for the unseen system improves with loops (dotted line is groundtruth).

Key Results

  • OOD Generalization: On the chaotic Duffing oscillator, the iTTF model's performance improves significantly with loops, eventually covering the entire chaotic attractor, whereas a 1-loop model fails to leave a single basin of attraction.
  • PDE Performance: On the KdV equation, a 38K parameter FNO eTTF model outperformed a massive 545K parameter 16-block FNO baseline.
  • System Identification: For the Advection-Diffusion PDE, the authors showed that the "fast weights" in the eTTF model actually converge to the true physical parameters (Péclet number) of the system during the forward pass.
Figure 3: In the forced Duffing oscillator, increasing loops from 1 to 32 allows the model to accurately capture the full chaotic attractor.

Limitations and Future Work

  • Computational Overhead: While parameter-efficient, looped models are computationally expensive. Training through many iterations requires significant memory and time, especially for eTTF models that need Hessian-vector products for backpropagation.
  • Inner Optimizer Complexity: The choice of inner optimizer (e.g., AdamW vs. GD) matters greatly. More sophisticated optimizers improve performance but further increase memory requirements due to state buffers.
  • Spatial Scaling: The current iTTF formulations are primarily temporal. A key future direction is developing iTTF update rules that are "spatially extended" to better handle complex, multi-dimensional PDE geometries.

Summary updated

BibTeX
@misc{lai2026test,
  author = {Jeffrey B. Lai and John Quinn and Anthony Bao and William Gilpin},
  title = {{Test-Time Forecasting: Recurrent Depth Enables In-Context Dynamics Prediction}},
  year = {2026},
  eprint = {2610.19552},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.19552},
}
Figure