Table of Contents
Fetching ...

Provably Optimal Reinforcement Learning under Safety Filtering

Donggeon David Oh, Duy P. Nguyen, Haimin Hu, Jaime F. Fisac

TL;DR

The paper addresses the challenge of ensuring strict safety in reinforcement learning without sacrificing long-term performance. It introduces a safety-filtered RL framework built on a Safety-Critical MDP (SC-MDP) and a corresponding filtered MDP $\,\mathcal{M}_{φ}$ that uses a perfect safety filter $φ$, guaranteeing categorical safety via a maximal invariant safe set $Ω^*$. The main theoretical result establishes a complete safety–performance separation: any ε-optimal policy on $\,\mathcal{M}_{φ}$, when executed through $φ$, is an ε-optimal policy on the SC-MDP, and standard RL convergence carries over to the filtered setting. Empirically, the approach validated on Safety Gymnasium yields zero safety violations with a rollout-based filter and achieves equal or better asymptotic performance compared to unfiltered baselines, supporting its practical viability. The work thus provides a principled, implementable recipe: train with the most permissive safety filter and deploy with the same filter, ensuring strict safety and optimal long-run performance in tandem.

Abstract

Recent advances in reinforcement learning (RL) enable its use on increasingly complex tasks, but the lack of formal safety guarantees still limits its application in safety-critical settings. A common practical approach is to augment the RL policy with a safety filter that overrides unsafe actions to prevent failures during both training and deployment. However, safety filtering is often perceived as sacrificing performance and hindering the learning process. We show that this perceived safety-performance tradeoff is not inherent and prove, for the first time, that enforcing safety with a sufficiently permissive safety filter does not degrade asymptotic performance. We formalize RL safety with a safety-critical Markov decision process (SC-MDP), which requires categorical, rather than high-probability, avoidance of catastrophic failure states. Additionally, we define an associated filtered MDP in which all actions result in safe effects, thanks to a safety filter that is considered to be a part of the environment. Our main theorem establishes that (i) learning in the filtered MDP is safe categorically, (ii) standard RL convergence carries over to the filtered MDP, and (iii) any policy that is optimal in the filtered MDP-when executed through the same filter-achieves the same asymptotic return as the best safe policy in the SC-MDP, yielding a complete separation between safety enforcement and performance optimization. We validate the theory on Safety Gymnasium with representative tasks and constraints, observing zero violations during training and final performance matching or exceeding unfiltered baselines. Together, these results shed light on a long-standing question in safety-filtered learning and provide a simple, principled recipe for safe RL: train and deploy RL policies with the most permissive safety filter that is available.

Provably Optimal Reinforcement Learning under Safety Filtering

TL;DR

The paper addresses the challenge of ensuring strict safety in reinforcement learning without sacrificing long-term performance. It introduces a safety-filtered RL framework built on a Safety-Critical MDP (SC-MDP) and a corresponding filtered MDP that uses a perfect safety filter , guaranteeing categorical safety via a maximal invariant safe set . The main theoretical result establishes a complete safety–performance separation: any ε-optimal policy on , when executed through , is an ε-optimal policy on the SC-MDP, and standard RL convergence carries over to the filtered setting. Empirically, the approach validated on Safety Gymnasium yields zero safety violations with a rollout-based filter and achieves equal or better asymptotic performance compared to unfiltered baselines, supporting its practical viability. The work thus provides a principled, implementable recipe: train with the most permissive safety filter and deploy with the same filter, ensuring strict safety and optimal long-run performance in tandem.

Abstract

Recent advances in reinforcement learning (RL) enable its use on increasingly complex tasks, but the lack of formal safety guarantees still limits its application in safety-critical settings. A common practical approach is to augment the RL policy with a safety filter that overrides unsafe actions to prevent failures during both training and deployment. However, safety filtering is often perceived as sacrificing performance and hindering the learning process. We show that this perceived safety-performance tradeoff is not inherent and prove, for the first time, that enforcing safety with a sufficiently permissive safety filter does not degrade asymptotic performance. We formalize RL safety with a safety-critical Markov decision process (SC-MDP), which requires categorical, rather than high-probability, avoidance of catastrophic failure states. Additionally, we define an associated filtered MDP in which all actions result in safe effects, thanks to a safety filter that is considered to be a part of the environment. Our main theorem establishes that (i) learning in the filtered MDP is safe categorically, (ii) standard RL convergence carries over to the filtered MDP, and (iii) any policy that is optimal in the filtered MDP-when executed through the same filter-achieves the same asymptotic return as the best safe policy in the SC-MDP, yielding a complete separation between safety enforcement and performance optimization. We validate the theory on Safety Gymnasium with representative tasks and constraints, observing zero violations during training and final performance matching or exceeding unfiltered baselines. Together, these results shed light on a long-standing question in safety-filtered learning and provide a simple, principled recipe for safe RL: train and deploy RL policies with the most permissive safety filter that is available.
Paper Structure (16 sections, 4 theorems, 25 equations, 3 figures)

This paper contains 16 sections, 4 theorems, 25 equations, 3 figures.

Key Result

Theorem 1

If ass:standing_formal holds, then the following claims on the safety, convergence, and optimality of under safety filtering are true:

Figures (3)

  • Figure 1: Our proposed framework for training and deploying optimal policies under safety filtering. First, we train a filter-agnostic task policy in a safety-enforcing environment where every action is passed through a safety filter. Then, we deploy the learned task policy with the same filter at runtime. The filtered policy provably achieves the same asymptotic performance as it had been trained with the safety constraints in mind.
  • Figure 2: Top: environment components (Agent, Circle, Pillars, Goal, Walls). Bottom: example scenes for the two tasks from Safety Gymnasium ji2023safety. We use the Car agent across all experiments. Circle task: the agent aims to track the green circle's boundary as fast as possible while remaining inside the square wall; safety is violated by crossing the wall. Goal task: the agent navigates to a fixed green goal while avoiding the pillars and staying inside the wall; safety is violated by crossing the wall or colliding with a pillar. In both tasks, the agent is randomly initialized inside the wall and away from the pillars and the goal.
  • Figure 3: Experimental results on the Goal (left) and Circle (right) tasks in Safety Gymnasium. We compare our safe RL framework, implemented with an -based task policy and a neural safety filter with rollout- and value-based monitoring, against and standard baselines. Top: mean episodic training return versus the number of environment steps. Middle: mean episodic evaluation return versus the number of environment steps. Bottom: cumulative safety violations versus the number of environment steps. Our method achieves zero safety violations when using a valid (rollout-based) safety filter while converging to the same or higher return than the baselines. Even with an error-prone approximate (value-based) filter, the number of safety violations is significantly reduced compared to the baselines.

Theorems & Definitions (14)

  • Definition 1: Safety-Critical ()
  • Remark 1: Probabilistic and worst-case uncertainty
  • Definition 2: Perfect safety filter
  • Definition 3: Filtered
  • Theorem 1: Safe and optimal under a perfect safety filter
  • proof
  • Remark 2: Safety with optimal performance
  • Remark 3: Practical recipe for Safe
  • Lemma 1: No all-time safety outside the maximal invariant set
  • proof
  • ...and 4 more