Reward-Consistent Dynamics Models are Strongly Generalizable for Offline Reinforcement Learning

Fan-Ming Luo, Tian Xu, Xingchen Cao, Yang Yu

Abstract

Learning a precise dynamics model can be crucial for offline reinforcement learning, which, unfortunately, has been found to be quite challenging. Dynamics models that are learned by fitting historical transitions often struggle to generalize to unseen transitions. In this study, we identify a hidden but pivotal factor termed dynamics reward that remains consistent across transitions, offering a pathway to better generalization. Therefore, we propose the idea of reward-consistent dynamics models: any trajectory generated by the dynamics model should maximize the dynamics reward derived from the data. We implement this idea as the MOREC (Model-based Offline reinforcement learning with Reward Consistency) method, which can be seamlessly integrated into previous offline model-based reinforcement learning (MBRL) methods. MOREC learns a generalizable dynamics reward function from offline data, which is subsequently employed as a transition filter in any offline MBRL method. On 21 offline tasks in D4RL and NeoRL benchmarks, MOREC improves the previous state-of-the-art performance by a significant margin, i.e., 4.6% on D4RL tasks and 25.9% on NeoRL tasks.

Introduction

In Offline Reinforcement Learning (RL), agents must learn optimal behaviors from a fixed dataset without any environment interaction. Model-Based approaches (MBRL) attempt this by learning a "dynamics model"—essentially a simulator of the environment.

The primary challenge in MBRL is generalization error. Dynamics models are usually trained via supervised learning to fit historical transitions. However, when a learning policy deviates from the data (visiting "out-of-distribution" states), the model often produces unrealistic transitions. These errors compound over long horizons, leading the policy to exploit "hallucinated" rewards in the simulator that do not exist in the real world. MOREC (Model-based Offline reinforcement learning with REward Consistency) addresses this by learning a hidden "dynamics reward" function to filter model-generated transitions.

Methodology

The authors introduce the concept of Reward-Consistent Dynamics Models. They hypothesize that there is an underlying "dynamics reward"—a hidden factor that remains consistent across all transitions—representing the "driving forces" of the environment's physics. The core MOREC method consists of three main stages:

  1. Dynamics Reward Learning: Instead of just predicting the next state, MOREC uses Inverse Reinforcement Learning (IRL) to learn a reward function that distinguishes "true" transitions (from the data) from "false" ones (generated by a flawed model).
  2. Transition Filtering: During policy training, when the dynamics model predicts the next state, it generates a batch of candidate transitions and uses the learned dynamics reward to select the most "realistic" one via a softmax distribution.
  3. Early Termination: If the dynamics reward for a predicted state falls below a certain threshold, the rollout is terminated immediately to prevent the agent from learning from "garbage" data.
The three-stage pipeline of MOREC: Model Learning, Model Simulation with Transition Filtering, and Policy Updating.

Experimental Setup

The researchers evaluated MOREC across three distinct environments:

  • Synthetic Refrigerator Task: A custom temperature-control simulation used primarily for visualizing how the dynamics reward generalizes to unseen regions.
  • D4RL Benchmark: The standard industry benchmark for offline RL, featuring 12 locomotion tasks (Hopper, HalfCheetah, Walker2d) with varying data quality.
  • NeoRL Benchmark: A more difficult benchmark containing 9 tasks with narrower, more "near-real-world" data distributions, where generalization is significantly harder.

Key Insights and Results

A pivotal finding is that the dynamics reward function generalizes much better than the dynamics model itself. Even in regions where the model's predictions are shaky, the reward function can still accurately identify which transitions are physically plausible. By treating the environment's dynamics as an "agent" trying to maximize this reward, the paper uses IRL tools to "decode" the laws of the environment.

Visualization of dynamics reward generalization on a synthetic task, showing its ability to identify plausible transitions even where model error is high.

Key performance highlights include:

  • State-of-the-Art Performance: MOREC outperformed previous SOTA methods on 18 out of 21 tasks.
  • Significant Gains: It improved average performance by 4.6% on D4RL and 25.9% on NeoRL.
  • High Fidelity: MOREC is the first method to achieve over 95% of the performance of an online RL agent in 6/12 D4RL tasks and 3/9 NeoRL tasks.
  • Error Reduction: On HalfCheetah tasks, MOREC reduced the maximum transition error (MAE) by several orders of magnitude compared to models without transition filtering.

Conclusion

MOREC demonstrates that reward consistency is a powerful tool for stabilizing offline MBRL. While the method adds a slight computational overhead (roughly 12.4% increase in training time), the gains in generalization and performance are substantial. Future work may explore specialized IRL methods tailored specifically for learning environment dynamics rather than behavioral imitation.

Summary updated

BibTeX
@inproceedings{luo2024reward,
  author = {Fan-Ming Luo and Tian Xu and Xingchen Cao and Yang Yu},
  title = {{Reward-Consistent Dynamics Models are Strongly Generalizable for Offline Reinforcement Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=GSBHKiw19c},
}
Figure