On the Iteration Complexity of Hypergradient Computation

Riccardo Grazzi, Luca Franceschi, Massimiliano Pontil, Saverio Salzo

Computing "hypergradients" is a central challenge in modern machine learning, particularly for bilevel optimization problems like hyperparameter tuning, meta-learning, and training equilibrium models. This paper provides the first unified theoretical analysis of the iteration complexity for computing these hypergradients. The authors prove that Approximate Implicit Differentiation (AID)—especially when paired with the Conjugate Gradient method—is generally more computationally efficient and memory-friendly than the widely used Iterative Differentiation (ITD) approach.

The Challenge of Bilevel Optimization

Many machine learning scenarios are structured as bilevel problems. In these setups, an "outer" objective (such as validation loss) depends entirely on the solution to an "inner" problem (such as training a model's weights).

To optimize the outer objective using gradient descent, practitioners need the hypergradient: the gradient of the outer loss with respect to the outer parameters. However, the inner problem is often defined by a fixed-point equation (e.g., the result of many steps of gradient descent), making the exact hypergradient nearly impossible to compute directly.

Historically, researchers have relied on two main workarounds:

  1. Iterative Differentiation (ITD): "Unrolling" the optimization steps and using automatic differentiation through the entire path.
  2. Approximate Implicit Differentiation (AID): Using the Implicit Function Theorem to solve for the gradient at the "destination" (the fixed point) without tracking the specific optimization path taken.

Until this paper, there was no rigorous, non-asymptotic way to compare how fast these two methods converge to the true hypergradient.

Methods: ITD vs. AID

The authors analyze both ITD and AID under the assumption that the inner problem is defined by a contraction mapping—a mathematical property ensuring the optimization eventually settles into a unique solution.

  • ITD (Iterative Differentiation): The paper analyzes the error introduced when the inner optimization is stopped after $t$ steps, computing the gradient via automatic differentiation.
  • AID (Approximate Implicit Differentiation): This method involves solving a linear system to find the gradient. The authors evaluate two ways to solve this system:
  • AID-FP: Using a fixed-point iteration (similar to recurrent backpropagation).
  • AID-CG: Using the Conjugate Gradient method.

The core novelty of this work is the derivation of non-asymptotic linear rates of convergence for both methods, allowing for a direct "apples-to-apples" comparison of their iteration complexity.

Key Insights and Empirical Results

The Efficiency Hierarchy and CG Dominance

The theoretical analysis establishes a clear hierarchy. AID-CG is the most efficient, followed by AID-FP, with ITD being the least efficient in terms of the number of iterations required to reach a specific accuracy. The authors proved that the error in the hypergradient for both ITD and AID vanishes at a linear rate. Specifically, AID-FP is guaranteed to be faster than ITD when the number of linear solver steps matches the number of optimization steps.

Convergence of hypergradient error across different methods.

In synthetic experiments across various settings (Logistic Regression, Kernel Ridge Regression, Biased Regularization, and Hyper-representation), the Conjugate Gradient version of AID (AID-CG) consistently converged to the true hypergradient significantly faster than the other methods.

Memory is the Tie-Breaker

Beyond iteration complexity, memory usage is a critical differentiator. ITD's error is tied to how many steps of optimization you take, and reverse-mode ITD requires storing the entire optimization trajectory. This creates a massive memory bottleneck for large models.

AID, on the other hand, decouples the error into two parts: how close you got to the inner solution ($t$ steps) and how accurately you solved the resulting linear system ($k$ steps). Because AID only needs the final state of the inner problem, it is far more scalable for large-scale scenarios with millions of parameters.

Performance on real-world datasets, highlighting ITD memory failures.

This theoretical advantage was confirmed empirically. In experiments on the high-dimensional 20 Newsgroups dataset (over 100,000 features), ITD ran out of memory (exceeding 11GB on a GPU) at higher iteration counts. Meanwhile, AID methods remained stable, achieving lower objective values in less time.

Limitations and Future Work

While this paper provides a robust theoretical foundation, the authors note a few limitations and avenues for future research:

  • The Contraction Assumption: The theory relies heavily on the inner mapping being a contraction. While this covers many cases (like strongly convex problems), it does not necessarily apply to the non-convex inner problems common in deep learning.
  • Warm Starts: In practice, researchers often "warm start" the inner problem using the solution from the previous outer-loop iteration. The current analysis assumes starting from scratch, and theoretically analyzing the benefit of warm starts remains an open challenge.
  • Non-smoothness: The current framework assumes continuously differentiable functions. Extending this analysis to non-smooth problems (such as those involving L1 regularization) is a promising direction for future work.

Summary updated

BibTeX
@inproceedings{grazzi2020iteration,
  author = {Riccardo Grazzi and Luca Franceschi and Massimiliano Pontil and Saverio Salzo},
  title = {{On the Iteration Complexity of Hypergradient Computation}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
  url = {https://openreview.net/forum?id=dABDIMBrMU9},
}
Figure