DynaMITE-RL: A Dynamic Model for Improved Temporal Meta-Reinforcement Learning

Anthony Liang, Guy Tennenholtz, ChihWei Hsu, Yinlam Chow, Erdem Biyik, Craig Boutilier

In the world of Reinforcement Learning (RL), we often assume the "rules of the game"—the rewards and physics—stay the same throughout an episode. But real life is rarely that cooperative. A user’s preferences in a recommender system evolve; a robot’s joints wear down over time; a gust of wind changes the dynamics of a drone mid-flight.

Standard Meta-RL algorithms struggle here because they usually assume the "latent context" (the hidden factors defining the task) is static within an episode. At NeurIPS 2024, researchers introduced DynaMITE-RL, a new approach designed specifically for environments where the ground truth shifts while the agent is still acting.

TL;DR

DynaMITE-RL is a meta-reinforcement learning framework that handles environments where hidden task variables change at varying rates. By modeling episodes as a sequence of "sessions" with fixed contexts and enforcing consistency within those sessions, it significantly outperforms state-of-the-art baselines in both online and offline settings.

What Problem Does This Paper Address?

Most Meta-RL agents (like the popular VariBAD) are "Bayes-optimal" under the assumption that the task is fixed for the duration of an episode. They spend the beginning of an episode exploring to identify the task and the rest exploiting that knowledge.

However, if the task changes mid-episode (a "non-stationary" environment), these agents get confused. They try to find a single latent vector that explains the entire trajectory, which often results in an "average" policy that performs poorly for every specific task state. The authors identify a gap: we need a way to model Dynamic Latent Contextual MDPs (DLCMDPs)—environments where the latent state remains fixed for a "session" and then transitions to a new state.

Illustration of an episode divided into sessions, where the latent context remains fixed within each session.

Methods

The authors propose three key modifications to the standard variational Meta-RL pipeline to handle these shifting sessions:

  1. Prior Latent Conditioning: Unlike static models, DynaMITE-RL explicitly learns a transition function for the latent state itself. It predicts how the hidden context ($m$) will evolve from one session to the next.
  2. Consistency of Latent Information: Within a single session, the environment is stationary. DynaMITE-RL introduces a consistency loss that penalizes the agent if its belief about the latent state fluctuates wildly or fails to "hone in" on a stable estimate during these stationary periods.
  3. Session Reconstruction Masking: Standard models try to reconstruct the entire history using the current belief. DynaMITE-RL uses "masking" to ensure the model only tries to reconstruct transitions that occurred within the same latent session. This prevents information from a previous, irrelevant context from "bleeding" into and biasing the current belief.

The architecture uses a recurrent encoder (like an RNN or Transformer) to maintain a belief state and a decoder to reconstruct rewards and transitions for training.

Datasets and Benchmarks

The researchers evaluated DynaMITE-RL across a diverse suite of environments modified to include temporal shifts:

  • Gridworld Alternate: A 5x5 navigation task where the rewarding goal swaps between two locations mid-episode.
  • MuJoCo Continuous Control: Standard benchmarks like Reacher and HalfCheetah were modified. For example, in HalfCheetah-Vel, the target velocity changes according to a sine wave, and in HalfCheetah-Wind, external forces are added and removed.
  • Assistive Itch Scratching: A high-dimensional robot arm task from the Assistive-Gym benchmark where a robot must find and scratch an "itch" on a human arm, but the itch location moves stochastically.

Key Insights and Ideas

  • Reconstruction can be a Double-Edged Sword: In static Meta-RL, reconstructing the whole past helps the agent learn. In dynamic settings, the authors found that trying to explain the entire past with the current belief is actually detrimental because the past might have been governed by a completely different set of rules.
  • The "Session" Inductive Bias: By formalizing the environment as a series of sessions, the model gains a powerful inductive bias. It learns to recognize when a "break" has occurred and resets its expectations accordingly.
  • Robustness to Stochasticity: One of the most interesting findings was an ablation study on the frequency of context switches. DynaMITE-RL remained performant even as the environment became more chaotic, whereas baselines like VariBAD saw their performance collapse as soon as the "one task per episode" assumption was violated.

Key Results

  • Superior Performance: DynaMITE-RL achieved the highest average returns across all tested environments, often by a massive margin. In the Reacher task, it achieved a return of -8.4 compared to VariBAD’s -102.4.
Gridworld trajectories demonstrating DynaMITE-RL (orange) adapting to a changing goal mid-episode, while VariBAD (blue) fails.
  • Sample Efficiency: The model converges to a high-performing policy much faster than baselines, which often get "stuck" in suboptimal behaviors because they cannot reconcile the changing dynamics.
  • Offline Success: The benefits aren't limited to online learning. When trained on static datasets (Offline RL) using the IQL algorithm, DynaMITE-RL’s objectives helped it learn a more accurate posterior belief model than the previous state-of-the-art, BORel.

Limitations and Future Work

The authors acknowledge a few areas for growth:

  • Markovian Assumption: The current model assumes latent dynamics are Markovian (the next context only depends on the current one). Real-world scenarios might involve long-term dependencies or non-Markovian shifts.
  • Hierarchical Contexts: The paper focuses on a single level of latent change. Future work could explore hierarchical contexts where some factors change every few seconds while others change every few hours.
  • Scalability: While tested on complex robot simulations, moving to massive-scale real-world recommender systems or fleet-wide robot learning remains an open challenge.

DynaMITE-RL represents a significant step toward RL agents that don't just solve a task, but understand the rhythm of a changing world.

Summary updated

BibTeX
@inproceedings{liang2024dynamite,
  author = {Anthony Liang and Guy Tennenholtz and ChihWei Hsu and Yinlam Chow and Erdem Biyik and Craig Boutilier},
  title = {{DynaMITE-RL: A Dynamic Model for Improved Temporal Meta-Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=OPrPegYIZo},
}
Figure