Differentiable Optimization Layers for End-to-End Learning

This direction is no longer present in the current build. Its last version stays readable and citable here.

Version 1 of 164 papers67 conceptsfrozen 2026-10-04

In traditional machine learning pipelines, we often separate prediction from decision-making. A model might predict tomorrow’s energy prices, and a separate optimization algorithm then uses those prices to decide how to discharge a battery. The problem is that the predictive model is usually trained to minimize a generic error metric, like Root Mean Square Error (RMSE), which doesn't know or care about the downstream "task loss"—the actual money lost due to a suboptimal battery schedule.

Differentiable optimization layers bridge this gap. By embedding the optimization problem directly into the neural network architecture, we can backpropagate through the "argmin" operator. This allows the model to learn parameters that minimize the final decision regret, effectively training the predictor to be "smart" about the specific errors that matter most for the task.

The Problem with Unrolling Solvers

To train a network containing an optimization problem, we need the gradient of the optimal solution $z^*$ with respect to the input parameters $\theta$. A naive approach is "algorithm unrolling," where you treat each iteration of an optimizer (like Gradient Descent) as a layer in a very deep network and use standard automatic differentiation.

However, as Brandon Amos and J. Zico Kolter point out in OptNet, unrolling is computationally expensive and memory-intensive because you must store every intermediate step of the solver. Furthermore, it can be numerically unstable, especially if the solver requires many iterations to converge.

Intuition: Differentiating the Result, Not the Process

The key insight of this research direction is that we don't need to know how the solver found the optimum; we only need to know the properties of the optimum itself.

For a constrained optimization problem, the optimal solution must satisfy the Karush-Kuhn-Tucker (KKT) conditions. These conditions are a set of equations that relate the objective function, the constraints, and the Lagrange multipliers at the point of optimality. By applying the Implicit Function Theorem to these KKT conditions, we can analytically derive the sensitivity of the optimal solution to the input parameters.

As Akshay Agrawal demonstrates in Differentiating through Log-Log Convex Programs, this "implicit differentiation" provides exact gradients without the overhead of unrolling. It treats the optimizer as a black box that outputs a solution, and then uses a single, efficient linear system solve to find the gradients needed for backpropagation.

Decision-Focused Learning

This mathematical trick enables Decision-Focused Learning (DFL). In Task-based End-to-end Model Learning, Priya L. Donti and colleagues show that when a model is trained end-to-end through a downstream optimization task, it learns to prioritize accuracy in the features that drive the decision.

For example, in a power grid scheduling task, a standard model might try to predict all loads equally well. A decision-focused model, however, might realize that overestimating load during peak hours is much more "expensive" for the grid than underestimating it during off-peak hours. By differentiating through the grid's economic dispatch optimization, the model learns this asymmetry automatically. Bryan Wilder extended this concept to combinatorial problems in Melding the Data-Decisions Pipeline, using continuous relaxations to make discrete decisions differentiable.

Applications Across Domains

The ability to "snap" neural network outputs to physically or logically consistent structures has led to breakthroughs in several fields:

  • Robotics and Control: Akshay Agrawal 0001 and Bartolomeo Stellato show in Learning Convex Optimization Control Policies how to automatically tune Model Predictive Control (MPC) parameters. Similarly, Ming Xu introduced IDOC to handle long-horizon trajectories with linear scaling complexity.
  • Computer Vision: In Surface Snapping, Yuan-Ting Hu and Raymond A. Yeh use an optimization layer to force 3D mesh reconstructions to align with predicted surface normals, resulting in much sharper geometric details.
  • Game Theory: Chun Kai Ling and Fei Fang use differentiable solvers to learn the hidden payoffs of games by observing how agents play, as seen in What Game Are We Playing?.
  • Large Language Models: Even in the world of LLMs, Philipp Becker and Gerhard Neumann introduced TROLL, which replaces heuristic clipping in Reinforcement Learning with a differentiable trust-region projection layer to improve stability.

Scaling the Idea

While early work focused on small quadratic programs, the field is moving toward general-purpose frameworks. Andrew W. Rosemberg and others have developed DiffOpt.jl, a toolbox that makes sensitivity analysis a standard feature for a wide range of solvers. By treating optimization not as a final step, but as a differentiable component of the model itself, researchers are creating systems that don't just predict the world, but act optimally within it.

Papers in this version

Showing 60 of 64 papers.

History & citationVersion 1 · 2026-10-04

No longer present in the current build · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_differentiable_optimization_layers_for_e_1986da92,
  title = {Differentiable Optimization Layers for End-to-End Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/differentiable-optimization-layers-for-end-to-end-learning/rdr_1986da92fc4843dbaf07cb22279c9a88},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-18},
}

This exact version (version 1, frozen text):

@misc{lacuna_differentiable_optimization_layers_for_e_1986da92_v1,
  title = {Differentiable Optimization Layers for End-to-End Learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/differentiable-optimization-layers-for-end-to-end-learning/rdr_1986da92fc4843dbaf07cb22279c9a88/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-18},
}