Safety-constrained reinforcement learning with a distributional safety critic

Qisong Yang, Thiago D. Simão, Simon H. Tindemans, Matthijs T. J. SpaanMachine Learning 2023 · DOI

Abstract

Reinforcement Learning (RL) in real-world applications requires robust safety guarantees. Traditional safe RL methods typically constrain the expected safety cost, which fails to account for rare but catastrophic "tail" events. This paper introduces Worst-Case Soft Actor Critic (WCSAC), an algorithm that leverages distributional RL to model the entire safety cost distribution. By optimizing for the Conditional Value-at-Risk (CVaR), WCSAC ensures safety even in worst-case scenarios. Empirical evaluations on SpyGame and Safety Gym demonstrate that WCSAC, particularly the variant using Implicit Quantile Networks (WCSAC-IQN), provides superior risk control and sample efficiency compared to standard baselines.

Introduction

While Reinforcement Learning (RL) has demonstrated remarkable success in simulated environments, its deployment in safety-critical real-world domains remains challenging. Standard safe RL frameworks, such as Constrained Markov Decision Processes (CMDPs), typically focus on minimizing the expected safety cost. However, expectation is a risk-neutral metric that can ignore low-probability, high-impact events—the "heavy tails" of a distribution. For instance, a self-driving car that is safe on average but has a 1% chance of a high-speed collision is unacceptable. To address this, there is a critical need for risk-averse agents that prioritize safety in the worst-case scenarios.

Methodology: Distributional Safety Critics

The authors propose the Worst-Case Soft Actor Critic (WCSAC), building upon the off-policy Soft Actor Critic (SAC) algorithm. The core innovation is the introduction of a Distributional Safety Critic. Unlike traditional critics that predict a single scalar value for the expected cost, a distributional critic models the entire probability distribution of potential safety costs.

Comparison of the architectures for SAC-Lag, WCSAC-GS, and WCSAC-IQN.

The paper explores two primary architectural variants for modeling this distribution:

  1. WCSAC-GS (Gaussian): This variant assumes that safety costs follow a Gaussian distribution. It is computationally efficient but may fail to accurately represent complex, non-Gaussian risk profiles.
  2. WCSAC-IQN (Quantile Regression): Utilizing an Implicit Quantile Network (IQN), this approach learns the cost distribution without making parametric assumptions. This allows the agent to capture heavy-tailed or multimodal risks more effectively.

By modeling the full distribution, the agent can calculate the Conditional Value-at-Risk (CVaR), defined as the average cost of the worst $\alpha$% of cases. A Lagrangian multiplier is then used to adaptively weight the safety constraint, ensuring the policy prioritizes risk mitigation when the CVaR exceeds a predefined threshold.

Experimental Setup

The proposed methods were evaluated across two distinct environments:

  • SpyGame: A custom environment designed to test specific cost distributions, including Spy-Unimodal (Gaussian-like) and Spy-Bimodal (two-peaked, representing rare high-cost events).
  • Safety Gym: A high-fidelity benchmark for safe RL involving robot navigation (Point or Car) around hazards and obstacles in tasks like StaticEnv, PointGoal, and CarButton.

Key Results and Insights

The experimental results highlight several advantages of the WCSAC framework:

  • Superior Risk Control: In the complex CarButton environment, WCSAC-IQN was the only method to consistently satisfy risk-averse safety thresholds.
  • Handling Non-Gaussian Risk: In the Bimodal SpyGame, WCSAC-IQN maintained safety across all risk levels by accurately modeling the tail of the distribution. In contrast, the Gaussian approximation (WCSAC-GS) underestimated risk and failed as safety requirements became stricter.
  • Sample Efficiency: As an off-policy algorithm, WCSAC demonstrated significantly higher sample efficiency than on-policy baselines like CPO or PPO-Lagrangian, reaching safe policies with fewer training steps.
  • The Safety-Performance Trade-off: The results quantify the "safety tax"—the reduction in expected reward as risk-aversion increases. WCSAC provides a tunable parameter ($\alpha$) that allows designers to precisely balance safety and performance.

Conclusion and Future Work

WCSAC demonstrates that distributional RL is a powerful tool for safety-constrained learning. By explicitly modeling the "worst case" via CVaR, agents can navigate complex environments with greater reliability. However, several challenges remain. Current models do not guarantee safety during the initial exploration phase of training. Future research could integrate epistemic uncertainty—accounting for what the agent does not yet know—to further enhance safety during training and provide formal convergence proofs for distributional Lagrangian methods.

Summary updated

BibTeX
@article{yang2023safety,
  author = {Qisong Yang and Thiago D. Simão and Simon H. Tindemans and Matthijs T. J. Spaan},
  title = {{Safety-constrained reinforcement learning with a distributional safety critic}},
  journal = {Machine Learning},
  year = {2023},
  doi = {10.1007/s10994-022-06187-8},
}
Figure