Research
Amortising Trajectory Optimisation for Residual MPC via Implicit Contact Differentiation
Contact-rich trajectory optimisation needs gradients of a simulator step, but contact is resolved by an iterative constrained solve, so standard reverse-mode automatic differentiation must store…

- arXiv
- 2607.24959 · Preprint · not peer-reviewed
- Published
- 2026-07-27
- Authors
- Daniel Layeghi, Thomas Corbères, Calum Arnott, Aditya Kamireddypalli, Hashim Al-Obaidi, Steve Tonneau, Michael Mistry
In plain words
Contact-rich trajectory optimisation needs gradients of a simulator step, but contact is resolved by an iterative constrained solve, so standard reverse-mode automatic differentiation must store every solver iteration for every contacted step. Tightening the solve therefore costs memory and leaves room for fewer parallel trajectories, while truncating it differentiates an under-solved contact response.
Key results
- Solver-iteration memory is nearly eliminated. Compiled temporary memory changes by less than 4% for IFT from one to ten solver iterations, versus a 10.6× growth for unrolled AD.
- Lower memory as contacts and dimension grow. IFT uses 20× less memory at 256 active contacts and 6× less at 16 contacts with 96 DoF.
AI summary
Overview
Research area: Robotics — contact-rich trajectory optimisation, differentiable physics simulation, and model-based control (residual MPC).
Technical level: Advanced. The paper assumes familiarity with the Implicit Function Theorem, Karush–Kuhn–Tucker (KKT) systems, reverse-mode automatic differentiation, iLQR/DDP, and MuJoCo's regularised contact model.
Scope (one sentence): The paper replaces unrolled automatic differentiation of MuJoCo MJX's iterative contact solver with a residual-based implicit derivative, and then uses the resulting memory savings to distil batched full-horizon iLQR teachers into a policy that guides short-horizon residual iLQR on three simulated robots.
What This Paper Is About
Contact-rich trajectory optimisation needs gradients of a simulator step, but contact is resolved by an iterative constrained solve, so standard reverse-mode automatic differentiation must store every solver iteration for every contacted step. Tightening the solve therefore costs memory and leaves room for fewer parallel trajectories, while truncating it differentiates an under-solved contact response. The paper removes this convergence–parallelism trade-off by differentiating a stationarity residual at the converged solution instead of the solver trace, and then exploits the freed memory to amortise long-horizon optimisation into a policy for short-horizon model predictive control.
Key Contributions
-
An AD-assisted implicit backward pass for MJX contact. The authors derive the sensitivity of the tolerance-converged contact acceleration from the stationarity residual of MuJoCo's regularised (round Coulomb cone) contact solve using the Implicit Function Theorem. The forward solver is unchanged, no hand-assembled KKT system is required, and the backward pass stores nothing that grows with forward solver iterations. It is implemented with
jax.lax.custom_root, with a dense QR solve applying the transposed Jacobian inverse. -
Validation and memory characterisation of the derivative. Whole-rollout gradients are checked against central finite differences on an 80-step ball bounce-to-target rollout, and compiled temporary memory is compared against unrolled AD and finite differences as solver iterations, active contact count, and generalised velocity dimension vary.
-
Optimiser distillation for residual MPC. Batched full-horizon iLQR generates and continually refreshes contact-rich teacher trajectories; the optimised actions are distilled into a policy. At deployment the policy supplies the long-horizon nominal action while short-horizon residual iLQR computes local model-based corrections and feedback gains through the differentiable contact model.
-
Open-source release of the implementation (github.com/calumarnott/mujoco).
Main Findings
-
Gradient agreement at converged solver effort. On a fixed 80-step open-loop rollout (timestep 0.01 s, controls in R³, 46 steps invoking contact, 480 finite-difference perturbations all preserving the nominal contact schedule), IFT and unrolled AD at K = 5 both agree with whole-rollout central FD throughout the horizon, including during active contact. Shorter unrolls (K = 1 and K = 2) retain errors concentrated around contact.
-
Solver-iteration memory is nearly eliminated. Compiled temporary memory changes by less than 4% for IFT from one to ten solver iterations, versus a 10.6× growth for unrolled AD.
-
Lower memory as contacts and dimension grow. IFT uses 20× less memory at 256 active contacts and 6× less at 16 contacts with 96 DoF. The authors note dense QR storage gives roughly quadratic IFT memory growth in the generalised velocity dimension, and that IFT completes the largest tested problem while unrolled AD and parallel finite differences hit GPU out-of-memory first. Measurements used batched primitive-contact steps at batch size B = 1024 on a 4 GiB GPU, with K = 5 for the contact-count and dimension panels.
-
iLQR beats Adam for the optimisation stage. After 20 optimisation iterations on 100 trajectories per task across four contact-rich tasks, iLQR achieves lower mean running cost and tighter 10th–90th percentile ranges than Adam on all four tasks, with the clearest separation on Hand and Unitree. Full-horizon iLQR is therefore used as the teacher.
-
Policy guidance raises short-horizon success. At a planning horizon of H = 6 with a 10 ms simulation and control timestep, over 160 randomised trials per controller and horizon, policy guidance improves success by 28–98 percentage points across Finger, Franka, and Unitree relative to standard iLQR.
-
Franka shows the largest gap. Standard short-horizon iLQR remains near zero success across the evaluated horizons, whereas the hybrid controller succeeds with substantially less lookahead: the policy supplies the long-horizon pushing strategy and iLQR corrects the local box contact.
-
Two task-specific caveats. On Finger, the policy-only controller at H = 0 can outperform the shortest residual horizons, because a myopic residual optimiser can perturb a policy that already encodes the required manoeuvre; iLQR helps again once its horizon provides enough lookahead. On Unitree, very short-horizon control can obtain low cost while sitting near a stationary configuration and avoiding orientation penalties, so success (base height ≥ 0.15 m and forward position ≥ 1.0 m) is the more informative metric than cost.
Methodology in Plain English
Step 1 — Differentiate the answer, not the search. MJX finds contact forces by iterating a Newton-type or nonlinear conjugate-gradient solver until a tolerance is met. Unrolled AD records every one of those iterations and replays them backwards. Instead, the authors write down the residual that the solver drives to zero — the force imbalance at the contact solution — and use the Implicit Function Theorem to say: if the residual is zero at the answer, then the derivative of the answer with respect to the inputs can be recovered from the Jacobian of the residual alone. In reverse mode this requires one transposed linear solve and one vector–Jacobian product, not a stored iteration trace. Automatic differentiation supplies the residual's Jacobians, so no solver-specific KKT derivation is written by hand, and the forward solver is left untouched. The derivative is local: it is valid within a fixed contact set and smooth friction region, and may change at contact creation, removal, or friction-mode transitions.
Step 2 — Check the derivative and measure the memory. The authors compare against finite differences (repeated simulation in each input direction) and against unrolled AD, in double precision, on a rollout containing free flight, floor impact and separation, sustained contact, and a floor–wall interaction. A separate parallel per-step finite-difference implementation is used only to study memory scaling.
Step 3 — Optimise trajectories in parallel. With the memory freed, the authors batch full-horizon trajectory optimisation in MJX, comparing a first-order method (Adam on the whole control sequence, with checkpointing to trade recomputation for memory) against iLQR, which linearises the dynamics using the implicit contact Jacobians and runs a Riccati backward recursion with a line search batched over trajectories and step sizes.
Step 4 — Distil the optimiser into a policy. Full-horizon iLQR acts as an online teacher: each epoch samples new initial conditions and goals, keeps only successful trajectories, and regresses the policy onto the complete optimised action with a squared-error loss. A target policy is updated by exponential averaging to keep the optimiser's rollout distribution from shifting abruptly. At deployment the applied control is the (stop-gradient) policy action plus an iLQR-optimised residual, with a quadratic penalty on the residual so the correction stays close to the policy.
Step 5 — Evaluate closed loop. Three tasks with randomised initial conditions: Finger (a 2-DoF arm rotates a spinner to a target angle, error ≤ 0.4 rad), Franka (a 7-DoF arm pushes a box to a fixed target region, planar distance ≤ 0.10 m), and Unitree (an A1 quadruped accelerates from rest toward 1 m/s). Each controller and horizon is evaluated on 160 randomised trials.
Why This Matters
Impact on research. The paper decouples contact-gradient memory from contact-solver effort, which directly targets the convergence–parallelism trade-off that limits batched differentiable-simulation pipelines. Because the method is modular — residual plus AD, no solver-specific backward derivation — it is a template other iterative contact solvers could follow. It also reframes the relationship between learning and planning: rather than a policy replacing the optimiser or a residual correcting a fixed controller, the distilled policy carries the long-horizon plan and a short-horizon optimiser supplies contact-aware local feedback and gains.
Real-world applications (plausible, not evaluated in the paper):
- Legged locomotion, where short receding-horizon control on hardware benefits from a policy that already encodes gait-level strategy.
- Robotic manipulation with pushing and contact transitions, such as the box-pushing Franka setting.
- Dexterous and in-hand manipulation on the Finger-style spinner tasks, where contact schedules switch repeatedly.
- GPU-parallel simulation tooling and offline trajectory generation for robot learning pipelines.
Industry relevance. The practical payoff is batch capacity: less per-step backward memory means more parallel trajectories on the same accelerator, which matters for offline teacher generation and for deployment-time MPC with tight compute budgets. The 28–98 percentage-point success gain at H = 6 speaks to shorter lookahead, which translates into lower online optimisation cost. The open-source release lowers the barrier to adoption, though the work is evaluated entirely in simulation and the paper reports no hardware experiments.
Future Directions
- Handling non-smooth events explicitly. The implicit derivative is local to a fixed contact set and smooth projection region and need not remain valid across contact creation, contact removal, or friction-mode changes; extending or complementing it at these transitions is left open.
- Reducing the remaining memory costs. The authors note dense QR storage produces roughly quadratic IFT memory growth in the generalised velocity dimension, and that batching and contact-workspace costs persist; a matrix-free or structured solve could push the largest problems further.
- Combining with terminal-value and planning-prior methods. The paper explicitly notes that terminal-value approaches such as POLO and TD-MPC2 are complementary and could reuse the same full-horizon teacher trajectories.
- Validation beyond simulation and beyond these three tasks. The evaluation covers Finger, Franka, and Unitree in simulation; hardware deployment, and whether the H = 6 gains transfer, are not reported.
Target Audience
Robotics and machine-learning researchers working on differentiable physics, contact-implicit trajectory optimisation, and model-based reinforcement learning; practitioners building batched GPU simulation pipelines in MuJoCo/MJX who are blocked by backward-pass memory; and engineers designing hybrid policy-plus-MPC controllers who want to understand when a learned nominal action plus a short-horizon optimiser beats planning alone. Readers need comfort with implicit differentiation and optimal control to follow Sections III and IV, though the empirical results in Section V are readable on their own.
Authors’ abstract
Differentiable simulation can accelerate contact-rich trajectory optimisation by exposing local sensitivities of task outcomes to controls. Existing approaches either use finite differences, which are expensive and step-size sensitive; differentiate iterative contact solvers by unrolling automatic differentiation (AD), which stores a growing computation trace; or require intricate, solver-specific KKT sensitivity derivations. We introduce an AD-assisted implicit derivative…
The full abstract on arXivRelated papers
- ContactKernels: Adaptive Proposals using Geometry-COnditioned Wrenches for Contact-Rich Manipulation 2026-09-26 · cs.RO · Also by Aditya Kamireddypalli, Steve Tonneau
- Differentiable Contact Dynamics for Legged Locomotion: Policy Learning and Contact-Implicit Trajectory Optimization 2026-10-26 · cs.RO · Key terms of the title in common
- ALFRED: Requirement-driven development of an open-source mobile manipulator for long-term plant monitoring 2026-10-01 · cs.RO · Also by Steve Tonneau
- Contact-Implicit Whole-Body Trajectory Optimization for Dynamic Humanoid Locomotion on Parameterizable Uneven Terrain 2026-11-03 · cs.RO · Key terms of the title in common
- A Unified Fractal Impedance Control Framework 2026-11-05 · cs.RO · Also by Michael Mistry