Safe Distributional Reinforcement Learning

Jianyi Zhang, Paul Weng

Abstract

This paper introduces Safe Distributional Policy Optimization (SDPO), a framework that combines the risk-awareness of distributional reinforcement learning (RL) with the constraint-satisfaction of safe RL. By learning the entire distribution of future rewards and costs—rather than just their averages—the authors enable agents to satisfy complex safety constraints, such as minimizing tail-end risks or variance, both during training and at execution.

Introduction

Standard reinforcement learning focuses on maximizing the expected (average) sum of rewards. However, in high-stakes domains like autonomous driving or finance, average performance is insufficient; avoiding catastrophic failures is paramount.

Existing "Safe RL" methods typically utilize Constrained Markov Decision Processes (CMDPs) to ensure that the expected cost stays below a threshold. However, this approach has two major gaps:

  1. Risk Sensitivity: It ignores the "shape" of the risk. Two policies might have the same average cost, but one might have a small chance of a total disaster, while the other has a consistent, manageable cost.
  2. Constraint Complexity: Many current algorithms struggle with non-linear safety constraints, such as limiting the variance of returns or the Conditional Value-at-Risk (CVaR)—a measure of the "worst-case" scenarios.

Methods

The authors propose SDPO, which merges two powerful ideas:

  • Distributional RL (via Implicit Quantile Networks): Instead of learning a single value for a state, the agent learns the full probability distribution of possible returns. This makes it mathematically natural to calculate risk measures like CVaR or variance.
  • Interior-Point Policy Optimization (IPO): To handle constraints, the authors use a "log barrier" function. This transforms a constrained optimization problem into an unconstrained one by adding a penalty that grows infinitely as the agent approaches a safety limit.
The SDPO architecture connects the actor network directly to distributional critics, allowing for automatic differentiation of complex risk measures.

To calculate gradients for non-linear risk constraints, the authors connect the actor network directly to the distributional critic. This allows them to use automatic differentiation to update the policy in a way that explicitly accounts for complex risk measures.

Experimental Evaluation

The researchers evaluated SDPO across three distinct environments:

  1. Random CMDPs: Synthetically generated environments used to test basic convergence and the ability to handle variance and CVaR constraints.
  2. Safety Gym: A high-dimensional robotics benchmark where agents must navigate to goals while avoiding obstacles and hazards.
  3. Financial Investment: A real-world application using 2019 stock market data (S&P 500). The agent manages a portfolio with the goal of maximizing profit while strictly limiting the risk of loss (CVaR).

Key Results

SDPO demonstrated superior performance in both safety and efficiency:

  • Superior Constraint Satisfaction: In Safety Gym, SDPO successfully stayed within safety bounds during training, whereas older methods like Constrained Policy Optimization (CPO) often violated constraints as task complexity increased.
  • Faster Convergence: Compared to IPO (the non-distributional version of this approach), SDPO often converged to a safe policy faster and achieved higher total rewards.
  • Real-World Utility: In financial simulations, SDPO agents managed to generate profit while strictly adhering to risk-aversion levels. Agents with tighter risk constraints showed smoother, less volatile profit curves compared to unconstrained PPO.
Comparison of SDPO against PPO and PD-CVaR/PD-VAR baselines, showing rewards and constraint satisfaction for both CVaR and Variance constraints.

Conclusion

SDPO demonstrates that learning the full distribution of returns is a requirement for sophisticated safety. Because it relies on differentiable functions of the distribution, it can handle almost any safety definition. While it requires a feasible starting point and carries higher computational overhead than scalar methods, its ability to manage tail-end risks makes it a significant step forward for reliable RL in the real world.

Summary updated

BibTeX
@inproceedings{zhang2021safe,
  author = {Jianyi Zhang and Paul Weng},
  title = {{Safe Distributional Reinforcement Learning}},
  booktitle = {DAI},
  year = {2021},
  url = {https://openreview.net/forum?id=iwoAFG7cNg},
}
Figure