SAFTER: Safety-Aware Filtering Through Explicit Recoverability for Robust Reinforcement Learning Under Distribution Shift

Anonymous Authors (under double-blind review)

Abstract

Learning safe policies that generalize to unseen environments is difficult under bounded actuation, where an unsafe decision may become unrecoverable. Conventional control barrier function (CBF) filters enforce only instantaneous safety and ignore future recoverability. We propose SAFTER (Safety-Aware Filtering Through Explicit Recoverability), which embeds a differentiable, closed-form backup-CBF filter into Soft Actor-Critic training. SAFTER unifies current safety, finite-horizon backup safety, terminal recoverability, and input admissibility into a single differentiable certificate. Its CBF condition yields an exact minimum-intervention projection without iterative online optimization. In quadruped navigation, SAFTER reaches 90% training success with 30.6% fewer transitions than Vanilla SAC and 34.1–35.1% fewer than current-state CBF-filtered SAC baselines. Across unseen simulated environments, SAFTER improves success by up to 42.4 and 61.4 percentage points over the state-of-the-art methods CBF–RL and SEA–Nav, respectively, and achieves 73.3% and 76.7% success on two real-world navigation maps. Ablations identify accurate differentiation through the safety filter as a key contributor to robustness, in which replacing the projection Jacobian with the identity approximation reduces success rate in a High-Shift environment from 61.4% to 6.2%. These results show that recoverability-aware filtering serves as both a runtime safety mechanism and a learning mechanism for sample-efficient, robust policies.

Overview of the SAFTER framework

Overview of SAFTER. The policy proposed a nominal commmand, and the proposed safety filter evaluate the actions under predictive backup rollout. Multiple evaluation constraints were combined under one single composite constraint through Log-Sum-Exp, where the soft-minimum is obtained. Under one single constraint, the safe actions can be synthesized through a closed-form solution.

Experimental Results

All methods are evaluated in MuJoCo with a Unitree Go2 under a frozen 50 Hz low-level locomotion policy and a 10 Hz high-level LiDAR-based policy. SR, TR, and FR denote success, timeout, and failure rates (%).

RQ1: Learning Efficiency and Policy Internalization

Training success rate of Vanilla SAC, CBF-QP, CBF-CF, bCBF-LSE-QP and SAFTER

Training success rates under the same training environments (five seeds, 256 parallel environments). SAFTER reaches 90% success after 4.06±0.08M transitions, 30.6% fewer than Vanilla SAC and 34.1–35.1% fewer than the current-state CBF baselines. The matched bCBF–LSE–QP (4.13±0.43M) behaves similarly, indicating the gain is primarily associated with predictive backup recoverability.

Table 1. Training-map performance with each method's runtime safety filter disabled or enabled.

Method Filter disabled Filter enabled
SR ↑TR ↓FR ↓SR ↑TR ↓FR ↓
SEA–Nav89.7±2.40.0±0.010.3±2.491.2±2.90.0±0.08.8±2.9
CBF–RL84.3±8.25.9±5.29.8±7.184.8±7.45.9±5.29.3±6.6
CBF–CF76.6±13.82.7±6.320.7±15.890.1±8.21.9±4.58.0±8.5
SAFTER (Ours)95.1±7.10.0±0.04.9±7.199.7±1.20.0±0.00.3±1.2

SAFTER achieves 95.1% success even without its runtime filter (99.7% with it), suggesting that recoverability-aware training promotes nominal behavior compatible with the prescribed backup strategy.

Table 2. Safety-filter runtime (mean ± std over 300 timed repetitions, NVIDIA RTX 4090). Speedup is relative to the direct bCBF–QP.

Method Batch = 1 Batch = 100
Total (ms)Synthesis (ms)SpeedupTotal (ms)Synthesis (ms)Speedup
bCBF–QP30.546±0.32428.369±0.1941.00×2504.789±22.4632487.383±16.9491.00×
bCBF–LSE–QP5.732±0.4563.342±0.4055.33×7.084±0.5694.588±0.481353.58×
SAFTER (Ours)2.495±0.3120.102±0.01112.24×2.529±0.2830.106±0.014990.43×

SAFTER has the lowest total latency at both batch sizes: 12.24× and 990.43× lower than the direct bCBF–QP, and 2.30× and 2.80× faster than the matched bCBF–LSE–QP. Since the QP baselines use different solvers (OSQP and qpth), comparisons against the direct formulation reflect end-to-end implementation latency rather than a solver-isolated speedup.

RQ2: Robustness under Geometric Distribution Shift

Each method uses a fixed checkpoint selected independently of unseen-map performance, evaluated over 25 seeds with 20 episodes each (500 episodes per environment).

Representative trajectories of SEA-Nav, CBF-RL, CBF-CF and SAFTER in the Medium-Shift environment

Representative trajectories in the Medium-Shift environment (10 scenarios). Purple and yellow regions denote the initial and goal regions, squares mark initial positions, stars successful terminations, crosses collision terminations, and faint circles indicate the robot footprint. SAFTER succeeds in 9/10 scenarios, versus 5/10 for SEA–Nav, 3/10 for CBF–RL, and 5/10 for CBF–CF.

Real-World Quadruped Navigation

Real-world navigation experiments using the Unitree Go2 quadruped.

Table 3. Navigation performance across unseen static environments (mean ± std across 25 evaluation-seed rates).

Method Low-Shift Medium-Shift High-Shift
SR ↑TR ↓FR ↓ SR ↑TR ↓FR ↓ SR ↑TR ↓FR ↓
SEA–Nav93.8±6.70.0±0.06.2±6.750.6±10.90.0±0.049.4±10.90.0±0.00.0±0.0100.0±0.0
CBF–RL61.2±10.713.6±6.725.2±9.846.2±11.617.2±7.636.6±9.231.0±10.015.4±8.953.6±12.2
Vanilla SAC34.2±10.10.0±0.065.8±10.120.8±6.90.0±0.079.2±6.917.4±8.30.0±0.082.6±8.3
CBF–QP58.8±9.40.2±1.041.0±9.243.2±11.00.0±0.056.8±11.018.0±6.90.0±0.082.0±6.9
CBF–CF69.0±11.50.0±0.031.0±11.548.4±8.40.0±0.051.6±8.433.8±12.20.0±0.066.2±12.2
bCBF–LSE–QP99.4±1.70.0±0.00.6±1.775.0±9.70.0±0.025.0±9.767.4±11.70.0±0.032.6±11.7
SAFTER (Ours)98.8±2.20.0±0.01.2±2.288.6±7.30.0±0.011.4±7.361.4±10.20.0±0.038.6±10.2

SAFTER achieves 98.8%, 88.6%, and 61.4% success on Low-, Medium-, and High-Shift, exceeding Vanilla SAC and both current-state CBF baselines in all three environments. The matched bCBF–LSE–QP performs similarly strongly (99.4%, 75.0%, 67.4%), indicating that the robustness gain is primarily associated with predictive backup recoverability rather than the analytical realization alone.

RQ3: Why Does SAFTER Learn Differently?

Table 4. Ablation of the projection Jacobian and correction reward on unseen environments. Exact and Identity use the same forward safety-filter map and differ only in the backward differentiation through the analytical projection.

Projection
Jacobian
Correction
Reward
Low-Shift Medium-Shift High-Shift
SR ↑TR ↓FR ↓ SR ↑TR ↓FR ↓ SR ↑TR ↓FR ↓
ExactOn98.8±2.20.0±0.01.2±2.288.6±7.30.0±0.011.4±7.361.4±10.20.0±0.038.6±10.2
IdentityOn89.8±6.00.0±0.010.2±6.041.6±9.30.0±0.058.4±9.36.2±4.40.0±0.093.8±4.4
ExactOff95.6±4.94.2±4.90.2±1.094.4±4.43.8±3.91.8±3.576.2±9.23.2±3.820.6±8.3
IdentityOff76.8±7.10.0±0.023.2±7.19.0±6.10.0±0.091.0±6.12.0±3.50.0±0.098.0±3.5

Replacing the Exact projection Jacobian with the Identity approximation reduces success by up to 85.4 percentage points across the evaluated distribution shifts. Removing the correction reward has a mixed effect: the Exact-Jacobian policy improves from 88.6% to 94.4% on Medium-Shift and from 61.4% to 76.2% on High-Shift, while decreasing from 98.8% to 95.6% on Low-Shift. Propagating the analytical projection Jacobian therefore materially improves robustness, whereas minimizing filter intervention is not uniformly beneficial under larger geometric shifts.