Sampling-Based Safe Reinforcement Learning

Luca Vignola, Bruce D Lee, Manish Prajapat, Manuel Wendl, Melanie N. Zeilinger, Andreas Krause, Yarden AsNeurIPS 2026

TL;DR

Teaching robots in the real world is nerve-wracking: reinforcement learning (RL) relies on trial and error, and "error" in physical systems means broken hardware. This paper introduces Sampling-Based Safe Reinforcement Learning (SBSRL), an algorithm that guarantees safety during learning by testing policies across a handful of plausible "parallel universe" physics models before acting, and replaces finicky exploration bonuses with a clean uncertainty constraint. The result is an agent with rigorous theoretical safety guarantees that successfully learns to pilot a high-speed remote-controlled race car around obstacles without crashing.

What Problem Does This Paper Address?

Reinforcement learning shines in simulators where dying a million times is free. Deploying RL online on physical hardware hits two massive walls: sample efficiency and safety during exploration.

To explore safely, an agent faces a classic catch-22: it needs to visit unknown states to learn how the world works, yet because those states are unknown, visiting them might cause a catastrophic failure. Model-based RL tries to solve this by learning a model of the environment's physics (dynamics) along with uncertainty estimates. Standard safe RL methods use these estimates to optimize for the worst-case plausible physics—which is mathematically intractable in continuous spaces, forcing researchers to use loose, overly conservative heuristics that sacrifice theoretical guarantees. Furthermore, to encourage exploration, standard methods add "intrinsic curiosity bonuses" to the reward function. Anyone who has tuned RL hyperparameters at 2 AM knows these bonuses are notoriously brittle, easily causing the agent to either obsess over irrelevant noise or stop exploring way too early.

Methods

The authors work within Constrained Markov Decision Processes (CMDPs), where an agent maximizes expected reward while keeping expected cumulative costs (like collision energy) below a strict budget at every single episode. Assuming a basic safe starting policy and a rough initial physics prior, SBSRL introduces two clever mechanisms:

  1. Safety via Dynamics Sampling & Truncation: Instead of solving an impossible worst-case optimization over infinitely many plausible physics models, SBSRL draws a finite number ($M$) of dynamics functions from a Gaussian Process (GP) prior. As real-world data arrives, it refines these samples online by clipping ("truncating") them so they stay inside the shrinking confidence intervals of the updated GP. The agent then optimizes its policy so that it satisfies a slightly tightened safety constraint across all $M$ sampled models simultaneously.
SBSRL enforces tightened safety constraints jointly across rollouts of multiple plausible dynamics models (transparent cars) to guarantee safety on the true system.
Samples drawn from the GP prior are clipped to lie within calibrated confidence bounds, ensuring at least one sample stays uniformly close to the true dynamics.
  1. Exploration as a Constraint: Instead of muddying the reward objective with an exploration bonus, SBSRL adds a minimum constraint on epistemic uncertainty (uncertainty due to lack of data). The agent simply maximizes task reward, subject to accumulating at least a threshold $d_\sigma^n$ of model uncertainty along its trajectory.

For high-dimensional robotics where exact GPs struggle to scale, the authors also introduce a practical deep RL variant using neural network ensembles in place of GP samples.

Datasets

Because this is an online RL paper, evaluation happens in interactive simulated benchmarks and a real-world dataset/hardware setup rather than static datasets:

  • DeepMind Control Suite: PendulumSwingUp and CartpoleSwingUp tasks (used to validate the exact GP-based theory).
  • High-dimensional RL Benchmarks: SafetyGym and the Real-World RL (RWRL) suite (evaluated in the appendix using the deep ensemble variant).
  • Real-World Hardware + Offline Dataset: An offline dataset of real-world trajectories used to warm-start and calibrate a 45-dimensional state-space model (using a sliding window of 5 past state measurements) for a physical remote-controlled race car operating at 60 Hz, which then learns online to dodge tire obstacles.

Key Insights and Ideas

  • Finite samples beat intractable worst-cases: By invoking "small-ball probability" theory from Gaussian Processes, the authors prove that if you draw enough prior samples, at least one is guaranteed (with high probability) to stay uniformly close to the true, unknown physics—and clipping those samples with new data preserves this closeness! This bridges the gap between tractable computation and strict theoretical safety.
  • Let greedy policies be greedy: Framing exploration as a constraint rather than a reward bonus means that whenever maximizing the actual task reward naturally visits uncertain states, the exploration constraint becomes inactive. The agent doesn't waste time exploring irrelevant corners of the state space just to farm curiosity points.
  • Built-in stopping criterion: Eventually, the agent learns the dynamics well enough that no safe policy can accumulate enough uncertainty to satisfy the exploration constraint. Problem infeasibility isn't a bug here—it's a mathematically certified alarm bell telling the algorithm: "You know enough; drop the exploration constraint and deploy the greedy policy, it's guaranteed to be near-optimal!"

Key Results

  • Theoretical Guarantees: Under standard regularity assumptions, SBSRL satisfies safety constraints at every episode with high probability ($1 - 2\delta$), terminates in a finite number of episodes, and returns an $\varepsilon$-optimal policy within the reachable set of safe policies.
  • GP Simulation: On PendulumSwingUp and CartpoleSwingUp (5 seeds), SBSRL achieves near-optimal normalized cumulative returns while keeping maximum cost violations at zero. A baseline using only mean dynamics violates safety constraints heavily (exceeding the cost budget by $>0.05$ on Pendulum and $\sim 0.5$ on Cartpole). SBSRL also converges noticeably faster than pure-exploration baselines like ActSafe within just 6 episodes.
  • Real-World Race Car (60 Hz): Over ~70 online episodes (3 seeds), deep-ensemble SBSRL nearly triples the initial offline policy's reward (climbing from $\sim 55$ to $>150$) while keeping collision costs (kinetic energy lost in crashes) safely below the budget of 15. A baseline enforcing constraints only on the mean critic repeatedly crashes, spiking above the safety budget during training.

Limitations and Future Work

  • Conservative theoretical sample bounds: The theoretical number of GP samples $M$ required to guarantee a close match in the worst case can be very large, though empirically a small handful of samples (or a standard deep ensemble) works well in practice.
  • Episodic resets: The framework relies on finite-horizon episodes, which requires manual environment resets (like someone walking over to pick up or reset the RC car). Extending this to continuing, non-episodic tasks is left for future work.
  • Expected vs. State-wise Safety: Costs are constrained in expectation over an entire trajectory rather than guaranteeing strict, instantaneous state-wise safety at every millisecond—another open frontier the authors highlight for nonlinear, high-dimensional control.

Summary updated

Abstract

Safe exploration remains a fundamental challenge in reinforcement learning (RL), limiting the deployment of RL agents in the real world. We propose _Sampling-Based Safe Reinforcement Learning_ (SBSRL), a model-based RL algorithm that maintains safety throughout the learning process by enforcing constraints jointly across a _finite_ set of dynamics samples. This formulation approximates an intractable worst-case optimization over uncertain dynamics and enables practical safety guarantees in continuous domains. We further introduce an exploration strategy based on constraining epistemic uncertainty, eliminating the need for explicit exploration bonuses. Under regularity conditions, we derive high-probability guarantees of safety throughout learning and a finite-time sample complexity bound for recovering a near-optimal policy. Empirically, SBSRL achieves safe and efficient exploration both in simulation and in real-world experiments, and readily extends to practical deep-ensemble implementations that scale to high-dimensional continuous control problems.
BibTeX
@inproceedings{vignola2026sampling,
  author = {Luca Vignola and Bruce D Lee and Manish Prajapat and Manuel Wendl and Melanie N. Zeilinger and Andreas Krause and Yarden As},
  title = {{Sampling-Based Safe Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=nGAaqOxzHK},
}
Figure