Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.An optimization inside an optimization
A coach picks a training plan. The athlete trains as well as possible under that plan, and then the coach judges the result in competition and adjusts the plan. The athlete solves the inner problem (train best given the plan); the coach solves the outer problem (pick the plan whose trained athlete wins).
To improve the plan quickly, the coach wants to know: “if I change the plan a little, how much better will the trained athlete do?” Answering that without retraining from scratch each time is what implicit differentiation does.
Hyperparameter tuning, meta-learning (learning to adapt fast to a new robot or terrain), learning cost functions from demonstrations (inverse optimal control), differentiable MPC layers inside neural networks, and robust design against adversaries are all bilevel problems.
- 1. In hyperparameter tuning, the inner problem is…
- 2. The outer problem judges the result on…
- 3. Implicit differentiation tells you…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Bilevel problems
The hypergradient is . The hard part is .
Implicit function theorem
satisfies the optimality condition . Differentiate this identity in :
You only need the optimality condition, not a formula for . Example: for ridge, , so with .
- 1. Implicit differentiation starts from…
- 2. For ridge, dw*/dλ =
- 3. The hypergradient combines dw*/dλ with…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.Two ways to compute hypergradients
- Implicit: solve the inner problem to optimality, then do one linear solve with the inner Hessian. Memory is independent of how the inner problem was solved. It’s exact at an exact optimum.
- Unrolled (iterative) differentiation: run inner steps and backpropagate through them (or carry forward-mode derivatives). It works for inexact or non-converged solvers but costs memory ∝ , and truncation biases it (short-horizon bias; Wu et al., 2018).
Large-scale inverse-Hessian products
When is too large to factor:
- Conjugate gradient with Hessian-vector products (A2.4-7);
- Neumann series (Lorraine, Vicol and Duvenaud, 2020), which is exactly what unrolled GD computes.
Applications
- Hyperparameter optimization: weight decay, data augmentation strength, per-parameter learning rates.
- Meta-learning: MAML’s outer loss is post-adaptation performance (Finn, Abbeel and Levine, 2017). Implicit MAML uses the implicit theorem (Rajeswaran et al., 2019).
- Inverse optimal control / IRL: learn cost weights whose optimal plans match demonstrations.
- Differentiable optimization layers (OptNet, differentiable MPC): differentiate through a QP’s KKT system (Amos and Kolter, 2017; Amos et al., 2018).
- 1. Unrolled differentiation's memory grows with…
- 2. Truncated unrolling tends to…
- 3. OptNet differentiates through…
Level 3: Advanced
★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.Implicit function theorem for argmin
Let . If and is invertible (for example, strong convexity), then near there’s a unique smooth with . Differentiating gives . ∎
Ridge hypergradient
with . Differentiating: , so . Then . ∎
Unrolled converges to implicit
For a quadratic inner loss with Hessian , GD with forward-mode derivatives gives , a truncated Neumann series for . It converges geometrically to the implicit hypergradient when . Scalar example: gives . ∎
Exercise 3.1: The limit of η Σ(1 − ηa)ʲ with a = 4
The geometric series sums to , provided .
- 1. The implicit function theorem for argmin requires the inner Hessian to be…
- 2. Unrolled GD derivatives form a truncated…
- 3. η Σ (1 − ηa)ʲ converges to 1/a when…
Level 4: Expert
★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.Learning what an expert cares about
An expert’s planner for a 1-D cart minimizes position error plus times control effort. We observe four of the expert’s (slightly noisy) control sequences, but not . Treat our own planner, , as the inner problem. The outer loss is the mismatch with the demonstrations. The implicit hypergradient drives gradient descent on from 3.0 to 0.2999 (true 0.3). This is inverse optimal control, the core of learning-from-demonstration (Ratliff, Bagnell and Zinkevich, 2006; Englert et al., 2017).
Bilevel optimization in AI, robotics and aerospace
- Meta-learning for fast adaptation of robot controllers to new payloads or terrains (MAML; Finn et al., 2017. Implicit MAML; Rajeswaran et al., 2019).
- Differentiable MPC as a policy layer trained end to end (Amos et al., 2018). Differentiable QP layers (OptNet; Amos and Kolter, 2017).
- Inverse optimal control and IRL for driving and manipulation from demonstrations (Ratliff, Bagnell and Zinkevich, 2006, maximum-margin planning; Levine and Koltun, 2012).
- Hyperparameter optimization at scale: implicit hypergradients for millions of hyperparameters (Lorraine, Vicol and Duvenaud, 2020).
- Stackelberg games and robust design: a designer anticipates an optimal adversary or follower (Colson, Marcotte and Savard, 2007).
References
- B. Colson, P. Marcotte, G. Savard (2007). “An overview of bilevel optimization.” Annals of Operations Research, 153.
- J. Domke (2012). “Generic methods for optimization-based modeling.” AISTATS.
- D. Maclaurin, D. Duvenaud, R. Adams (2015). “Gradient-based hyperparameter optimization through reversible learning.” ICML.
- J. Lorraine, P. Vicol, D. Duvenaud (2020). “Optimizing millions of hyperparameters by implicit differentiation.” AISTATS.
- C. Finn, P. Abbeel, S. Levine (2017). “Model-agnostic meta-learning for fast adaptation of deep networks.” ICML.
- A. Rajeswaran, C. Finn, S. Kakade, S. Levine (2019). “Meta-learning with implicit gradients.” NeurIPS.
- B. Amos, J. Z. Kolter (2017). “OptNet: differentiable optimization as a layer in neural networks.” ICML.
- B. Amos, I. Jimenez, J. Sacks, B. Boots, J. Z. Kolter (2018). “Differentiable MPC for end-to-end planning and control.” NeurIPS.
- N. Ratliff, J. A. Bagnell, M. Zinkevich (2006). “Maximum margin planning.” ICML.
- Y. Wu, M. Ren, R. Liao, R. Grosse (2018). “Understanding short-horizon bias in stochastic meta-optimization.” ICLR.