Out-of-Distribution Adaptation in Offline RL: Counterfactual Reasoning via Causal Normalizing Flows

Minjae Cho, Jonathan P. How, Chuangchuang SunarXiv 2024

This paper, titled "Out-of-Distribution Adaptation in Offline RL: Counterfactual Reasoning via Causal Normalizing Flows," presents a novel framework for offline reinforcement learning (RL) that moves beyond simple data imitation toward true environment adaptation.

TL;DR

MOOD-CRL leverages Causal Normalizing Flows to build a world model capable of counterfactual reasoning, allowing offline RL agents to accurately predict outcomes in regions of the state-action space never seen during training. By combining physics-informed causal graphs with exact likelihood estimation, the method enables agents to discover high-reward trajectories beyond the original dataset while avoiding the catastrophic overestimation typical of standard offline methods.

What Problem Does This Paper Address?

Offline RL is the practice of training agents on static, pre-collected datasets without any live interaction with the environment. This is essential for safety-critical fields like autonomous driving or healthcare, where "trial and error" is too dangerous.

The primary hurdle is distributional shift: when an agent encounters a state or action not present in its training data (Out-of-Distribution, or OOD), standard neural networks often produce wildly inaccurate, overly optimistic predictions. To counter this, most current algorithms use conservatism—they strictly penalize the agent for straying from the known data. While safe, this is sub-optimal; it prevents the agent from ever discovering better strategies that might lie just outside the "support" of the provided dataset.

Methods

The authors introduce MOOD-CRL (Model-based Offline OOD-Adapting Causal RL). Its core components include:

  • Causal Normalizing Flows (CNF): Normalizing Flows are generative models that transform simple distributions into complex ones using bijective (invertible) mappings. The authors "causalize" these flows by applying masks based on a qualitative causal graph (e.g., knowing that force causes a change in velocity). This ensures the model learns physical cause-and-effect rather than spurious correlations.
  • Counterfactual Reasoning: By learning the underlying structural causal model, the agent can perform counterfactual reasoning—asking "what would happen if I took this action?" even if that action was never taken in the original data.
  • Base-Space Mapping: Because RL dynamics (mapping a state and action to a next state) are not naturally bijective, the authors propose a novel architecture that performs the "heavy lifting" of prediction in the latent base space of the Normalizing Flow.
  • Likelihood-Based Truncation: Instead of using a hard reward penalty for OOD states, MOOD-CRL uses the exact likelihood quantification of Normalizing Flows to detect when a prediction is unreliable. If the log-probability of a state-action pair falls below a threshold, the simulated episode is truncated, preventing the policy from learning from "false beliefs."
Causal relationships in an Inverted Pendulum environment
Figure 1: The model uses physics-informed causal graphs to structure its learning.

Datasets

The researchers evaluated MOOD-CRL across several standard benchmarks:

  • FrozenLake: A discrete toy problem used to demonstrate the model's superior predictive power in OOD scenarios compared to standard MLPs.
  • MuJoCo Environments: Continuous robotic control tasks including InvertedPendulum, Hopper, Walker, and HalfCheetah.
  • Data Quality Tiers: They specifically tested on "low-quality" data (early-stage exploration) and "medium-quality" data to see if the agent could adapt and find optimal policies that outperformed the best trajectories in the training set.

Key Insights and Ideas

  • Causality is the Key to Extrapolation: Standard deep learning excels at interpolation (filling gaps within data) but fails at extrapolation. By embedding physical laws into the model architecture via causal masking, the authors allow the model to generalize to unseen scenarios more reliably.
  • Moving Beyond Conservatism: Most offline RL is "pessimistic." MOOD-CRL argues that if your world model is grounded in causality and provides a reliable measure of its own uncertainty (likelihood), you don't need to be purely pessimistic; you can be adaptive.
  • Bijective World Modeling: The paper overcomes the structural constraints of Normalizing Flows (which require input and output dimensions to match) by using a "perturbed tuple" approach, effectively turning a generative model into a predictive one.

Key Results

MOOD-CRL significantly outperformed state-of-the-art baselines like MOPO (model-based) and OptiDICE (model-free).

  • Performance: In many tasks, MOOD-CRL's learning curve closely mirrored or even matched the performance of online RL agents, despite only having access to offline data.
  • OOD Accuracy: In the FrozenLake test, MOOD-CRL maintained low error rates in OOD regions where standard MLPs failed completely.
  • Robustness: Unlike MOPO, which often failed in environments like InvertedPendulum due to overly restrictive OOD constraints, MOOD-CRL successfully navigated these regions to find optimal rewards.
Fig. 2: A depiction of Causal Reinforcement Learning employ- ing a normalizing flow world model. The system handles two MDP tuples: the first is an arbitrary input for counterfactual reasoning, involving the use of state and action as inputs, initializing the next state with the current state for stability, and setting the reward to zero for initialization. The second tuple represents the original scenario. Subsequently, we calculate the loss between these tuples in the base space and train the mapping function.
Figure 2: MOOD-CRL (red) consistently outperforms baselines and rivals online learning (blue).

Limitations and Future Work

  • Scalability: The computational cost of passing entire MDP tuples through a Normalizing Flow increases significantly as the state and action dimensions grow (the "curse of dimensionality").
  • Theoretical Foundations: While empirical results are strong, the authors note a lack of formal theoretical proofs for the adaptation limits of this specific architecture.
  • Future Directions: The authors suggest integrating these causal mechanisms with more complex architectures like Transformers or RNNs and exploring "neuro-symbolic" RL that combines data-driven learning with explicit logic rules for even better extrapolation.

Summary updated

BibTeX
@misc{cho2024out,
  author = {Minjae Cho and Jonathan P. How and Chuangchuang Sun},
  title = {{Out-of-Distribution Adaptation in Offline RL: Counterfactual Reasoning via Causal Normalizing Flows}},
  year = {2024},
  eprint = {2405.03892},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.03892},
}
Figure