Constrained Policy Optimization via Bayesian World Models

Yarden As, Ilnura Usmanova, Sebastian Curi, Andreas Krause

Constrained Policy Optimization via Bayesian World Models

LAMBDA is a novel model-based reinforcement learning (RL) agent that achieves state-of-the-art safety and sample efficiency by "dreaming" in a Bayesian world model. By combining optimistic exploration for rewards with pessimistic caution for safety constraints, LAMBDA solves complex tasks from raw pixels—such as navigating a "Doggo" robot—using up to 50x fewer environment interactions than traditional model-free methods while strictly adhering to safety limits.

What Problem Does This Paper Address?

Reinforcement learning agents are notoriously "crash-prone" during training. In real-world applications like robotics, we cannot afford to have an agent destroy itself or its environment while learning. This challenge is typically modeled as a Constrained Markov Decision Process (CMDP), where the agent must maximize a reward while keeping a "cost" (representing unsafe actions) below a specific threshold.

Existing solutions face two major hurdles:

  1. Sample Inefficiency: Model-free methods (like PPO-Lagrangian or CPO) require millions of interactions to learn, which is impractical and dangerous for physical hardware.
  2. The "Model-Exploitation" Trap: Model-based methods are faster because they learn a "world model" to simulate trajectories. However, if the model is slightly inaccurate, the agent might find a "cheat" in the simulation that leads to catastrophic failures in the real world.

Methods

The authors introduce LAMBDA (Lagrangian Model-Based Agent), which overcomes these hurdles using the following core components:

  • Bayesian World Model: Instead of learning a single "best guess" of how the world works, LAMBDA learns a distribution over possible models using SWAG (Stochastic Weight Averaging-Gaussian). This allows the agent to quantify its own uncertainty.
  • Optimism vs. Pessimism: This is the paper's core innovation. When planning its next move in its "imagination," LAMBDA applies a dual strategy:
  • It is optimistic about rewards: It picks the model that predicts the highest possible reward to encourage exploration.
  • It is pessimistic about safety: It picks the model that predicts the highest possible cost (risk) to ensure it stays far away from danger.
  • Augmented Lagrangian Optimization: To solve the constrained optimization problem, the authors use an Augmented Lagrangian method. Unlike standard Lagrangian methods that can be "jittery" or non-smooth, this approach provides a more stable numerical path for the agent to learn the trade-off between reward and safety.
  • RSSM Backbone: The underlying architecture uses the Recurrent State Space Model (RSSM), which is capable of learning complex dynamics directly from raw pixel observations (64x64 images).

Datasets and Environments

The researchers evaluated LAMBDA on the Safety-Gym SG6 benchmark, a suite of safety-critical environments.

Safety-Gym SG6 benchmark environments showing top-down and first-person pixel observations.
  • Robots: Includes "Point" (simple), "Car" (non-holonomic), and "Doggo" (a complex quadruped).
  • Tasks: Reaching goals, pushing boxes, or pressing buttons while avoiding obstacles like hazards, vases, and pillars.
  • Observations: The agent only sees first-person RGB images, making the task significantly harder than methods that use internal "proprioceptive" sensor data.

Key Insights

  • Safety through Imagination: LAMBDA learns what is "unsafe" by experiencing crashes in its internal world model rather than the real world. This "imaginary failure" is the key to its high safety record during actual deployment.
  • Uncertainty as a Safety Buffer: By using a Bayesian approach, the agent recognizes when it doesn't know if an area is safe. Its "pessimistic" logic forces it to assume the worst in these unknown regions, effectively creating a safety buffer around unexplored or complex states.
  • Efficiency of SWAG: While many Bayesian RL methods use "ensembles" (training 5-10 separate neural networks), LAMBDA uses SWAG. This is much cheaper in terms of memory and computation, making it feasible to use with large, parameter-heavy world models.

Key Results

LAMBDA demonstrates a massive leap forward in both safety and sample efficiency compared to existing baselines.

Normalized performance metrics comparing LAMBDA against baseline methods.
  • Perfect Safety Record: LAMBDA was the only agent across all tested benchmarks to satisfy safety constraints in every single task of the SG6 suite.
  • Massive Speedup: In the "DoggoGoal1" task (the most complex), LAMBDA reached a high-performing, safe policy in just 2 million steps. For comparison, the best model-free baselines required 100 million steps to reach similar performance, and even then, they often failed to stay within safety limits.
  • Superior to CEM-MPC: The authors showed that LAMBDA’s "actor-critic" style of planning outperforms online planning methods like CEM-MPC, which tend to be short-sighted and fail to account for long-term credit assignment.

Limitations and Future Work

  • Partial Observability: LAMBDA struggled with the "PointPush1" task. Because the agent relies on visual input, the box the robot pushes often blocks its view of the goal, causing it to "forget" the goal's location. Better memory mechanisms or different sensor modalities (like pseudo-LiDAR) might be needed.
  • Computational Bottleneck: While LAMBDA is highly sample-efficient, it is computationally intensive. Training the world model and performing gradient steps through "imaginary" trajectories takes significant GPU time.
  • Initial Safety: While LAMBDA is safer during training than other methods, it still needs to experience some initial real-world interactions to build its model. Integrating prior knowledge (like a map or a rulebook) so the agent never has to crash in the real world remains an open question.

Summary updated

BibTeX
@inproceedings{as2022constrained,
  author = {Yarden As and Ilnura Usmanova and Sebastian Curi and Andreas Krause},
  title = {{Constrained Policy Optimization via Bayesian World Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=PRZoSmCinhf},
}
Figure