Abstract
Integrating Model Predictive Control (MPC) into machine learning pipelines requires efficient and accurate computation of solution sensitivities. This paper presents a high-performance implementation for differentiable Nonlinear MPC (NMPC) within the acados framework. By leveraging the Implicit Function Theorem (IFT) and exploiting the specific stage-wise structure of optimal control problems, the authors achieve speedups exceeding 3x over state-of-the-art solvers. Crucially, the method addresses the "approximate Hessian pitfall," ensuring gradient accuracy even when using efficient solvers like Gauss-Newton for the nominal solution.
Introduction
Model Predictive Control (MPC) is essential for modern robotics due to its ability to handle complex constraints and nonlinear dynamics. However, "Learning-based MPC"—where the controller is embedded in a Reinforcement Learning or Imitation Learning loop—demands that the controller be differentiable. We must compute how optimal control actions $u^*$ change with respect to parameters $\theta$ in the model, cost function, or constraints.
Existing differentiable MPC tools often struggle with limited scope (convex only), poor efficiency (not exploiting control structure), or inaccuracy (using Hessian approximations for sensitivities). This work addresses these gaps by providing an open-source, structure-exploiting sensitivity solver.
Methodology
The core of the approach is the application of the Implicit Function Theorem (IFT) to the Karush-Kuhn-Tucker (KKT) conditions of the Nonlinear Program (NLP) representing the MPC problem.
The Two-Solver Approach and Hessian Accuracy
A key contribution is the "Two-Solver Approach." While Hessian approximations like Gauss-Newton are efficient for finding the nominal solution $z^*$, they often lead to highly inaccurate sensitivities. The authors propose using a nominal solver for the solution, followed by a dedicated sensitivity solver that employs the exact Hessian at $z^*$.
As shown in the figure above, using an approximate Hessian (IFT approx. Hess.) results in gradients that deviate significantly from the true sensitivities (finite diff. and $\tau_{min} = 0$).
Handling Non-smoothness
The solution map of an MPC problem is often non-differentiable at "active set changes"—points where a constraint becomes active. The authors utilize the barrier parameter ($\tau$) from Interior-Point Methods (IPM) to naturally "smooth" these kinks, providing a principled way to compute gradients in the vicinity of constraints.
Results and Performance
The implementation is integrated into acados, utilizing high-performance linear algebra (BLASFEO) to ensure computational complexity scales linearly with the time horizon $O(N)$.
Computational Efficiency
In benchmarks against mpc.pytorch and cvxpygen, acados demonstrated superior performance. For a bounded LQR task, it was 9.2x to 31x faster for the nominal solve and 3.6x to 19x faster for adjoint sensitivities.
The figure above illustrates that computing a single adjoint sensitivity (how a scalar loss changes w.r.t. parameters) is roughly 2.5x faster than computing the full forward Jacobian. This is particularly beneficial for backpropagation in machine learning.
Conclusion
This work provides a robust and efficient bridge between classical control and machine learning. By addressing the accuracy issues of approximate Hessians and exploiting the inherent structure of OCPs, the authors enable high-performance differentiable NMPC. Future work will focus on extending these sensitivities through internal integrator stages and formalizing the handling of non-smoothness using conservative Jacobians.
The code is open-source and available as part of the acados framework.
Summary updated