lapanda: A Matrix-Free Differentiable Solver for Nonconvex Constrained Optimization Layers
Authors: Yuankun Chen, Zifei Nie, Kangyu Lin, Ján Drgoňa, Liang Wu
Organizations: School of Artificial Intelligence, Jilin University, China · Graduate School of Informatics, Kyoto University, JPN · Department of Civil and Systems Engineering, Johns Hopkins University, USA
Differentiable optimization brings the structural guarantees of mathematical optimization to network pipelines, allowing them to be trained end-to-end. However, its application remains challenging for nonconvex constrained problems, as existing differentiable solvers often suffer from limited modeling expressiveness due to their reliance on specialized problem structures, while also incurring substantial computation time and memory overhead in both the forward and backward passes. To address these challenges, we propose lapanda, a matrix-free differentiable solver for nonconvex optimization with general constraints. It reformulates the problem to a sequence of augmented Lagrangian subproblems, each handled by a first-order inner solver through a proximal averaged quasi-Newton algorithm with adaptive linesearch, thus enabling efficient forward optimization. We establish local well-posedness of the solution map and convergence of the outer iterations, and further derive a sensitivity alignment between the original problem and the final subproblem in the backward pass, demonstrating that the subproblem sensitivity, which can be computed efficiently in a matrix-free manner, provides a principled approximation to the exact optimizer sensitivity. We evaluate lapanda on nonconvex constrained Rosenbrock benchmarks, imitation learning with several representative constrained optimal control problems, and embedded robotic obstacle-avoidance tasks. Compared with state-of-the-art differentiable solvers, lapanda delivers substantial reductions in computation time and memory footprint while maintaining reliable constraint satisfaction and learning performance.
Figures & tables
Solver
Target problem
Hard constraints
Matrix-free
Platform
lapanda (Ours)
General NLP
General
✓
C / MATLAB / Python
CasADi (2019)
General NLP
General
✗
C / MATLAB / Python
acados (2025)
General OCP
General
✗
C / MATLAB / Python
TurboMPC (2026)
General OCP
General
✗
Python
SafePDP (2021)
General OCP
General
✗
Python
PANDA (2026)
Composite NLP
Prox.-friendly
✓
MATLAB
Table 1: Comparison of representative differentiable optimization solvers.
Figure 1: Overview of the lapanda framework.
n
Forward time (ms)
Backward time (ms)
Memory (MB)
lapanda
Explicit
CasADi
lapanda
Explicit
CasADi
lapanda
Explicit
CasADi
100
8.23
–
36.50
4.04
4.22
3.04
1.78
5.01
17.55
200
14.37
–
108.19
5.89
10.23
17.05
2.06
7.78
29.39
500
49.75
–
496.03
14.36
51.26
245.99
3.12
25.32
84.70
1000
200.00
–
1968.78
37.36
218.21
2325.16
5.31
79.65
249.66
Table 2: Matched-accuracy comparison on the constrained Rosenbrock benchmark.
Figure 2: Normalized constraint values xi2+xi+12/ri(θ) for n=200 .
Figure 3: Open-loop imitation learning results on different constrained OCPs.
Figure 4: Closed-loop imitation learning results including training loss and policy evolution.
OCP
Method
Fwd. time (ms)
Bwd. time (ms)
Total time (ms)
Memory (MB)
CartPole
lapanda
5.10
0.09
5.20
1.64
SafePDP
22.06
9.65
31.71
7.71
Quadrotor
lapanda
1.20
0.24
1.45
1.79
SafePDP
29.86
13.41
43.27
9.23
TurboMPC-CPU
10.46
7.74
18.20
241.30
TurboMPC-GPU
21.78
2.28
24.06
336.48
Table 3: Detailed performance comparison of different solvers on closed-loop OCP benchmarks.