Leveraging augmented-Lagrangian techniques for differentiating over infeasible quadratic programs in machine learning

Antoine Bambade, Fabian Schramm, Adrien Taylor, Justin Carpentier

TL;DR

This paper introduces a unified framework for differentiating through both feasible and infeasible convex Quadratic Program (QP) layers in neural networks. By leveraging primal-dual augmented Lagrangian techniques, the authors allow models to "wander" into infeasible territory during training. They provide a robust C++ library, QPLayer, that is significantly faster and more numerically stable than existing state-of-the-art solvers.

The Challenge of Feasibility in Optimization Layers

Integrating optimization problems as layers within deep learning architectures (e.g., OptNet) allows researchers to embed hard physical constraints or domain-specific logic directly into a model. However, these "optimization layers" come with a major headache: feasibility.

Standard methods for differentiating through these layers via implicit differentiation typically require the optimization problem to have a valid, feasible solution at every step of training. If the neural network predicts parameters that make the optimization problem infeasible—meaning the constraints contradict each other—the solver fails, and the gradient becomes undefined. To avoid this, researchers often use restrictive architectures to "force" feasibility, which limits the model's expressive power and adds unnecessary complexity.

Proposed Method: Embracing Infeasibility

The authors propose a shift in perspective: instead of forcing feasibility, they define the output of the layer as the solution to the closest feasible problem (in an $\ell_2$ sense).

Architecture of a QP layer showing forward and backward passes.

Key technical components of their approach include:

  • Augmented Lagrangian Method: They use this optimization technique to solve a "hierarchic" problem that finds the optimal solution while simultaneously minimizing a "shift" variable. This variable measures how far the problem is from being feasible.
  • Extended Conservative Jacobian (ECJ): Since infeasible or nonsmooth problems aren't differentiable in the classical sense, the authors employ the theory of "conservative Jacobians." This provides a mathematically rigorous way to compute gradients even when the problem is at a "kink" or is primal-infeasible.
  • Unified Differentiation: Their approach consistently covers both feasible cases (reducing to standard implicit differentiation) and infeasible cases (providing a least-squares estimate).
  • QPLayer Software: They implemented these algorithms in a high-performance C++ package that interfaces seamlessly with modern learning frameworks like PyTorch.

Key Insights

  • Infeasibility is a Training Signal: By allowing the model to encounter infeasible QPs during training, the loss function can actually "drive" the parameters back toward a feasible and accurate region. This allows for simpler layer architectures that don't need complex "feasibility-forcing" logic.
  • Learning Linear Programs (LPs): Traditional QP layers often require a strictly positive definite Hessian (the "curvature" of the objective), making it hard to learn LPs. Because the authors' method is based on the augmented Lagrangian, it handles LPs naturally, which proves highly effective for logical tasks like Sudoku.
  • Numerical Stability: Interior-point methods (used by competitors like OptNet) can become unstable near constraint boundaries. The augmented Lagrangian approach is more robust to these "degenerate" conditions, allowing for much higher learning rates without the model crashing.

Experimental Results

The authors evaluated their approach on several standard benchmarks, including random QPs, 9x9 Sudoku, MNIST digit classification, signal denoising, and a Cart-Pole control simulation.

Prediction error comparison across epochs.
  • Speedup: In random QP benchmarks (batch size 100), QPLayer was ~4x faster than OptNet and orders of magnitude faster than CvxpyLayer.
  • Accuracy: On the Sudoku task, QPLayer achieved significantly fewer prediction errors (33 errors) compared to OptNet (162 errors) and CvxpyLayer (1531 errors) by successfully learning the task as a Linear Program.
  • Robustness: In MNIST and denoising tasks, QPLayer remained stable at learning rates where OptNet produced NaNs or failed to converge.
  • Efficiency: For the Sudoku task, a single training batch took ~0.45 seconds with QPLayer, compared to ~8.99 seconds with OptNet.

Limitations and Future Work

While the authors demonstrate strong empirical performance, they note that proving the chain rule for Extended Conservative Jacobians in the most general case remains an open theoretical gap. Furthermore, the current work is strictly limited to convex quadratic programs; extending this to non-convex problems would be significantly more challenging. In the future, the authors plan to extend the QPLayer framework to handle a broader range of optimization problems, specifically Second-Order Cone Programs (SOCPs), which are common in robotics and structural engineering.

Summary updated

BibTeX
@inproceedings{bambade2024leveraging,
  author = {Antoine Bambade and Fabian Schramm and Adrien Taylor and Justin Carpentier},
  title = {{Leveraging augmented-Lagrangian techniques for differentiating over infeasible quadratic programs in machine learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=YCPDFfmkFr},
}
Figure