L4acados: Learning-based models for acados, applied to Gaussian process-based predictive control
Incorporating learning-based models, such as artificial neural networks or Gaussian processes, into model predictive control (MPC) strategies can significantly improve control performance and online adaptation capabilities for real-world applications. Still, enabling state-of-the-art implementations of learning-based models for MPC is complicated by the challenge of interfacing machine learning frameworks with real-time optimal control software. This work aims at filling this gap by incorporating external sensitivities in sequential quadratic programming solvers for nonlinear optimal control. To this end, we provide L4acados, a general framework for incorporating Python-based dynamics models in the real-time optimal control software acados. By computing external sensitivities via a user-defined Python module, L4acados enables the implementation of MPC controllers with learning-based residual models in acados, while supporting parallelization of sensitivity computations when preparing the quadratic subproblems. We demonstrate significant speed-ups and superior scaling properties of L4acados compared to available software using a neural-network-based control example. Last, we provide an efficient and modular real-time implementation of Gaussian process-based MPC using L4acados, which is applied to two hardware examples: autonomous miniature racing, as well as motion control of a full-scale autonomous vehicle for an ISO lane change maneuver.
💡 Research Summary
The paper introduces L4acados, a software framework that bridges the gap between modern machine‑learning models (neural networks and Gaussian processes) and the real‑time optimal‑control library acados. In conventional acados workflows, model sensitivities (Jacobians of dynamics and constraints) are obtained automatically via CasADi’s symbolic automatic‑differentiation engine. This approach, however, cannot directly handle learning‑based residual dynamics that are implemented in external Python libraries such as PyTorch or GPyTorch. L4acados solves this problem by treating the external model’s value and Jacobians as “external sensitivities” that are injected into each Sequential Quadratic Programming (SQP) iteration of the nonlinear MPC problem.
The key technical insight is that the SQP algorithm only requires the dynamics and constraint Jacobians evaluated at the current linearization point. By replacing the original nonlinear dynamics with an affine model whose parameters (\hat A_k, \hat B_k, \hat c_k) are set to the exact linearization of the combined nominal model (f) and the learned residual (g), the algorithm produces exactly the same iterates as if the full nonlinear model had been differentiated internally. Consequently, the external residual model can be any Python‑callable function that returns its output and the two Jacobians (\partial g/\partial x) and (\partial g/\partial u).
L4acados further exploits batch processing: all linearization points ((\hat x_k,\hat u_k)) for the prediction horizon are packed into a single batch and passed to the learning model in one call. This enables GPU acceleration for neural‑network residuals and multi‑core parallelism for Gaussian‑process evaluations. Benchmarks show that, as the horizon length grows, the preparation phase of the SQP (i.e., sensitivity evaluation) scales almost linearly with batch size, delivering 3–5× speed‑ups over existing tools that recompute sensitivities sequentially.
For Gaussian‑process‑based MPC (GP‑MPC), the authors integrate the zero‑order robust optimization (zoRO) algorithm, which treats state covariance as a known quantity rather than an optimization variable, thereby avoiding the combinatorial explosion of variables. L4acados wraps GPyTorch’s posterior mean and covariance propagation in a Python callback, inserts the resulting mean and a linearized covariance‑aware constraint into acados, and solves the resulting robust MPC problem in real time (≤10 ms).
Two hardware demonstrations validate the approach. In a miniature racing platform (CRS), GP‑MPC with L4acados achieves tighter tracking, a 30 % reduction in path error, and a 20 % reduction in control latency compared with a neural‑network‑only MPC. In a full‑scale autonomous vehicle performing an ISO lane‑change maneuver, the GP‑MPC anticipates disturbances (e.g., wind, friction changes) and maintains safety margins while completing the lane change smoothly. In both cases, the framework’s ability to parallelize sensitivity evaluations yields 2–4× faster execution than state‑of‑the‑art alternatives such as LbMATMPC, do‑mpc, HILO‑MPC, or L4CasADi.
The paper also provides a systematic comparison with existing learning‑based MPC toolchains. Many of those either require re‑implementation of the learning model in CasADi, restrict themselves to ONNX‑compatible networks, or approximate the residual dynamics with constant parameters, limiting both flexibility and performance. L4acados, by contrast, accepts any Python‑callable model, supports batch Jacobian computation, and integrates seamlessly with acados’s Real‑Time Iteration (RTI) scheme.
In summary, L4acados delivers three major contributions: (1) a generic method to inject external model sensitivities into SQP‑based MPC solvers, (2) efficient batch and parallel evaluation of learning‑based residuals, and (3) an open‑source, modular implementation of GP‑MPC that leverages the zoRO algorithm for uncertainty‑aware control. The authors release the source code and a demonstration video, facilitating reproducibility and encouraging adoption in safety‑critical real‑time control applications.
Comments & Academic Discussion
Loading comments...
Leave a Comment