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

Task-Aware Virtual Training: Enhancing Generalization in Meta-Reinforcement Learning for Out-of-Distribution Tasks

Jeongmo Kim, Yisak Park, Minung Kim, Seungyul Han

Abstract

Meta-reinforcement learning (meta-RL) aims to produce agents capable of rapid adaptation to novel tasks. However, standard context-based methods often fail when encountering out-of-distribution (OOD) scenarios. We present Task-Aware Virtual Training (TAVT), a framework that improves OOD generalization by combining metric-based representation learning with a generative approach for creating realistic virtual training tasks. TAVT ensures robust task inference by aligning latent representations with environment dynamics and rewards, significantly outperforming existing baselines on challenging benchmarks.

Introduction

The goal of meta-RL is to learn a policy that generalizes across a distribution of tasks. Context-based meta-RL typically achieves this by learning a "task latent"—a compressed representation of the environment's characteristics. While effective for tasks within the training distribution, these methods often collapse when faced with OOD tasks. Previous attempts to mitigate this via "virtual tasks" (VTs) generated through latent interpolation often produced inaccurate samples or failed to account for changes in transition dynamics (e.g., changes in an agent's mass). TAVT addresses these shortcomings through a multi-pronged approach focusing on representation accuracy and generative stability.

Methodology

TAVT introduces several key innovations to ensure that virtual training translates to real-world performance:

Bisimulation Metric for Latents

Instead of relying on standard reconstruction losses, TAVT utilizes a Bisimulation metric to train its task encoder. This metric quantifies task similarity based on both rewards and state transition dynamics. By doing so, it forces the latent space to reflect the actual physical properties of the tasks, such as goal angles or agent mass, rather than just superficial reward differences.

Task-Preserving Sample Generation

To generate high-quality virtual training data, TAVT employs a Wasserstein GAN (WGAN) framework. A task decoder acts as a generator to produce transitions that mimic real environment behavior. To ensure these virtual samples remain faithful to their intended task, a task-preserving loss is introduced. This loss ensures that the task encoder can correctly identify the intended virtual task from the generated samples.

State Regularization and Latent Alignment

To prevent the RL agent from exploiting inaccuracies in the generated virtual states—a phenomenon known as "delusion"—TAVT implements state regularization. This involves mixing generated next-states with real next-states from the training buffer, grounding the agent's Q-function. Additionally, an On-Off Latent Alignment mechanism uses stable off-policy latents to guide the learning of on-policy latents, ensuring consistent task inference during exploration.

Experimental Evaluation

TAVT was evaluated on several MuJoCo and MetaWorld benchmarks modified for OOD testing:

  • MuJoCo OOD: Tasks included target velocity extrapolation (Cheetah-Vel-OOD), new direction adaptation (Ant-Dir), and varying physical properties (Hopper-Mass-OOD, Walker-Mass-OOD).
  • MetaWorld ML1: Robotic manipulation tasks (Reach and Push) where goal positions were placed in unseen "inter" (unseen middle) or "extra" (unseen outer) regions.

Key Insights: Latent Space Geometry

A critical finding of this work is that the Bisimulation metric produces a geometrically intuitive latent space. In velocity-based tasks, latents align linearly with target speed; in directional tasks, they form a circular structure matching physical angles. This structured representation is essential for successful interpolation and extrapolation to OOD tasks. Furthermore, TAVT uses these virtual tasks as exploration guides, encouraging the agent to sample trajectories that cover a wider range of the task space than standard Gaussian exploration.

Comparison of latent space visualizations across different meta-RL methods. TAVT (e) shows a highly structured and task-aligned latent space compared to PEARL (b), CCM (c), and VariBad/LDM (d).

Results

TAVT significantly outperformed state-of-the-art baselines, including PEARL, VariBad, and LDM. In many MuJoCo scenarios, TAVT's performance approached that of an "Oracle" trained specifically on the test tasks. Notably, in environments with changing physics (Walker-Mass and Hopper-Mass), TAVT maintained high performance where previous virtual-task methods failed. In the MetaWorld Push-OOD-Extra task, TAVT achieved a 92% success rate, compared to 83% for the next best method (Amago) and 55% for PEARL.

Conclusion and Future Work

TAVT demonstrates that combining structured latent representations with task-preserving generative models can bridge the gap in OOD generalization for meta-RL. While highly effective for parametric task shifts (like mass or velocity), future work will explore extending TAVT to non-parametric shifts—such as moving between entirely different task semantics—by integrating task decomposition methods.

Summary updated

BibTeX
@inproceedings{kim2025task,
  author = {Jeongmo Kim and Yisak Park and Minung Kim and Seungyul Han},
  title = {{Task-Aware Virtual Training: Enhancing Generalization in Meta-Reinforcement Learning for Out-of-Distribution Tasks}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=WjCpaV6N8q},
}
Figure