Paying Only for the Difference: Safe Real-World Learning in the Low-Rank Sim-to-Real Residual

A robot trained in a simulator usually behaves badly on real hardware, and the usual fix, collecting real data and fine-tuning, risks breaking the robot while it learns. This proposal rests on one observation. The simulator is wrong in only a few ways, such as friction, motor delay, or tire slip. If the robot's dynamics are described with a compact set of features, those few errors should occupy only a few directions in that feature space. A learner that trusts the simulator everywhere else, and spends its cautious real-world trials only on measuring those few directions, should need far fewer real samples. It should also be able to keep every real episode within its safety budget, without assuming the simulator is either exactly right or wrong by a fixed minimum amount.

Concretely, we work in a linear Markov decision process, a model of the environment where both the reward and the next-state distribution are linear functions of a known $d$-dimensional feature vector $\phi(s,a)$ of the current state and action. We propose to model the gap between simulator and reality as a low-rank linear residual inside that model. We use the simulator's own parameter randomization to propose which $r \ll d$ feature directions the residual can occupy. Real data is used only to estimate the residual's coefficients, with a pessimistic, uncertainty-aware estimate of the safety cost. The claim is that real-world sample cost then scales with $r$ instead of $d$ or $|S|$, and that constraint violations stay at zero in every episode, as long as the subspace proposal is approximately right. A separate statistical check detects when the proposal is wrong and falls back to full-dimensional estimation.

Where this sits

Three existing results each supply one piece.

Provably Safe Sim-to-Real Transfer is the closest work. It proves that real samples need only scale with the size of a "mismatch region" $|B|$ of state-action pairs where the simulator is wrong. It keeps real exploration safe by mixing a known safe policy with an exploratory one, using a weight computed by a linear program. Its limits are that it is tabular, and that it requires a "separable shift": every state-action pair is either exactly right in simulation or wrong by at least $\sigma_s$. Smooth physical errors such as gradual friction changes violate this assumption. When they do, the method's test cannot certify the simulator and it treats everything as mismatched. We keep its hybrid-model and safe-mixture structure. We replace "a set of bad cells" with "a low-dimensional subspace of bad feature directions," and we replace the yes/no test with a continuous confidence set, so small errors cost little instead of breaking certification.

Provably Efficient RL under Episode-Wise Safety in Constrained MDPs with Linear Function Approximation supplies the method template. Its algorithm, OPSE-LCMDP, uses optimistic reward estimates, pessimistic cost estimates, and a trigger that reverts to a safe policy. It obtains zero violations in every episode with $\tilde{O}(\sqrt{K})$ regret over $K$ episodes. It learns the full $d$-dimensional dynamics from scratch in the deployment environment, with no notion of a simulator.

Distributionally Robust Off-Dynamics Reinforcement Learning supplies a constraint on design. It shows that defining dynamics uncertainty over feature coordinates with total-variation sets keeps the robust value function linear, whereas KL-type sets make errors grow exponentially with horizon. It has no safety costs and plans against the worst case instead of learning the actual shift. We keep linear, feature-coordinate uncertainty for the same tractability reason, but our uncertainty set shrinks with real data and is confined to $r$ directions.

SPiDR motivates the project from the empirical side. Penalizing actions where an ensemble of randomized simulators disagrees gave zero-shot safe transfer on a Unitree Go1 and an RC car. However, it never learns from real data, its penalty weight is hand-tuned, and it has no protection when reality lies outside the randomization range. We use the same randomized simulators for a different job: to estimate the directions of plausible mismatch, not as a penalty.

One negative result also shapes the design. Demystifying Linear MDPs shows that representing the full transition kernel can force $d \gtrsim S/U$, where $U$ is the number of states reachable in one step. Exact linear models of densely connected dynamics are therefore large. This is why we never ask real data to identify the full kernel. The simulator carries the large part, and real data identifies only a residual that we hypothesize is low-rank even when $d$ is large.

Core Claim

We write the real dynamics as the simulator plus a residual confined to an $r$-dimensional subspace of the features:

$$P_{\text{real}}(\cdot\mid s,a) = P_{\text{sim}}(\cdot\mid s,a) + \big\langle U^\top \phi(s,a),\, w(\cdot)\big\rangle + e(\cdot\mid s,a).$$

The terms are as follows. $U \in \mathbb{R}^{d\times r}$ is an orthonormal basis for the proposed mismatch directions. The term $w(\cdot)$ is an unknown $r$-dimensional signed measure giving the residual's coefficients. The term $e$ is whatever error lies outside the subspace, with total-variation size at most $\eta$.

We obtain $U$ before touching hardware. We sample simulator parameters from the domain-randomization range, fit the linear dynamics parameters for each sample, and take the top principal directions of how those parameters vary.

On hardware, the learner regresses observed next-state value targets minus simulator predictions onto $U^\top\phi$. This gives a ridge estimate of $w$ and an elliptical confidence set built from the $r\times r$ covariance of the projected features. Planning uses the simulator plus the residual estimate. Rewards get an optimistic bonus and costs a pessimistic bonus, both inflated by an $\eta$-dependent term.

Each episode, the learner runs a mixture policy: with probability $1-\alpha_k$ it runs the safe baseline, and otherwise it runs the optimistic policy. $\alpha_k$ is the largest weight whose pessimistic expected cost meets every constraint. Because episode-level mixing makes expected cost linear in $\alpha_k$, several constraints are handled by taking a minimum. This sidesteps the single-constraint bisection argument of OPSE-LCMDP, though only for this mixture policy class.

By the standard elliptical-potential argument applied to an $r$-dimensional regression, we expect real-world regret of order $\tilde{O}(r\sqrt{H^3K})$ plus a term linear in $\eta HK$. Here $H$ is the horizon and $K$ the number of episodes. This replaces the $d$ of the from-scratch bound with $r$. The $\eta$ term is the cost of a wrong subspace, so we also need a way to detect it.

That detector is the out-of-subspace check. It is a full-$d$ residual regression run in parallel on the same real data, with a confidence test for whether any mass outside $U$ is distinguishable from zero. If the test fires, the method enlarges $U$ with the detected directions. This is our answer to SPiDR's support-envelope blind spot: reality falling outside the randomization range shows up as residual outside $U$, rather than silently removing the penalty.

Research Program

The theoretical part proves three things. The first is episode-wise safety given a safe baseline and a correctly sized $\eta$-inflation. The second is the regret bound above. The third is a detection guarantee: out-of-subspace error larger than a threshold that shrinks like $1/\sqrt{n}$ in the number of real samples $n$ is flagged with high probability, so the effective $\eta$ the learner suffers decays rather than staying fixed. With one-hot features and $U$ spanning the coordinates of the mismatch cells, the method reduces to the setting of Provably Safe Sim-to-Real Transfer without the separability assumption. We will state this reduction explicitly as a sanity check.

The empirical part tests whether real sim-to-real gaps are actually low-rank in learned features, which is the claim most likely to fail. For deep control tasks, $\phi$ will be the frozen last layer of a network trained in simulation. This brings back misspecification, which the theory covers only through $\eta$, so we will measure how large the effective $\eta$ is in practice.

Baselines

The naive reference point is the policy trained in simulation (with domain randomization where relevant) and deployed unchanged. It measures the gap we are trying to close. SPiDR reports that standard randomization produced 26.1x more violations than SPiDR on the Go1 and 6.2x more on the RC car.

The strongest existing method in the tabular regime is Provably Safe Sim-to-Real Transfer. On its 5×5 windy gridworld it reports 0% unsafe iterations and 77,958 real samples, against 296,910 for the version without a simulator. We will run its released formulation on the same gridworld with the same safety budget and safe policy. Beating it means matching 0% unsafe iterations with fewer real samples, or keeping certification when we make the wind's effect smoothly graded, which breaks separability.

The strongest continuous-control competitor is SPiDR. It reports 100% zero-shot constraint satisfaction on both hardware platforms. We will give it the same simulator ensemble and the same tuning budget for its penalty weight $\lambda$, and then allow it Lagrangian fine-tuning on the same real-sample budget as our method. Beating it means equal or better constraint satisfaction with higher return after adaptation. Safety alone does not count, since SPiDR is already safe zero-shot when reality lies inside its envelope.

The theoretical competitor is OPSE-LCMDP run from scratch on the "real" environment with identical features. For Safety-Gymnasium-style tasks we will report PPO-Lagrangian as the deep reference. Safety Gymnasium reports that it cuts violations by 98% relative to PPO at a 45% drop in reward.

The key ablation is our method with $U = I_d$: a full-dimensional residual centered on the simulator, with everything else identical. This isolates whether the low-rank subspace, rather than simply reusing the simulator, produces the savings.

Why not just…?

Why not just warm-start OPSE-LCMDP with a prior centered on the simulator's dynamics? This is the most serious alternative. A ridge prior centered at the simulator's parameters is essentially our $U=I_d$ ablation, and it inherits OPSE-LCMDP's safety guarantee for free. If that ablation matches our real-sample counts, the subspace idea adds nothing and we will say so. Our method can only win where $r \ll d$ and the confidence ellipsoid in $d$ dimensions is much wider than in $r$. We will report sample counts as a function of $d$ at fixed true rank $r$ on the synthetic linear constrained MDP, where the predicted crossover can be checked directly.

Why not just use SPiDR and skip real adaptation? When reality lies inside the randomization range, SPiDR is already safe on hardware, and we do not expect to beat it on safety there. It cannot improve from real data, its $\lambda$ is hand-tuned and can freeze the agent, and its penalty vanishes outside the ensemble's support. Our experiments therefore include shifts that place reality outside the randomization range, where we predict SPiDR's violations rise and our out-of-subspace check fires.

Why not just discretize and run the tabular safe-transfer algorithm? Discretization makes $|B|$ grow with grid resolution, and smooth parameter errors break the separable-shift test, as that paper itself acknowledges. The graded-wind gridworld variant tests exactly this.

Proposed Experiments

The first experiment is the windy gridworld, in its original form and in a graded-wind form. The metrics are unsafe-iteration rate and real samples to an $\varepsilon$-optimal safe policy.

The second is the synthetic linear constrained MDP with $|S|=100$ from the OPSE-LCMDP paper. That paper reports zero violations but no regret numbers on Lacuna. We extend it with a planted rank-$r$ residual and sweep $d$, $r$, and planted out-of-subspace error $\eta$.

The third uses Safety Gymnasium velocity and navigation tasks and the MuJoCo circle tasks from FOCOPS. "Reality" is a held-out simulator with altered friction, mass, and actuator delay, including values outside the randomization range. These tasks carry multiple simultaneous costs.

If the simulated results hold, the final experiment is the RC-car obstacle task used by SPiDR.

Three outcomes decide the proposal. First, real-sample savings must scale with $d/r$ against the $U=I_d$ ablation. Second, the method must keep zero violations in every episode when the shift is smooth. Third, when the randomization range misses reality, the out-of-subspace detector must fire before any violation occurs. If the principal-component subspace explains little of the true residual in learned features, the core hypothesis is false, and the method reduces to a simulator-centered OPSE-LCMDP.