Optimistic in Simulation, Pessimistic on Hardware: Boundary-Calibrated Safe Domain Randomization

Robots trained in simulation are usually made safe for their first real deployment by being cautious in every simulator. The simulator's physics (friction, mass, motor delay) are randomized during training. Wherever the randomized simulators disagree, the policy is penalized, so it learns to stay well away from anything uncertain. This works. A pessimistic method of this kind reports 100% constraint satisfaction on a real quadruped and a small race car. But caution has a price on tasks whose best behavior sits right at the edge of what is physically safe, such as cornering at the friction limit or pushing an object fast without tipping it. There the cautious policy settles deep inside the safe region and gives up performance. Theory from constrained bandits and Bayesian optimization says the remedy is optimism about constraints, meaning the agent treats uncertain costs as possibly low so that it goes and checks. Roboticists have avoided optimism because checking a constraint on hardware can break the hardware.

This note proposes to put the two attitudes in different places. In simulation, a constraint violation costs nothing, so a dedicated exploration policy should be optimistic and high-entropy: it deliberately probes and crosses the safety boundary in every randomized physics setting, specifically to teach the safety estimator where that boundary is. Training also shifts which simulated physics settings get sampled, toward settings where the boundary is both close and poorly understood. Only the policy that is actually deployed is pessimistic. That pessimism is applied to a cost estimate trained on this boundary data, not as a hand-tuned penalty on simulator disagreement. The claim is that this matches the zero-shot safety of pessimistic domain randomization while recovering much of the performance it gives up on tasks where the best behavior lies at the boundary.

Core Claim

Safe reinforcement learning treats "safety during exploration" and "safety of the final policy" as one problem. That is right for real-world learning and wrong for simulation-to-real transfer. A constrained Markov decision process (CMDP) is a decision problem where the agent maximizes reward while keeping expected cumulative safety cost under a budget $\epsilon$. In sim-to-real, only the deployed policy's constraint matters, and exploration should be judged by how well it calibrates the deployed policy's safety estimate.

The Breaking Safety Paradox with Feasible Dual Policy Iteration work identifies the "safety paradox": as a policy gets safer, violating samples vanish and the cost critic degrades. Domain randomization makes this worse, because the safe boundary moves with the physics parameter $\xi$. A speed that is safe on high friction is a crash on low friction. Our position is that the cure is optimistic exploration that is confined to simulation and targeted by $\xi$.

How This Differs From the Closest Work

Four papers come closest, and each takes a different position on the two attitudes or on where they apply.

SPiDR is the main motivating result and the main competitor. It adds an ensemble-disagreement penalty $\lambda\upsilon(s,a)$ to the cost and proves this bounds the true cost from above. Because it is pessimistic everywhere, including during training, it never learns whether an uncertain boundary region is actually feasible. Its $\lambda$ is also hand-tuned. We keep its deployment-time pessimism, but derive it from a cost critic conditioned on $\xi$ and trained on boundary-crossing data, rather than from raw dynamics disagreement.

COX-Q is optimistic about cost in an off-policy learner. However, it shrinks exploratory steps to keep training-time cost near the threshold, which is a sensible restriction for real-world learning that becomes unnecessary in simulation. It also never randomizes dynamics. We drop the training-time cost restriction and add randomization.

DOPE and Provably Safe Sim-to-Real Transfer mix optimism and pessimism with zero-violation guarantees. Both are tabular, both need a known safe baseline policy, and neither uses randomized simulators. They constrain our ambitions on theory, and we do not claim their guarantees.

DORAEMON supplies the entropy-over-physics idea. It widens the distribution over simulator parameters as far as a success-rate threshold allows. It has no safety cost, and it reports forgetting when it backtracks to narrower distributions. We use maximum entropy over $\xi$ differently: as a regularizer that keeps the full randomization range covered while sampling is tilted toward boundary-critical physics.

BSPG supplies the reason boundaries matter. It shows that whenever the unconstrained optimum is infeasible, the constrained optimum lies exactly on the cost boundary. It only studies nominal, non-randomized dynamics.

Research Program

The system trains two policies off-policy from one shared replay buffer filled by parallel simulators with randomized $\xi$.

The deployed policy is a soft actor-critic agent, an off-policy learner that maximizes reward plus a bonus for action randomness (Haarnoja et al.), with a Lagrangian constraint. The constraint is placed on an upper quantile of cost across domains rather than the domain average:

$$\max_{\pi}\ \mathbb{E}_{\xi\sim p}\,J_r(\pi;\xi)\quad\text{s.t.}\quad \mathrm{Quantile}_{1-\delta,\ \xi\sim p}\big[\hat J_c(\pi;\xi)+\kappa\,u(\xi)\big]\le\epsilon .$$

In this objective, $p$ is the base randomization distribution and $J_r(\pi;\xi)$ is the expected return in the simulator with physics $\xi$. The term $\hat J_c(\pi;\xi)$ is the mean prediction of an ensemble of cost critics conditioned on $\xi$, and $u(\xi)$ is the ensemble's standard deviation. The parameter $\delta$ sets the tail of physics settings the deployed policy must stay safe in, and $\kappa$ sets how strongly the remaining critic uncertainty is penalized.

The design intent is that once the critic is calibrated near the boundary, $u$ is small there. At that point the pessimism comes mostly from genuine variation across physics, which is set by $\delta$ and the randomization range, rather than from a free penalty knob. We will report sensitivity to $\kappa$ honestly, since this is the same kind of knob as SPiDR's $\lambda$.

The explorer policy is never deployed. It maximizes an optimistic score: an upper bound on reward minus a multiplier times a lower confidence bound on cost, plus an action-entropy bonus. This is the reward-up, cost-down optimism of Bandits with Knapsacks and CONFIG, moved into continuous control. Its role is to put many transitions on both sides of the deployed policy's boundary.

Domain sampling follows a maximum-entropy rule. Each episode's physics are drawn from

$$q(\xi)\propto p(\xi)\exp\!\big(b(\xi)/\tau\big),\qquad b(\xi)=u(\xi)-\big|\hat J_c(\pi;\xi)-\epsilon\big|,$$

which is the exact maximizer of $\mathbb{E}_q[b]-\tau\,\mathrm{KL}(q\,\|\,p)$. The score $b$ is high where the deployed policy's cost is plausibly at the budget and the critic is unsure. The temperature $\tau$ trades this targeting against staying close to the full randomization range, which guards against the forgetting reported for DORAEMON.

The analysis component measures cost-critic calibration as a function of $\xi$ and of distance to the boundary throughout training. The goal is to test directly whether the safety paradox appears under standard training and disappears under optimistic exploration.

Baselines

The naive reference is soft actor-critic with a Lagrangian cost constraint under standard uniform domain randomization. Per-domain average cost is constrained, and there is no explorer and no domain tilt. This is what most practitioners would run. It is weak on transfer: LyEvO reports SAC-Lagrangian violation rates "as high as 54% in some scenarios" under disturbances, and SPiDR reports standard domain randomization producing 26.1x (Go1) and 6.2x (race car) more real violations than SPiDR.

The strongest existing method is SPiDR, run as its authors describe. It shares our ensemble of randomized simulators, with ensemble size at least 8, and our soft actor-critic backbone. Its $\lambda$ is tuned on the same validation physics with the same number of tuning runs we give our $\kappa$, $\delta$ and $\tau$. Its reported hardware result is 100% real-world constraint satisfaction on both the Unitree Go1 and the race car. No reported result was found on Lacuna for SPiDR's numerical task return, and none for scalar SPiDR numbers on RWRL. We therefore measure return ourselves.

Beating SPiDR means achieving held-out violation rates statistically indistinguishable from its own, while scoring higher return on tasks whose optimum lies at the boundary. Matching it on interior-optimal tasks is the expected null outcome there.

COX-Q combined with domain randomization tests whether existing optimistic off-policy exploration suffices once physics are randomized. It uses the same simulators and the same step budget. No scalar COX-Q values were reported on Lacuna.

All methods get equal environment steps, equal wall-clock compute and the same network sizes.

Three ablations isolate the ingredients. The first removes the explorer: the deployed policy collects its own data under the same quantile constraint. The second keeps an explorer with matched action entropy but no cost optimism. The third removes the domain tilt by setting $\tau\to\infty$.

Why not just…?

Why not just use SPiDR and tune $\lambda$ smaller? Lowering $\lambda$ trades safety for performance along a single curve, because the penalty cannot tell regions that are truly unsafe from regions that are merely unexplored. Our method aims to move the curve rather than slide along it. The experiment that settles this sweeps $\lambda$ and plots SPiDR's return against held-out violation rate next to ours. If some $\lambda$ reaches our point, the explorer is not earning its keep, and we would say so.

Why not just constrain the cost quantile across domains with an ordinary safe learner, without a separate explorer? This is the most serious threat, since the deployed objective alone might do most of the work. The ablation that removes the explorer answers it directly. Our prediction, based on the safety paradox described in Breaking Safety Paradox with Feasible Dual Policy Iteration, is that without boundary-crossing data the critic's error in low-friction or high-latency domains grows. That error should show up either as held-out violations or as excess conservatism. If calibration error and transfer results do not differ, the proposal reduces to this simpler method.

Why not just raise the soft actor-critic entropy temperature to explore more? Undirected randomness spreads samples evenly. Boundary samples in rare physics settings stay scarce, and the maximum-entropy literature notes that a fixed entropy target over-explores dangerous regions and under-explores safe ones. The ablation that matches action entropy but removes cost optimism isolates exactly this.

Why not just tighten the budget $\epsilon$? A tighter budget is pessimism applied uniformly. It shrinks the policy into the interior that BSPG shows is suboptimal, and it does nothing for critic calibration. It enters the comparison as a point on the naive baseline's return-versus-violation curve.

Proposed Experiments

Training uses Safety-Gymnasium (benchmark) PointGoal2 with dynamics randomization, mirroring SPiDR's MuJoCo-on-accelerator port, along with Brax Safe Velocity and the RWRL suite. We add two tasks designed so the optimum lies on the boundary: a velocity limit that binds only under low friction, and a cornering task whose safe speed depends on tire friction.

"Reality" is simulated with held-out physics drawn from a shifted distribution inside the training support. A second held-out set lies just outside the support, to expose the in-support assumption that both we and SPiDR rely on.

The metrics are:

  • held-out deployed return;
  • held-out violation rate and worst-decile cost;
  • the deployed policy's cost relative to $\epsilon$, which measures how close to the boundary it operates;
  • cost-critic calibration error binned by $\xi$ and by distance to the boundary.

The decisive checks are three. First, on boundary-optimal tasks, our method must beat SPiDR's best return-versus-violation curve while matching its held-out safety. Second, the ablation without the explorer must show measurably worse boundary calibration. Third, outside the training support, neither method should be credited with safety; we report how each one fails.

If these hold in simulation, the hardware step reuses SPiDR's race-car setting, where the friction-limited optimum is most pronounced. There, real-world violation counts and lap progress are compared against SPiDR under identical deployment protocols.