Online Optimization for Offline Safe Reinforcement Learning

Yassine Chemingui, Aryan Deshwal, Alan Fern, Thanh Nguyen-Tang, Jana Doppa

Abstract

Offline Safe Reinforcement Learning (OSRL) presents a significant challenge: agents must maximize rewards while strictly adhering to safety constraints, relying solely on pre-collected datasets without environment interaction. Traditional approaches often struggle with the "Safety-Reward Tightrope," where tuning safety penalties via Off-Policy Evaluation (OPE) leads to instability and poor performance. This paper introduces O3SRL (Online Optimization for Offline Safe RL), a framework that reformulates OSRL as a minimax game. By employing a multi-armed bandit strategy to adaptively tune safety penalties, O3SRL bypasses the need for unstable OPE. Experimental results across multiple benchmarks demonstrate that O3SRL consistently satisfies safety constraints under tight budgets while outperforming state-of-the-art methods in reward maximization.

1. Introduction

Reinforcement Learning (RL) typically relies on a trial-and-error process that is unsuitable for safety-critical domains such as healthcare or autonomous driving, where errors can be catastrophic. Offline Safe RL (OSRL) addresses this by learning safe policies from logged datasets. However, OSRL faces two primary hurdles: distributional shift, where agents lack information about actions not present in the data, and the instability of penalty tuning.

Standard OSRL methods use a Lagrange multiplier ($\lambda$) to penalize unsafe behavior. In an offline setting, finding the optimal $\lambda$ usually requires Off-Policy Evaluation (OPE) to estimate policy performance. Unfortunately, OPE is notoriously prone to error propagation, often resulting in policies that are either recklessly unsafe or overly conservative to the point of being useless.

2. The O3SRL Framework

O3SRL treats the OSRL problem as a minimax objective—a zero-sum game between a policy-player (maximizing rewards) and a penalty-player (enforcing safety). The framework operates iteratively through two primary phases:

  1. Policy Update: An "Offline RL Oracle" is called to identify a policy that maximizes the combined objective: $Reward - \lambda \times Cost$.
  2. Penalty Update: Instead of traditional gradient-based updates for $\lambda$, O3SRL utilizes a no-regret online optimization algorithm to adjust the penalty based on current performance.

2.1 The Multi-Armed Bandit Approach

To resolve the instability of OPE, the authors introduce a "Bandit Trick." The penalty parameter $\lambda$ is discretized into $K$ possible values, or "arms." The algorithm then employs the EXP3 algorithm—a multi-armed bandit strategy—to select the most effective $\lambda$. This discretization eliminates the reliance on continuous OPE, providing a more stable and robust mechanism for constraint satisfaction.

2.2 Computational Efficiency via Truncated Updates

Training an offline RL model to full convergence in every iteration is computationally prohibitive. O3SRL addresses this by performing truncated updates. By executing only a small number of gradient steps (e.g., $M=10$) before updating the penalty, the algorithm remains computationally efficient. This "plug-and-play" design allows O3SRL to be integrated easily with existing offline RL engines like TD3+BC or Implicit Q-Learning (IQL).

3. Experimental Evaluation

The researchers evaluated O3SRL on two comprehensive suites:

  • DSRL Bullet Benchmark: Eight continuous control tasks (e.g., Car-Run, Drone-Circle) requiring agents to maintain velocity or positional boundaries.
  • Gymnasium Safety Suite: Seven environments (e.g., PointCircle, Walker2dVelocity) used to test generalization across diverse dynamics.

3.1 Key Results

  • Superior Constraint Satisfaction: In the DSRL benchmark with a strict cost limit ($\kappa=5$), O3SRL was the only method to consistently maintain a normalized cost $\leq 1$ across all tasks. In contrast, competing methods like CDT and CCAC frequently exceeded safety limits by factors of 10x to 20x.
  • High Reward Utility: O3SRL does not sacrifice performance for safety. In the BallCircle task, it achieved rewards three times higher than other safe-performing baselines like CAPS.
  • Practicality: Due to the truncated update strategy, a complete training run takes approximately 20 minutes on a standard NVIDIA A40 GPU, making it highly accessible for iterative development.

4. Discussion and Future Work

While O3SRL demonstrates remarkable stability, the use of discrete "arms" for $\lambda$ introduces a theoretical discretization error. However, empirical evidence suggests this error is negligible in practice. Additionally, while theory suggests returning an average of all policies found during training, the authors found that using the last-iterate policy performed well while being significantly more memory-efficient.

Future research will focus on transitioning O3SRL from simulated benchmarks to "offline-to-online" settings, where agents initialized with offline data can continue to learn safely upon real-world deployment.

5. Conclusion

O3SRL provides a robust solution to the instability of Offline Safe RL. By framing penalty tuning as a multi-armed bandit problem and utilizing truncated updates, the framework ensures strict safety compliance without the computational or stability pitfalls of traditional OPE-based Lagrangian methods. It stands as a versatile wrapper capable of enhancing the safety profiles of various underlying offline RL algorithms.

Summary updated

BibTeX
@inproceedings{chemingui2025online,
  author = {Yassine Chemingui and Aryan Deshwal and Alan Fern and Thanh Nguyen-Tang and Jana Doppa},
  title = {{Online Optimization for Offline Safe Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=e85xf2d17F},
}
Figure