[Paper Review] Differentiable Physics Simulations with Contacts: Do They Have Correct Gradients w.r.t. Position, Velocity and Control?
This paper evaluates the accuracy of gradients in differentiable physics simulators with contact mechanics, comparing four formulations—LCP, convex optimization, compliant models, and position-based dynamics—on rigid body collisions. It finds that none of the studied simulators produce gradients matching analytical derivatives, yet some still enable successful learning, revealing a critical gap in gradient correctness despite practical utility in optimization tasks.
In recent years, an increasing amount of work has focused on differentiable physics simulation and has produced a set of open source projects such as Tiny Differentiable Simulator, Nimble Physics, diffTaichi, Brax, Warp, Dojo and DiffCoSim. By making physics simulations end-to-end differentiable, we can perform gradient-based optimization and learning tasks. A majority of differentiable simulators consider collisions and contacts between objects, but they use different contact models for differentiability. In this paper, we overview four kinds of differentiable contact formulations - linear complementarity problems (LCP), convex optimization models, compliant models and position-based dynamics (PBD). We analyze and compare the gradients calculated by these models and show that the gradients are not always correct. We also demonstrate their ability to learn an optimal control strategy by comparing the learned strategies with the optimal strategy in an analytical form. The codebase to reproduce the experiment results is available at https://github.com/DesmondZhong/diff_sim_grads.
Motivation & Objective
- To assess whether differentiable physics simulators compute correct gradients w.r.t. position, velocity, and control in contact-rich rigid body dynamics.
- To compare the performance of four major differentiable contact formulations: LCP, convex optimization, compliant models, and PBD.
- To investigate why some simulators with incorrect gradients still succeed in learning optimal control strategies.
- To provide a benchmark with analytical gradients for evaluating future differentiable physics tools.
Proposed method
- The authors implement four differentiable contact models—LCP, convex optimization, compliant models, and PBD—within a unified simulation framework.
- Analytical gradients are derived in closed form for three benchmark tasks involving frictionless rigid body collisions.
- Simulations are run with each implementation, and gradients are compared against the analytical reference using gradient difference metrics.
- A gradient-based optimization task is performed to learn optimal control inputs, with results compared against the known analytical optimal control profile.
- The study evaluates the impact of spring stiffness in compliant models on learning stability and convergence.
- Code for reproducing all experiments is released to enable benchmarking and future validation.
Experimental results
Research questions
- RQ1Do differentiable physics simulators compute correct gradients w.r.t. position, velocity, and control in contact events?
- RQ2How do the gradients from LCP, convex optimization, compliant models, and PBD formulations compare to analytical gradients in a controlled setting?
- RQ3Why do some simulators with incorrect gradients still succeed in learning optimal control strategies?
- RQ4How does the choice of contact model affect the stability and convergence of gradient-based optimization?
- RQ5Can the discrepancy between computed and true gradients be quantified and linked to optimization performance?
Key findings
- None of the tested differentiable simulators produced gradients that matched the analytical gradients in the benchmark tasks, indicating a fundamental issue in gradient computation.
- Only the two PBD-based implementations produced gradients that were close to the analytical reference, suggesting PBD may offer more accurate gradient estimation.
- Despite incorrect gradients, several simulators successfully learned optimal control strategies, converging to losses near the analytical optimum.
- Compliant models with low stiffness produced high initial losses due to soft contact representation, while high stiffness led to unstable learning and failure to converge.
- Simulators without time-of-impact (TOI) handling or with poor gradient computation failed to learn meaningful control sequences, often resulting in zero control actions.
- The results highlight a critical disconnect: even with incorrect gradients, optimization can succeed, raising questions about the reliability of current differentiable simulators for physics-based learning tasks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.