Safety-Gymnasium: A Unified Safe Reinforcement Learning Benchmark

Jiaming Ji, Borong Zhang, Jiayi Zhou, Xuehai Pan, Weidong Huang, Ruiyang Sun, Yiran Geng, Yifan Zhong, Juntao Dai, Yaodong Yang

TL;DR

Safety-Gymnasium is a new, comprehensive benchmark for Safe Reinforcement Learning (SafeRL) that addresses the limitations of previous suites by offering a wide range of single and multi-agent tasks with direct MuJoCo support. Alongside the environment suite, the authors provide SafePO, a library of 16 state-of-the-art SafeRL algorithms, creating a unified toolkit for developing AI that can optimize performance while strictly adhering to safety constraints.

What Problem Does This Paper Address?

Reinforcement Learning (RL) has shown incredible potential, but its "trial-and-error" nature is a major hurdle for real-world deployment in safety-critical fields like autonomous driving or healthcare. Safe Reinforcement Learning (SafeRL) attempts to solve this by training agents to maximize rewards while staying within predefined safety boundaries (constraints).

However, the research community has lacked a standardized, modern, and diverse set of environments to evaluate these algorithms. The previous gold standard, OpenAI’s Safety Gym, was built on the now-deprecated mujoco-py library, making it difficult to install and limiting its performance. Furthermore, it lacked support for multi-agent scenarios and realistic vision-based tasks, which are essential for modern AI research.

Methods

The authors introduce Safety-Gymnasium, a suite built on the latest Gymnasium and MuJoCo frameworks. Key technical improvements include:

  • Direct MuJoCo Support: By eliminating the mujoco-py dependency, the suite is easier to install and achieves rendering speeds on CPUs that are twice as fast as the original Safety Gym.
  • Multi-Agent Support: It extends SafeRL to Constrained Markov Games (CMG), where multiple agents must coordinate while each respects its own safety constraints.
  • SafePO Library: A collection of 16 SafeRL algorithms (including CPO, PPO-Lag, and MACPO) implemented in a "single-file" style. This design choice makes the code highly readable and easy for researchers to modify or extend.
  • High-Dimensional Tasks: It incorporates Safety-DexterousHands, a suite based on the Isaac Gym engine that leverages GPU acceleration for complex tasks involving robotic hands.
Figure 2: Upper: The Single-Agent Robots of Gymnasium-based Environments. Lower: The Multi-Agent Robots of Gymnasium-based Environments.

Datasets

The paper introduces a massive variety of new environments rather than a static dataset:

  • Gymnasium-based Environments: Includes five single-agent robots (Point, Car, Racecar, Doggo, Ant) and five multi-agent robots (Ant, Half Cheetah, Humanoid, Hopper, Walker2D).
  • Tasks and Constraints: Agents face tasks like reaching goals or pushing objects while avoiding hazards, pillars, or moving "gremlins."
  • Vision-only Tasks: More realistic scenarios like "FormulaOne" and "BuildingButton" that require agents to learn directly from RGB or RGB-D image inputs.
  • Safety-DexterousHands: A specialized set of tasks for dual robotic hands, focusing on fine motor skills under joint and finger constraints.
A wide array of tasks and safety constraints are provided to challenge agents.

Key Insights and Ideas

  • The Safety-Performance Trade-off: The experiments confirm a fundamental tension: unconstrained algorithms (like standard PPO) achieve the highest rewards but frequently violate safety rules. SafeRL algorithms successfully trade off some reward to maintain safety.
  • Lagrangian Sensitivity: Lagrangian-based methods (which use a penalty term for safety violations) are powerful but extremely sensitive to hyperparameters. The authors found that incorporating a PID controller (CPPO-PID) can significantly reduce the oscillations common in these methods.
  • Algorithm Specialization: Second-order algorithms (which use more complex mathematical updates) tend to perform better in navigation tasks requiring high safety standards, whereas first-order methods often achieve higher rewards in simpler velocity-tracking tasks.
  • Stochasticity Breeds Instability: Navigation tasks characterized by high randomness (stochasticity) lead to much more performance oscillation across all algorithms compared to more deterministic velocity tasks.

Key Results

The authors conducted a massive evaluation of 16 algorithms across 54 environments.

  • Safety Compliance: SafeRL algorithms like PPO-Lag were able to reduce safety costs by up to 98% in velocity tasks compared to standard PPO, with a manageable 45% decrease in total reward.
  • SafePO Performance: The SafePO library implementations were shown to match or outperform existing open-source baselines, proving its reliability as a research tool.
  • Vision Tasks: The suite provides a much-needed benchmark for vision-only SafeRL, showing that agents can learn to navigate complex construction sites or race tracks using only visual input while avoiding obstacles.
Vision-only tasks provide a more realistic challenge for SafeRL agents.

Limitations and Future Work

While comprehensive, the authors acknowledge several limitations:

  • Human-Centric Safety: The current constraints are physical (e.g., don't hit a wall). Future work needs to integrate human-centric safety considerations for human-AI collaboration.
  • Sim-to-Real Gap: The benchmark is entirely simulated. The authors note that transferring these safe policies to physical robotic platforms is a critical next step.
  • Constraint Variety: The suite doesn't yet encompass every possible form of safety constraint found in the real world.

For those interested in exploring the benchmark, the project website and code are available at https://sites.google.com/view/safety-gymnasium.

Summary updated

BibTeX
@inproceedings{ji2023safety,
  author = {Jiaming Ji and Borong Zhang and Jiayi Zhou and Xuehai Pan and Weidong Huang and Ruiyang Sun and Yiran Geng and Yifan Zhong and Juntao Dai and Yaodong Yang},
  title = {{Safety-Gymnasium: A Unified Safe Reinforcement Learning Benchmark}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=TwSzpH7tT6},
}
Figure