In the field of Reinforcement Learning (RL), offline datasets are invaluable resources that allow agents to learn from historical experiences without the costs or risks associated with real-world trials. However, a significant hurdle remains: Shifted Dynamics. This occurs when the transition physics in the offline data (e.g., a robot on a smooth floor) differ from the target online environment (e.g., the same robot on a rug). Most existing methods struggle with this mismatch because they rely on mathematical tools that fail when the old and new environments do not perfectly overlap.
Researchers from Harvard University have introduced COMPFLOW, a principled framework that leverages the geometric properties of "Flow Matching" to bridge this gap. By stacking generative models, COMPFLOW provides a stable, Wasserstein-based estimate of the dynamics gap, enabling smarter data utilization and targeted exploration.
The Challenge of Mismatched Support
The core difficulty in handling shifted dynamics is accurately measuring the "distance" between the offline and online physics. Traditional metrics like KL divergence or mutual information are notoriously brittle. If the offline data suggests a specific state transition is impossible, but the online environment allows it, the KL divergence becomes infinite or ill-defined—a problem known as mismatched support. This instability makes it difficult to filter unreliable offline data or to identify where the agent needs to focus its online learning efforts.
The COMPFLOW Framework
COMPFLOW addresses these issues by utilizing Flow Matching (FM), a generative modeling technique that learns to transport a simple distribution to a complex target distribution via a vector field. The framework introduces a Composite Flow architecture:
- Offline Flow: A conditional flow model is trained to map a simple Gaussian distribution to the transitions observed in the offline dataset.
- Online Flow (The Composite Step): Instead of learning online dynamics from scratch, a second flow model is built using the output of the offline flow as its starting point. This allows the model to learn only the "delta" or the difference between the two environments.
- Wasserstein Gap Estimation: Due to the theoretical connection between flow matching and Optimal Transport, the displacement distance of the online flow provides a direct, stable estimate of the 2-Wasserstein distance between offline and online dynamics.
Dual-Action Strategy for RL
With a reliable estimate of the dynamics gap, COMPFLOW employs a two-pronged strategy to optimize learning:
- Data Filtering: During training, the agent selectively uses offline transitions where the estimated dynamics gap is low, ensuring it doesn't learn from misleading physics.
- Optimistic Exploration: The agent is given an "exploration bonus" for visiting regions where the dynamics gap is high. This encourages the agent to actively investigate and resolve its ignorance in areas where the offline data is most inaccurate.
Experimental Evaluation and Results
The researchers evaluated COMPFLOW against several state-of-the-art baselines, including H2O and BC-PAR, across 27 benchmark tasks. These included standard Gym-MuJoCo locomotion tasks modified with morphology, kinematic, and friction shifts, as well as a high-stakes Wildlife Conservation simulator modeling poaching risks in Uganda.
Key findings include:
- Superior Performance: COMPFLOW outperformed or matched baselines on 24 out of 27 tasks, achieving a 14.2% relative improvement over the strongest baseline.
- Efficiency: Compared to learning from scratch (SAC), COMPFLOW showed a 149.8% improvement, demonstrating the power of effectively leveraging offline data.
- Computational Speed: Thanks to the linear-path ODE structure of flow matching, the filtering process is highly efficient, taking only 0.03 seconds per batch on an A100 GPU.
Conclusion and Future Directions
COMPFLOW provides a robust geometric solution to the problem of shifted dynamics in RL. By learning the difference between environments rather than relearning physics from scratch, it offers a sample-efficient path to deployment. While currently limited to environments sharing the same state and action spaces, future work may explore cross-morphology transfer and incorporating Bayesian uncertainty into the gap estimates to further enhance safety in critical applications.
Summary updated