Introduction
In the world of robotics, we are constantly chasing the dream of efficient learning. If you have ever trained a neural network for image recognition, you know the power of backpropagation. You calculate the error, compute the gradient (the direction to adjust parameters to reduce that error), and update the network. It’s elegant, mathematical, and efficient.
However, when we try to apply this same logic to robots interacting with the physical world—specifically legged robots that need to walk—we hit a massive wall: Contact.
When a robot’s foot hits the ground, the physics involves an abrupt collision. In mathematical terms, this is a discontinuity. Standard physics simulators handle these hard contacts well for simulation, but they break the calculus required for backpropagation. Because the dynamics aren’t smooth, we can’t easily compute a derivative (gradient) to tell the robot how to improve.
As a result, most modern robot learning relies on Reinforcement Learning (RL) algorithms like PPO (Proximal Policy Optimization). These methods treat the simulator as a “black box,” estimating gradients by trying millions of random actions. It works, but it is incredibly sample-inefficient.
But what if we could differentiate through the physics simulator?
In this post, we are diving into a fascinating paper: “Learning Deployable Locomotion Control via Differentiable Simulation.” The researchers propose a novel way to model contact that is physically accurate enough for the real world but smooth enough to allow for efficient, gradient-based learning.

They didn’t just run this in a computer. As shown above, they successfully transferred the policy to a real, physical quadruped robot zero-shot. This marks a significant milestone: the first successful sim-to-real transfer of a legged locomotion policy learned entirely within a differentiable simulator.
The Problem: Gradients vs. The Real World
To understand the innovation here, we first need to understand the “Gradient Bottleneck.”
Zeroth-Order vs. First-Order
In standard Reinforcement Learning, we use Zeroth-order Gradient (ZoG) estimation. Imagine you are on a mountain at night (the loss landscape) and want to find the valley (the optimal policy). You can’t see the slope. So, you stomp your feet around randomly to see which way is down. You estimate the slope based on these samples. This is robust but requires millions of stomps (samples).
Differentiable Simulation offers First-order Gradients (FoG). This is like turning on the lights. You can analytically calculate the exact slope of the mountain and take a direct step downhill. This promises vastly better efficiency.
The Contact Discontinuity
The problem arises when we introduce the ground. In a rigid-body simulator, contact is usually modeled as a “Hard Contact.”
- If the foot is above ground (\(distance > 0\)), force is zero.
- If the foot touches ground (\(distance = 0\)), force instantly jumps to prevent penetration.
This “jump” creates a discontinuity. If you try to calculate a gradient right at that impact point, the math breaks down.

As visualized in the charts above, standard RL (ZoG) handles this by introducing noise (stochasticity). By averaging over the noise (the orange line), the sharp jump becomes a smooth curve.
However, if you try to compute analytic gradients (FoG) on the original discontinuous function (the blue line), you get gradients that are either zero (useless) or infinite (exploding). The bottom plot shows how the analytic gradient (orange solid line) is basically flat—it gives no information—while the stochastic estimate (green line) provides a useful curve.
The Failure of “Soft” Contacts
To fix this, researchers have previously used Soft Contact models. Imagine the floor is made of invisible springs. As the foot gets closer, a force gradually builds up. This provides beautiful, smooth gradients.
The catch? It’s not real. Real floors aren’t made of marshmallows. Policies trained on soft contact models often learn to exploit these “springs” to move. When you put that software on a real robot with a hard concrete floor, the robot fails.
The Solution: Analytic Smoothing
The researchers propose a “Goldilocks” solution. They want the physical fidelity of a hard contact model (so it works on a real robot) but the mathematical smoothness required for gradient-based optimization.
They introduce an Analytically Smoothed Contact Model.
Instead of relying on random sampling (like RL) to smooth out the discontinuities, they smooth the mathematical formulation of the contact force itself using a sigmoid function.
The Math of Smoothing
In a traditional hard contact solver (specifically one using a Gauss-Seidel method), we prevent penetration by clamping values. The researchers modify this by scaling the contact impulses using a sigmoid function:

Here, \(d\) is the penetration depth and \(\kappa\) controls stiffness.
- When the foot is far away, the scaling is near zero.
- As the foot approaches and slightly penetrates, the force scales up smoothly rather than instantly.
This introduces “forces at a distance.” Even before the foot technically touches the ground, the optimizer can “feel” the ground coming via the gradient. This guides the optimization process, telling the robot, “If you move your leg this way, you will make contact.”
Visualizing the Physics
Let’s look at a simple example: a mass falling and hitting the ground.

This figure is crucial for understanding the contribution. Look at the Top-Left (Hard Contact - Blue Line). The final height of the ball has a sharp corner where it hits the ground.
- Blue Line (Hard): The gradients (bottom plots) are sharp and uninformative.
- Green Line (Stochastic/RL): The noise smooths the curve, making it learnable, but requires high variance sampling.
- Orange Line (Analytic Smoothing - Ours): Notice how the orange line closely follows the green “Stochastic” line.
The Insight: The analytically smoothed model mimics the beneficial smoothing effects of RL’s stochasticity but does so deterministically. This gives us unbiased, informative gradients without needing millions of random samples.
Implementation: Differentiable Simulation with Warp
The team implemented this physics engine using NVIDIA Warp, a framework that writes Python code but compiles it to high-performance GPU kernels. Crucially, Warp supports Automatic Differentiation (AD).
The Modified Solver
Most rigid body simulators use an equation of motion like this:

To solve for the contact forces (\(f_c\)), they use a time-stepping scheme. The core innovation is in the Modified Gauss-Seidel Iteration.
Standard Gauss-Seidel iterates through contacts to resolve forces. The researchers unrolled this loop (making it differentiable) and injected their sigmoid smoothing.

By scaling the impulse \(p\) with the sigmoid function dependent on depth \(d\), the solver allows gradients to propagate back through the contact event. If the robot misses a step, the gradient can travel back through this smooth function to tell the policy: “You should have lowered your leg sooner.”
Learning the Policy
With a differentiable simulator in hand, how do we train the robot?
Simply backpropagating through a long simulation (e.g., 10 seconds of walking) is unstable. This is known as the “exploding gradient” problem. Physics is chaotic; a tiny change in force now can lead to a massive difference in position 5 seconds later.
To manage this, the authors use the Short-Horizon Actor-Critic (SHAC) algorithm.
- Short Horizons: It only looks a few steps into the future (e.g., 32 steps) to compute exact analytic gradients.
- Critic: It uses a learned “Critic” (value function) to estimate the long-term rewards beyond that short horizon.
This hybrid approach stabilizes training while still leveraging the precise gradients from the differentiable simulator.
Experimental Results
Does it actually work? The researchers conducted extensive comparisons against Soft Contact models and traditional Hard Contact models.
Comparison 1: Contact Models
They trained a robot to walk using three different contact models and then evaluated them all in a realistic “Hard Contact” environment.

Key Takeaways from Table 1:
- Soft Contact: Performs well in its own training environment (2231 return) but fails completely when transferred to Hard Contact (325 return). The robot learned to “cheat” using the soft springs of the floor.
- Hard Contact: Learning is possible, but the gradients are noisy.
- Smoothed Contact (Ours): Performs the best in training and transfers almost perfectly to the Hard Contact evaluation (2255 return).
This confirms that analytic smoothing bridges the gap: it creates gradients smooth enough to learn from, but physics realistic enough to deploy.
Comparison 2: Motion Quality
Numbers are one thing, but what does the movement look like?

On the Left (Smoothed Contact), notice the clean, periodic loops. The robot has learned a consistent, smooth gait. On the Right (Hard Contact), the trajectories are messy and erratic. Because the gradients in a hard-contact model are discontinuous, the optimizer struggles to converge on a clean solution, resulting in “twitchy” behavior.
Comparison 3: Sample Efficiency
One of the main promises of differentiable simulation is speed—specifically, needing fewer samples to learn.

In Figure 4 (Bottom), we see the return vs. number of samples.
- Blue (SHAC/DiffSim): Shoots up almost immediately.
- Green (PPO/RL): Takes nearly an order of magnitude more samples to reach the same performance.
While SHAC takes slightly longer per iteration (calculating analytic gradients is computationally heavier than just sampling), the massive reduction in required data makes it highly attractive for complex problems.
Sim-to-Real: The Ultimate Test
The team took the policy learned in their differentiable simulator and deployed it zero-shot onto an ANYmal quadruped robot.
This is harder than it sounds. The ANYmal robot has heavy legs and high-torque actuators, which creates “stiff” dynamics that are notoriously hard to differentiate through without gradients exploding.

As shown in Figure 5, the gradients for the heavy ANYmal robot (top graph) explode if the optimization horizon is too long. The authors had to carefully tune the horizon length (using \(h=12\)) to keep gradients stable.
Despite these challenges, the transfer was successful.

The robot was able to track target velocities in the real world (Green line) that closely matched the simulation (Orange line). The real-world behavior was robust, handling the complex frictional contacts of the floor without the “soft contact” failures seen in previous works.

The joint trajectories in Figure 8 further validate the model. The Real (Blue), Smoothed Sim (Green), and Hard Sim (Orange) all align closely. The fact that the Smoothed Sim overlaps so well with the Hard Sim proves that the smoothing trick didn’t ruin the physical accuracy.
Conclusion and Implications
This paper represents a significant step forward for robot learning. For years, there has been a dichotomy: use accurate physics and slow learning (RL), or use approximate physics and fast learning (DiffSim).
By introducing Analytic Smoothing, this work shows we can have both. We can retain the hard, unforgiving physics of the real world while providing the smooth, informative gradients that optimizers crave.
Key Takeaways:
- Analytic Smoothing creates a bridge between differentiability and physical realism.
- Forces at a distance (via sigmoid scaling) help guide optimizers toward contact events.
- Policies learned this way are sample efficient and produce smoother, more natural gaits than those learned on hard contact models.
- Zero-shot transfer to complex hardware is possible using differentiable simulation.
As differentiable simulators mature, we may see a shift away from the “trial and error” of massive RL runs toward more elegant, gradient-based optimization for robotic control. The days of stomping around the mountain in the dark might be coming to an end; it’s time to turn on the lights.
](https://deep-paper.org/en/paper/2404.02887/images/cover.png)