Temporal Difference Flows

Jesse Farebrother, Matteo Pirotta, Andrea Tirinzoni, Remi Munos, Alessandro Lazaric, Ahmed Touati

Predictive models of the future are fundamental for an agent's ability to reason and plan in Reinforcement Learning (RL). The standard approach involves learning a "world model" that predicts the immediate next state and unrolling it step-by-step during inference. However, this method suffers from the "curse of horizon": tiny errors in each one-step prediction rapidly compound over time, rendering long-term planning unreliable.

Geometric Horizon Models (GHMs) offer a compelling alternative. Instead of predicting just the next step, GHMs are generative models that directly predict the discounted distribution of all future states (the "successor measure"). While GHMs can be trained using Temporal Difference (TD) learning—bootstrapping off their own predictions—training generative models like GANs or VAEs with TD bootstrapping is notoriously unstable. As the prediction horizon grows, the variance of the gradients explodes, causing existing GHMs to fail at predicting beyond 20 to 50 steps into the future.

This paper introduces Temporal Difference Flows (TD-Flow), a novel method that leverages flow matching and a new Bellman equation on probability paths to drastically reduce gradient variance, enabling stable, high-quality predictions at over 5x the horizon length of prior methods.

Bootstrapping the Vector Field

The authors propose using modern iterative generative models—specifically Flow Matching (FM) and Denoising Diffusion (DD)—to model future states. However, simply plugging a flow matching model into a TD learning loop (a naive approach termed TD-CFM) still suffers from high variance.

To resolve this, they introduce $\text{TD}^2$-CFM (and its diffusion counterpart, $\text{TD}^2$-DD). The core innovation lies in how the bootstrapping is applied.

Comparison of TD-CFM, Coupled TD-CFM, and the proposed TD²-CFM methods.

In standard TD generative training, the model generates a bootstrapped future state and trains the network to map noise to that specific sample. In contrast, the $\text{TD}^2$ approach derives a novel Bellman equation on probability paths. Instead of just bootstrapping the sample, it allows the model to bootstrap the vector field (in flow matching) or the score function (in diffusion) directly in the loss function. By regressing the network's predicted vector field directly against the target network's vector field, $\text{TD}^2$-CFM mathematically guarantees convergence to the true successor measure while drastically cutting down the computational variance that normally destabilizes long-horizon TD learning.

Key Theoretical Insights

  • Variance is the bottleneck: Theoretical analysis proves that instability in long-horizon GHMs stems from the variance of the samples generated by the algorithm itself during training. Bootstrapping the vector field ($\text{TD}^2$) bypasses this extra variance.
  • Path geometry matters: In flow matching, the "path" that noise takes to become data can be chosen (e.g., straight vs. curved). For naive TD-CFM, curved paths degrade performance. For $\text{TD}^2$-CFM, curved paths actually improve performance, demonstrating the robustness of the formulation.
  • Unification of Flow and Diffusion: The mathematical principles used to fix Flow Matching for TD learning seamlessly extend to Denoising Diffusion models, creating a unified framework.

Empirical Results

The authors evaluated their methods on 22 continuous control tasks across 4 domains from the DeepMind Control Suite (Maze, Walker, Cheetah, Quadruped), leveraging 10 million transitions from the ExoRL dataset for offline training.

Unprecedented Horizon Scaling

$\text{TD}^2$-based methods maintain high accuracy even at an effective horizon of 100 steps ($\gamma=0.99$). At this extended horizon, $\text{TD}^2$ methods achieve Value Function Mean Squared Errors (MSE) nearly four orders of magnitude lower than naive implementations and prior baselines like TD-GAN or TD-VAE.

Scaling effective horizon shows TD² methods maintaining low Value Function MSE at 100 steps compared to baselines.

Powerful Zero-Shot Planning

Beyond generative metrics like Earth Mover's Distance (EMD) and Negative Log-Likelihood (NLL), where $\text{TD}^2$-CFM consistently achieves state-of-the-art results, the model excels in downstream tasks. Integrating $\text{TD}^2$-CFM with Forward-Backward (FB) representations to perform Generalized Policy Improvement (GPI) yielded a roughly 30%+ performance improvement over base FB policies. In contrast, standard FB-GPI often degraded performance due to compounding errors.

Limitations and Future Directions

While TD-Flow significantly advances long-horizon prediction, it faces challenges with inference speed. Because it relies on flow matching and diffusion, generating samples requires iteratively solving an Ordinary Differential Equation (ODE) or Stochastic Differential Equation (SDE), making it computationally more expensive than one-step models.

Future work may address this sampling speed by exploring consistency models or self-distillation techniques, which have successfully accelerated standard diffusion models. Additionally, TD-Flow shows strong promise for future applications in imitation learning, exploration, and off-policy evaluation.

Summary updated

BibTeX
@inproceedings{farebrother2025temporal,
  author = {Jesse Farebrother and Matteo Pirotta and Andrea Tirinzoni and Remi Munos and Alessandro Lazaric and Ahmed Touati},
  title = {{Temporal Difference Flows}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=j6H7c3aQyb},
}
Figure