OmniSafe: An Infrastructure for Accelerating Safe Reinforcement Learning Research

Jiaming Ji, Jiayi Zhou, Borong Zhang, Juntao Dai, Xuehai Pan, Ruiyang Sun, Weidong Huang, Yiran Geng, Mickel Liu, Yaodong YangarXiv 2023 · DOI

Abstract

OmniSafe is a comprehensive, modular, and high-performance framework designed to streamline research in Safe Reinforcement Learning (SafeRL). By providing a unified infrastructure for dozens of algorithms—ranging from on-policy to offline methods—it bridges the gap between complex safety theory and practical, reproducible implementation.

Introduction

Reinforcement Learning (RL) has demonstrated significant potential in domains like robotics and gaming. However, its inherent "trial-and-error" nature poses substantial risks in safety-critical applications such as autonomous driving or healthcare. SafeRL addresses this by training agents to maximize rewards while strictly adhering to safety constraints.

Despite its importance, SafeRL is notoriously difficult to implement, requiring the integration of RL with constrained optimization and control theory. This has led to a fragmented research landscape with outdated or non-modular codebases. OmniSafe aims to establish a "gold standard" library, similar to what Stable-Baselines3 provides for standard RL, specifically tailored for the complexities of safety.

System Architecture

The design of OmniSafe prioritizes high modularity and performance to facilitate rapid research iteration.

The Adapter & Wrapper Pattern

To manage structural differences between various safety paradigms (e.g., Constrained MDPs vs. SauteMDPs), OmniSafe introduces "Adapters." These components reconcile data flow into the algorithms. Complementing this, "Wrappers" handle variability in environment dynamics, ensuring the framework remains highly extensible.

Parallelized Acceleration

Leveraging torch.distributed, OmniSafe supports process-level parallelism. This architecture enables asynchronous environment interaction and agent learning, significantly accelerating training compared to traditional single-threaded frameworks.

OmniSafe's modular dataflow and parallelized training architecture.

Algorithm Library

OmniSafe implements a vast registry of algorithms across multiple domains, standardizing mathematical notation to lower the barrier for researchers. The library includes on-policy, off-policy, model-based, and offline methods, as well as alternative MDP formulations like SauteRL and SimmerRL.

Comprehensive registry of SafeRL algorithms supported by OmniSafe categorized by domain and type.

Evaluation and Benchmarking

OmniSafe is primarily evaluated on two major SafeRL benchmarks: Safety-Gymnasium (an updated suite for goal navigation with obstacles) and Mujoco-Velocity (MuJoCo tasks with velocity constraints).

Key Results

  • Benchmarking Superiority: In Safety-Gym tasks, OmniSafe's implementations frequently achieved higher rewards while maintaining lower safety violation costs compared to standard baselines like Tianshou or Stable-Baselines3.
  • Reliability and Robustness: The framework maintains consistent parameter sets across environments, demonstrating that its implementations are robust rather than over-tuned.
  • Efficiency: The parallelized backend enables significantly faster iteration cycles, essential for compute-intensive SafeRL research.

Discussion

A core innovation of OmniSafe is the decoupling of the safety paradigm from the algorithm via the "Adapter" design. This allows researchers to switch safety logic (e.g., from Lagrangian penalties to state-augmentation) with minimal code changes. Furthermore, the "Experiment Grid" tool facilitates large-scale, multi-seed experiments with automated statistical analysis.

Limitations and Future Directions

While OmniSafe provides a robust foundation, challenges remain in transitioning "safe" policies from simulation to real-world hardware. Future work will focus on expanding the library to include formal methods, reachability analysis, and further standardizing diverse safety formulations.

OmniSafe is open-sourced at: https://github.com/PKU-Alignment/omnisafe

Summary updated

BibTeX
@misc{ji2023omnisafe,
  author = {Jiaming Ji and Jiayi Zhou and Borong Zhang and Juntao Dai and Xuehai Pan and Ruiyang Sun and Weidong Huang and Yiran Geng and Mickel Liu and Yaodong Yang},
  title = {{OmniSafe: An Infrastructure for Accelerating Safe Reinforcement Learning Research}},
  year = {2023},
  eprint = {2305.09304},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.09304},
}
Figure