Provably Safe Reinforcement Learning with Step-wise Violation Constraints

Nuoya Xiong, Yihan Du, Longbo Huang

Introduction

Most "Safe Reinforcement Learning" (RL) research defines safety as a long-term budget: as long as the average number of accidents or constraint violations per episode remains low, the agent is considered safe. However, in real-world, safety-critical applications like autonomous driving or surgical robotics, this definition falls short. An agent cannot "offset" a catastrophic crash in the first minute of operation by driving flawlessly for the next hour.

To address this, researchers have introduced a stricter framework for Safe RL that enforces safety at every single decision step. This paper tackles the challenge of Step-wise Violation Constraints (Safe-RL-SW), developing novel algorithms that allow an agent to maximize rewards while minimizing safety violations—even when it does not initially know which actions are safe.

The Challenge of Step-Wise Safety

The Safe-RL-SW setting introduces several unique hurdles compared to traditional Constrained Markov Decision Processes (CMDPs):

  1. Strictness (The "No Offset" Rule): The framework aggregates all non-negative violations at every step. Positive and negative costs cannot cancel each other out, ensuring that being overly safe in one state does not grant the agent a "license to crash" in another.
  2. Unknown Safety: Unlike many previous works that assume the agent starts with a known "safe baseline policy," this paper assumes the agent does not know which actions are safe in a given state at the outset.
  3. Hidden Dangers: A state might appear safe in the immediate term but inevitably lead to a dangerous "dead-end" region a few steps later.

Algorithmic Innovations: SUCBVI and SRF-UCRL

To navigate these challenges, the authors propose two primary algorithms based on the principle of "Optimism in the Face of Uncertainty," uniquely adapted for safety.

Look-Ahead Safety with SUCBVI

For standard RL, the authors introduce SUCBVI (Safe Upper Confidence Bound Value Iteration). SUCBVI maintains an optimistic estimate of both rewards and safety costs. Its core innovation is a novel dynamic programming approach used to identify "potentially unsafe states."

Instead of only looking at immediate costs, SUCBVI recursively defines an unsafe set. A state is marked as potentially unsafe if every available action leads to a state that is already known to be dangerous. This "look-ahead" capability allows the agent to foresee danger and alter its course before reaching a point of no return. The algorithm then restricts the agent's policy to a safe action set derived from these estimates.

Safe Reward-Free Exploration with SRF-UCRL

The authors also explore the "reward-free" setting, where an agent must explore an environment to learn its dynamics and safety boundaries before a specific reward function is provided. They introduce SRF-UCRL (Safe Reward-Free Upper Confidence Bound RL), which utilizes a specialized uncertainty function to ensure that the final policy it outputs is both near-optimal and strictly safe.

Theoretical Guarantees and Key Results

The paper provides rigorous theoretical guarantees within the tabular Markov Decision Process (MDP) framework, validated by synthetic grid-world simulations.

  • Regret and Violation Bounds: Because the agent learns from scratch without prior safety knowledge, it must inevitably suffer some initial violations to learn the environment's boundaries. However, SUCBVI guarantees that these violations are kept sub-linear, specifically $\widetilde{\mathcal{O}}(\sqrt{ST})$, where $S$ is the number of states and $T$ is the total number of steps. Simultaneously, it achieves a regret of $\widetilde{\mathcal{O}}(\sqrt{H^3SAT})$.
  • Gap-Dependent Safety: If there is a clear mathematical "gap" between safe and unsafe costs, the violation bound improves to a constant $\widetilde{\mathcal{O}}(S/\mathcal{C}_{\mathrm{gap}} + S^2AH^2)$. This means the agent eventually becomes perfectly safe and stops violating constraints entirely.
  • Exploration Efficiency: SRF-UCRL achieves nearly state-of-the-art sample complexity for reward-free exploration while maintaining the same $\widetilde{\mathcal{O}}(\sqrt{ST})$ safety guarantee during the learning phase.
  • Optimality: The authors provide theoretical lower bounds, proving mathematically that no algorithm can significantly improve upon their regret and safety violation trade-offs.

In simulations, both SUCBVI and SRF-UCRL successfully converged to the safe optimal reward, whereas standard CMDP algorithms (like OptCMDP-bonus and Triple-Q) suffered from high step-wise violations because they only optimized for episode-wise averages.

Limitations and Future Directions

While this work establishes strong theoretical foundations for step-wise safe RL, several challenges remain:

  • Tabular Limitations: The current proofs and algorithms are designed for tabular MDPs (discrete states and actions). Scaling these provable guarantees to Deep RL, which handles continuous spaces via neural networks, remains a major open challenge.
  • Initial Violations: Because the agent starts with zero knowledge, some initial violations (scaling with $\sqrt{ST}$) are mathematically inevitable. In ultra-high-stakes scenarios (e.g., deploying a real autonomous vehicle), even these initial violations may be unacceptable without pre-training, simulators, or human intervention.
  • Computational Complexity: The recursive dynamic programming step required to identify unsafe regions introduces additional computational overhead compared to standard RL algorithms.

Summary updated

BibTeX
@inproceedings{xiong2023provably,
  author = {Nuoya Xiong and Yihan Du and Longbo Huang},
  title = {{Provably Safe Reinforcement Learning with Step-wise Violation Constraints}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=UJ9o8wbB5U},
}
Figure