Simple Algorithm
Artificial Intelligence · Deep Layer · 26 min

Robot Learning & Sim-to-Real

Learning control in a physical world.

A simulated robot can gather years of experience in a day; a real one breaks things, needs resets and lives in physics that no simulator gets exactly right. Robot learning sits between two imperfect sources of data, simulators and demonstrations, and the theory says precisely how the errors of each propagate: through the simulation lemma for one, through compounding mistakes for the other.

What you’ll learn

  • Quantify the sim-to-real gap with the simulation lemma, formalize domain randomization as a latent-parameter POMDP, and prove that memory can double the value of a randomized policy.
  • Prove DAgger's uT(ϵN+γN)uT(\epsilon_N+\gamma_N) guarantee from the performance-difference lemma and no-regret online learning, and show that behavior cloning's quadratic bound can be tight.
  • Explain why inverse RL is ill-posed, prove that matching feature expectations guarantees near-expert performance for every bounded linear reward, and derive the maximum-entropy IRL gradient.
  • Describe diffusion policies, action chunking and vision–language–action models, and the open problems of generalist robot policies as of the mid-2020s.

The reality gap and domain randomization

Robots add constraints that games and gridworlds lack: continuous, high-dimensional actions issued tens to hundreds of times per second, noisy partial observations, hardware that wears out, and safety limits on what may be tried. GPU-based simulators run thousands of environments in parallel (Makoviychuk et al., 2021), so training moves into simulation whenever possible, and the question becomes how much of what is learned there survives contact with reality. The simulation lemma (Bellman Equations & Contraction) answers in the worst case: if every transition distribution of the simulator is within ε\varepsilon of reality in L1L_1, a policy optimal in the simulator loses at most 2γεRmax⁡/(1−γ)22\gamma\varepsilon R_{\max}/(1-\gamma)^2 in the real world.

Check your understanding

With γ=0.99\gamma=0.99, what per-step L1L_1 model error does that bound require before it promises that the simulator-optimal policy loses less than 10% of the maximum possible value Rmax⁡/(1−γ)R_{\max}/(1-\gamma)?

  1. About 5×10−25\times10^{-2}
  2. About 5×10−35\times10^{-3}
  3. About 5×10−45\times10^{-4}
  4. About 5×10−65\times10^{-6}
Show the answer

C. About 5×10−45\times10^{-4}

The bound is 2γεRmax⁡/(1−γ)2≈19,800 εRmax⁡2\gamma\varepsilon R_{\max}/(1-\gamma)^2\approx19{,}800\,\varepsilon R_{\max}, and 10% of the maximum value is 10Rmax⁡10R_{\max}, so ε≲5×10−4\varepsilon\lesssim5\times10^{-4}. No simulator of contact and friction is that accurate everywhere, so transfer cannot rest on accuracy alone; it needs robustness or adaptation. The bound is a worst case, which is also why policies often transfer better than it promises.

DerivationMemory can double the value (proof by example)
  1. Eξ[JMξ(πq)]=12 qT+12 (1−q) T=T2for every q\E_\xi\big[J_{M_\xi}(\pi_q)\big]=\tfrac12\,qT+\tfrac12\,(1-q)\,T=\tfrac T2\qquad\text{for every }q

    Let ξ∈{+1,−1}\xi\in\{+1,-1\} with probability 12\tfrac12 each, a motor wired one way or the other. At each of TT steps the robot pushes left or right; in M+1M_{+1} pushing right earns 1 and left 0, and in M−1M_{-1} the reverse. Observations are constant, so they reveal nothing about ξ\xi, but rewards do. A memoryless policy pushes right with a fixed probability qq at every step:

  2. Eξ[JMξ(πmem)]=12+(T−1)=T−12\E_\xi\big[J_{M_\xi}(\pi_{\mathrm{mem}})\big]=\tfrac12+(T-1)=T-\tfrac12

    A policy with memory pushes right once, notes whether it was rewarded, and pushes the correct way for the remaining T−1T-1 steps:

  3. The ratio (T−12)/(T/2)(T-\tfrac12)/(T/2) tends to 2. Robustness over Ξ\Xi cannot replace the information a single probe reveals; only memory can use it. Chen et al. (2022) analyze domain randomization in this latent-MDP model, show that it can transfer without any real-world samples under conditions on the simulator family, and their bounds highlight the role of history-dependent policies.

Practice followed the same logic. Tobin et al. (2017) randomized textures, lighting and camera poses so that a detector trained only on synthetic images worked on real ones. OpenAI's in-hand manipulation work used recurrent policies with automatic domain randomization, which widens each parameter's range as the policy masters the current one, and found evidence that the trained network adapts within an episode (OpenAI et al., 2019). Legged robots are often trained with a privileged teacher that sees ξ\xi in simulation and a student that must infer it from its sensor history (Lee et al., 2020), or with an adaptation module that estimates latent "extrinsics" from recent states and actions (rapid motor adaptation; Kumar et al., 2021).

Imitation: compounding errors and DAgger

Fix a TT-step task with costs C(s,a)∈[0,1]C(s,a)\in[0,1], a deterministic expert π∗\pi^*, and J(π)=∑t=1TEs∼dπt[C(s,π(s))]J(\pi)=\sum_{t=1}^T\E_{s\sim d^t_\pi}\big[C(s,\pi(s))\big], where dπtd^t_\pi is π\pi's state distribution at step tt and dπ=1T∑tdπtd_\pi=\frac1T\sum_td^t_\pi its average. Behavior cloning, supervised learning on the expert's state–action pairs, minimizes a surrogate loss ℓ(s,π)∈[0,1]\ell(s,\pi)\in[0,1], such as the indicator of disagreeing with the expert, on the expert's distribution, ϵ=Es∼dπ∗[ℓ(s,π)]\epsilon=\E_{s\sim d_{\pi^*}}[\ell(s,\pi)], and can pay up to T2ϵT^2\epsilon (Ross & Bagnell, 2010; proved in Sequence-to-Sequence Models).

Think first Can behavior cloning really lose order T2ϵT^2\epsilon, or is the bound just loose?

It can. Let the expert follow a narrow path, and let any wrong action drop the robot into a region the expert never visits, where every step costs 1 and the cloned policy, never trained there, cannot find its way back. If the learner errs with probability ϵ\epsilon per step while still on the path, its first error falls at step tt with probability about ϵ\epsilon and then costs about T−tT-t. Summing, the expected extra cost is about ϵ∑t(T−t)≈ϵT2/2\epsilon\sum_t(T-t)\approx\epsilon T^2/2. Ross and Bagnell give a construction of this kind.

DerivationProof
  1. J(π)−J(π∗)=∑t=1TEs∼dπt[QT−t+1∗(s,π(s))−QT−t+1∗(s,π∗(s))]J(\pi)-J(\pi^*)=\sum_{t=1}^{T}\E_{s\sim d^t_\pi}\Big[Q^*_{T-t+1}\big(s,\pi(s)\big)-Q^*_{T-t+1}\big(s,\pi^*(s)\big)\Big]

    Performance difference, finite-horizon form. Telescoping the expert's cost-to-go along the learner's trajectory, as in the discounted lemma of Bellman Equations & Contraction, gives for any π\pi:

  2. J(π)−J(π∗)≤u∑t=1TEs∼dπt[ℓ(s,π)]=uT Es∼dπ[ℓ(s,π)]J(\pi)-J(\pi^*)\le u\sum_{t=1}^T\E_{s\sim d^t_\pi}\big[\ell(s,\pi)\big]=uT\,\E_{s\sim d_\pi}\big[\ell(s,\pi)\big]

    Each bracket vanishes where π\pi agrees with the expert and is at most uu where it does not, so it is at most u ℓ(s,π)u\,\ell(s,\pi). The loss is weighted by the learner's own state distribution:

  3. 1N∑i=1NEs∼dπ^i[ℓ(s,π^i)]≤min⁡π∈Π1N∑i=1Nℓi(π)+γN=ϵN+γN\frac1N\sum_{i=1}^N\E_{s\sim d_{\hat\pi_i}}\big[\ell(s,\hat\pi_i)\big]\le\min_{\pi\in\Pi}\frac1N\sum_{i=1}^N\ell_i(\pi)+\gamma_N=\epsilon_N+\gamma_N

    No regret. In round ii the learner plays π^i\hat\pi_i and suffers ℓi(π^i)=Es∼dπ^i[ℓ(s,π^i)]\ell_i(\hat\pi_i)=\E_{s\sim d_{\hat\pi_i}}[\ell(s,\hat\pi_i)], which is exactly π^i\hat\pi_i's on-policy loss. Average regret at most γN\gamma_N means

  4. J(π^i)≤J(π∗)+uT(ϵN+γN)■J(\hat\pi_i)\le J(\pi^*)+uT\big(\epsilon_N+\gamma_N\big)\qquad\blacksquare

    Some π^i\hat\pi_i is no worse than the average, so its on-policy loss is at most ϵN+γN\epsilon_N+\gamma_N, and the second step finishes the proof. Training on the aggregated data is follow-the-leader, which is no-regret for strongly convex losses with γN=O(log⁡N/N)\gamma_N=\order{\log N/N}.

Two caveats are built into the statement. ϵN\epsilon_N is the best loss achievable in the class on the learner's own states, so if the policy class cannot imitate the expert there, more data does not help. And uu encodes recoverability: for driving-like tasks u=O(1)u=\order1, but when one wrong step can be fatal, uu can be of order TT and DAgger's bound is quadratic too. Practical variants lighten the expert's burden: human-gated interventions (HG-DAgger; Kelly et al., 2019), noise injected into the expert's own demonstrations so that they cover recovery states (DART; Laskey et al., 2017), and teachers that are themselves policies with privileged simulator state.

Inverse RL: learning what the expert wants

Imitation copies actions; inverse reinforcement learning (IRL) infers a reward that explains them, which can transfer to situations where copying cannot. Ng & Russell (2000) showed that the problem is ill-posed: the zero reward makes every policy optimal, and in a finite MDP the rewards for which a given policy is optimal form a convex cone cut out by linear inequalities. Potential-based shaping, r′(s,a,s′)=r(s,a,s′)+γΦ(s′)−Φ(s)r'(s,a,s')=r(s,a,s')+\gamma\Phi(s')-\Phi(s), never changes the optimal policies (Ng, Harada & Russell, 1999), so rewards are identifiable at best up to shaping and scale. IRL algorithms resolve the ambiguity with an extra criterion: a margin, maximum entropy, or a divergence between occupancy measures.

Proof. By linearity of expectation Jw(π)=w⊤μ(π)J_w(\pi)=w^\top\mu(\pi), so ∣Jw(π)−Jw(πE)∣=∣w⊤(μ(π)−μ(πE))∣≤∥w∥2∥μ(π)−μ(πE)∥2≤ϵ|J_w(\pi)-J_w(\pi_E)|=|w^\top(\mu(\pi)-\mu(\pi_E))|\le\norm w_2\norm{\mu(\pi)-\mu(\pi_E)}_2\le\epsilon by Cauchy–Schwarz. In occupancy-measure terms (RL Foundations), μ(π)=11−γ∑sdπ(s)ϕ(s)\mu(\pi)=\frac1{1-\gamma}\sum_sd^\pi(s)\phi(s), so feature matching matches kk linear projections of the occupancy measure. Abbeel and Ng's algorithm alternates between finding weights ww that best separate the expert's feature expectations from those of the policies found so far and solving the RL problem for that reward, and it returns a mixture of policies that matches within ϵ\epsilon after finitely many iterations.

DerivationMaximum-entropy IRL (Ziebart et al., 2008)
  1. Pw(τ)=exp⁡(w⊤f(τ))Z(w),Z(w)=∑τexp⁡(w⊤f(τ))P_w(\tau)=\frac{\exp\big(w^\top\mathbf f(\tau)\big)}{Z(w)},\qquad Z(w)=\sum_\tau\exp\big(w^\top\mathbf f(\tau)\big)

    Feature matching leaves many policies, and many weight vectors, consistent with the data. Ziebart et al. choose the trajectory distribution of maximum entropy subject to matching the expert's average feature counts fˉE\bar{\mathbf f}_E. For deterministic dynamics, Lagrangian duality yields an exponential family over trajectories, with f(τ)=∑tϕ(st)\mathbf f(\tau)=\sum_t\phi(s_t):

  2. ∇w1m∑j=1mlog⁡Pw(τj)=fˉE−Eτ∼Pw[f(τ)]\nabla_w\frac1m\sum_{j=1}^m\log P_w(\tau_j)=\bar{\mathbf f}_E-\E_{\tau\sim P_w}\big[\mathbf f(\tau)\big]

    Fit ww by maximum likelihood on demonstrations τ1,…,τm\tau_1,\dots,\tau_m. The gradient of log⁡Z\log Z is the model's expected feature count, so the gradient is expert features minus model features, and it vanishes exactly when they match:

  3. The model expectation comes from a soft, log-sum-exp version of value iteration, so each gradient step solves a planning problem. The log-likelihood is concave in ww, and the model treats the expert as noisily rational, likelier to take better trajectories but not always the best, which tolerates imperfect demonstrations.

GAIL (Ho & Ermon, 2016) showed that maximum-entropy IRL followed by RL amounts to matching occupancy measures under a convex regularizer, and chose a regularizer that turns the problem into a game between the policy and a discriminator D(s,a)D(s,a):

min⁡πmax⁡D E(s,a)∼dπ[log⁡D(s,a)]+E(s,a)∼dπE[log⁡(1−D(s,a))]−λH(π).\min_\pi\max_D\ \E_{(s,a)\sim d^\pi}\big[\log D(s,a)\big]+\E_{(s,a)\sim d^{\pi_E}}\big[\log\big(1-D(s,a)\big)\big]-\lambda H(\pi).

At the optimal discriminator, the policy minimizes a Jensen–Shannon divergence between its occupancy measure and the expert's, as in a GAN (Generative Adversarial Networks). GAIL recovers a policy without ever writing down a reward, at the price of on-policy RL in its inner loop.

Generalist robot policies (as of the mid-2020s)

Large-scale imitation has driven much of the recent progress in manipulation, and three design choices recur.

  • What to predict. Behavior cloning with a squared-error loss regresses to the mean of the demonstrated actions; when demonstrators pass an obstacle on both sides, the mean goes through it, the same failure as blurry video prediction (World Models & Video Generation). Diffusion policies (Chi et al., 2023) model the whole multimodal action distribution by denoising, as diffusion models do for images (Diffusion Models), and discretizing actions into bins and predicting tokens does the same with a categorical distribution.
  • How far ahead. Action chunking (ACT; Zhao, Kumar, Levine & Finn, 2023) predicts the next kk actions at once, which divides the number of decisions per episode by kk, and with it the opportunities for compounding error.
  • What to start from. Vision–language–action (VLA) models start from a pretrained vision–language model.
ApproachAction outputStrengthWeakness
Behavior cloning with squared errorone continuous actionsimple and fastaverages multimodal demonstrations
Diffusion or flow-matching policycontinuous, multimodalexpressive; smooth trajectoriesseveral denoising steps per action
Tokenized actions (RT-2, OpenVLA)discrete bins as tokensreuses language-model machinery and web knowledgecoarse precision; low control rates
Action chunkingblocks of kk actionsfewer decisions; smoother motionless reactive within a chunk

RT-1 (Brohan et al., 2022) trained a transformer on a large collection of real demonstrations, mapping camera images and language instructions to discretized actions. RT-2 (Brohan et al., 2023) fine-tuned vision–language models to emit actions as text tokens while co-training on web data, introduced the term vision–language–action model, and showed that semantic knowledge from the web carried over to instructions about objects and concepts absent from the robot data. The Open X-Embodiment collaboration (2023) pooled datasets from many labs and robot types, OpenVLA (Kim et al., 2024) released an open-weights VLA, and π0 (Black et al., 2024) paired a vision–language backbone with a flow-matching "action expert" for high-frequency continuous control.

Key takeaways

  • The simulation lemma makes sim-to-real gaps scale like γεRmax⁡/(1−γ)2\gamma\varepsilon R_{\max}/(1-\gamma)^2, far too large to rely on accuracy alone, so transfer relies on robustness and adaptation.
  • Domain randomization optimizes the expected return over a distribution of simulators: a latent-parameter POMDP in which memory enables implicit system identification and can double the value over memoryless policies.
  • Behavior cloning can lose order T2ϵT^2\epsilon, and the bound is tight; DAgger's on-policy labels and no-regret learning give J(π^)≤J(π∗)+uT(ϵN+γN)J(\hat\pi)\le J(\pi^*)+uT(\epsilon_N+\gamma_N), linear in TT when mistakes are recoverable.
  • Inverse RL is ill-posed, but matching feature expectations guarantees near-expert return for every bounded linear reward; maximum-entropy IRL and GAIL turn imitation into likelihood fitting or occupancy-measure matching.
  • Multimodal action models, action chunking and vision–language–action models drive generalist manipulation as of the mid-2020s, while data, evaluation and reliability remain open problems.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Why can a history-dependent policy trained with domain randomization beat the best memoryless policy?

  1. It has more parameters
  2. It can infer the hidden simulator parameters from its own history and adapt, while a memoryless policy must act the same way under every parameter value
  3. It is trained on more simulators
  4. Memoryless policies cannot be trained with domain randomization
Show the answer

B. It can infer the hidden simulator parameters from its own history and adapt, while a memoryless policy must act the same way under every parameter value

With ξ\xi hidden, domain randomization is a POMDP over (s,ξ)(s,\xi). A memoryless policy can only hedge across simulators, earning T/2T/2 in the motor-wiring example, while a policy with memory probes once, identifies ξ\xi and earns T−12T-\tfrac12.

Question 2

In the proof of DAgger's guarantee, what does the no-regret property contribute?

  1. It makes the expert optimal
  2. It makes the recoverability constant uu small
  3. It guarantees that the policy class contains the expert
  4. It bounds the iterates' average loss on their own state distributions by the best loss in hindsight on the aggregated data, plus γN\gamma_N
Show the answer

D. It bounds the iterates' average loss on their own state distributions by the best loss in hindsight on the aggregated data, plus γN\gamma_N

Round ii's loss ℓi(π^i)=Es∼dπ^i[ℓ(s,π^i)]\ell_i(\hat\pi_i)=\E_{s\sim d_{\hat\pi_i}}[\ell(s,\hat\pi_i)] is the on-policy loss of the iterate, so no regret gives 1N∑iℓi(π^i)≤ϵN+γN\frac1N\sum_i\ell_i(\hat\pi_i)\le\epsilon_N+\gamma_N. The performance-difference lemma converts an on-policy loss into a cost gap of at most uTuT times that loss.

Question 3

A policy's feature expectations match the expert's within ϵ\epsilon in the Euclidean norm. What does Abbeel and Ng's argument guarantee?

  1. The policy recovers the expert's true reward weights ww
  2. The policy takes the expert's action in every state
  3. ∣Jw(π)−Jw(πE)∣≤ϵ|J_w(\pi)-J_w(\pi_E)|\le\epsilon for every reward w⊤ϕw^\top\phi with ∥w∥2≤1\norm w_2\le1
  4. The policy is optimal for every reward function
Show the answer

C. ∣Jw(π)−Jw(πE)∣≤ϵ|J_w(\pi)-J_w(\pi_E)|\le\epsilon for every reward w⊤ϕw^\top\phi with ∥w∥2≤1\norm w_2\le1

Returns are linear in feature expectations, Jw(π)=w⊤μ(π)J_w(\pi)=w^\top\mu(\pi), so Cauchy–Schwarz gives ∣w⊤(μ(π)−μ(πE))∣≤∥w∥2 ϵ≤ϵ|w^\top(\mu(\pi)-\mu(\pi_E))|\le\norm w_2\,\epsilon\le\epsilon. The guarantee holds for the unknown true reward without identifying it, which IRL's ill-posedness would make impossible anyway.

Question 4

Demonstrators pass an obstacle on the left half the time and on the right half the time. A policy trained by behavior cloning with a squared-error loss on these demonstrations tends to…

  1. steer toward the middle, into the obstacle
  2. pass on the left, the first mode it sees
  3. pick left or right at random in each episode
  4. stop in front of the obstacle
Show the answer

A. steer toward the middle, into the obstacle

Squared error is minimized by the conditional mean, and the mean of "left" and "right" points straight ahead. A model of the whole action distribution, such as a diffusion policy or a categorical distribution over action tokens, can represent both modes and sample one of them.

Further reading

  • S. Ross, G. J. Gordon & J. A. Bagnell, "A reduction of imitation learning and structured prediction to no-regret online learning," AISTATS (2011).
  • J. Tobin, R. Fong, A. Ray, J. Schneider, W. Zaremba & P. Abbeel, "Domain randomization for transferring deep neural networks from simulation to the real world," IROS (2017).
  • P. Abbeel & A. Y. Ng, "Apprenticeship learning via inverse reinforcement learning," ICML (2004).
  • A. Brohan et al., "RT-2: Vision-language-action models transfer web knowledge to robotic control," CoRL (2023).
  • T. Osa, J. Pajarinen, G. Neumann, J. A. Bagnell, P. Abbeel & J. Peters, "An algorithmic perspective on imitation learning," Foundations and Trends in Robotics (2018).