# Single-loop stationarity-constrained hypergradient

- ID: 92
- Canonical URL: https://synthcore.org/idea/92/single-loop-stationarity-constrained-hypergradient
- API JSON: https://synthcore.org/api/idea/92.json
- API Markdown: https://synthcore.org/api/idea/92.md
- Verification status: mechanism_failed
- Source: [arXiv:2608.23211](https://arxiv.org/abs/2608.23211)
- Category: optimization
- Solves: speedup, stability, scalability
- ML areas: optimizer, fine-tuning, training-dynamics
- Math tags: optimization, convex-analysis, numerical-analysis
- Ratings: usefulness 7/10; difficulty 5/10; novelty 6/10

## Idea description

Replace conventional nested bilevel optimization with simultaneous primal-dual updates that enforce inner-model stationarity through a Lagrange multiplier. Add quadratic dual regularization and projection onto a bounded ball, while estimating all Hessian-vector terms using finite differences of ordinary gradients.

## Mathematical statement

The bilevel problem is \(\min_x F(x)=f(x,y^*(x))\), subject to \(y^*(x)\in\arg\min_y g(x,y)\), where \(x\) is the outer variable, \(y\) is the inner variable, \(f\) is the outer loss, and \(g\) is strongly convex in \(y\). Lower-level optimality is represented by the equality constraint \(c(x,y)=\nabla_y g(x,y)=0\). The regularized Lagrangian is \(\mathcal{L}_\mu(x,y,\lambda)=f(x,y)+\lambda^\top\nabla_y g(x,y)-\frac{\mu}{2}\|\lambda\|_2^2\), where \(\lambda\in\mathbb{R}^{d_y}\) is a multiplier, \(\mu>0\) is the dual regularization coefficient, and \(\lambda\) is restricted to \(\|\lambda\|_2\le R\). Its gradients are \(\nabla_x\mathcal{L}_\mu=\nabla_xf+(\nabla^2_{xy}g)\lambda\), \(\nabla_y\mathcal{L}_\mu=\nabla_yf+(\nabla^2_{yy}g)\lambda\), and \(\nabla_\lambda\mathcal{L}_\mu=\nabla_yg-\mu\lambda\). To use only first-order oracles, estimate the Hessian-vector products by \(\widehat H_{xy}\lambda=[\nabla_yg(x+h\lambda,y)-\nabla_yg(x,y)]/h\) and \(\widehat H_{yy}\lambda=[\nabla_yg(x,y+h\lambda)-\nabla_yg(x,y)]/h\), with finite-difference step \(h>0\). The dual update uses Euclidean projection \(\Pi_R(v)=v\min\{1,R/\|v\|_2\}\).

## Key formulas

- $$\min_{x\in\mathbb{R}^{d_x}}F(x)=f(x,y^*(x)),\quad\text{s.t.}\quad y^*(x)\in\arg\min_{y\in\mathbb{R}^{d_y}}g(x,y).$$
- $$\mathcal{L}_\mu(x,y,\lambda)=f(x,y)+\lambda^\top\nabla_y g(x,y)-\frac{\mu}{2}\|\lambda\|_2^2,\qquad \lambda\in\{v:\|v\|_2\le R\}.$$
- $$\nabla_x\mathcal{L}_\mu=\nabla_x f+(\nabla^2_{xy}g)\lambda,\quad \nabla_y\mathcal{L}_\mu=\nabla_y f+(\nabla^2_{yy}g)\lambda,\quad \nabla_\lambda\mathcal{L}_\mu=\nabla_y g-\mu\lambda.$$
- $$\widehat{H}_{xy}\lambda=\frac{\nabla_y g(x+h\lambda,y)-\nabla_y g(x,y)}{h},\qquad \widehat{H}_{yy}\lambda=\frac{\nabla_y g(x,y+h\lambda)-\nabla_y g(x,y)}{h}.$$

## Implementation notes

(1) Integration point: implement this as a bilevel optimizer for differentiable hyperparameter optimization or meta-learning. Let \(x\) denote hyperparameters or outer-network parameters, \(y\) denote inner-network weights, \(f(x,y)\) denote validation loss, and \(g(x,y)\) denote training loss. Replace several inner SGD steps plus unrolling or implicit differentiation with one simultaneous update of \(x\), \(y\), and \(\lambda\) per minibatch.

(2) Pseudocode:
```text
initialize x, y, lambda
choose lr_x, lr_y, lr_lam, mu, R, h
for each iteration:
    sample training batch Btr and validation batch Bva
    gy = grad_y g(x, y; Btr)
    gx_f = grad_x f(x, y; Bva)
    gy_f = grad_y f(x, y; Bva)
    gy_xplus = grad_y g(x + h*lambda, y; Btr)
    gy_yplus = grad_y g(x, y + h*lambda; Btr)
    vx = gx_f + (gy_xplus - gy)/h
    vy = gy_f + (gy_yplus - gy)/h
    vlambda = gy - mu*lambda
    x = x - lr_x*vx
    y = y - lr_y*vy
    lambda = project_ball(lambda + lr_lam*vlambda, R)
```
The two finite differences are the paper's \(\widehat H_{xy}\lambda\) and \(\widehat H_{yy}\lambda\). For reduced truncation bias, test the centered estimator \([\nabla_y g(z+h v)-\nabla_y g(z-h v)]/(2h)\), using the appropriate perturbation of \(x\) or \(y\).

(3) Compute directly from the mathematics the inner stationarity residual \(\|\nabla_y g\|_2\), dual residual \(\|\nabla_y g-\mu\lambda\|_2\), multiplier norm, projection frequency, and finite-difference estimates. Estimate empirically the finite-difference step by testing \(h\in\{10^{-2},10^{-3},10^{-4}\}\) times the parameter RMS. Tune \(\mu\), \(R\), and the three learning rates independently; use separate training and validation minibatches to avoid leakage.

(4) First experiment: use a two-layer MLP on MNIST or a five-way Omniglot meta-learning split. Let \(x\) be either 10–50 scalar hyperparameters or an outer initialization and let \(y\) be the classifier weights. Compare against first-order MAML, 5–20-step truncated unrolling, and implicit differentiation at equal gradient-evaluation and wall-clock budgets. Track validation loss, validation accuracy, \(\|\nabla_y g\|_2\), multiplier clipping rate, and memory. The method is successful if it reaches lower validation loss or accuracy at equal compute, maintains a decreasing stationarity residual, and avoids exploding multipliers. Ablate dual regularization, projection, one-sided versus centered differences, and exact autodiff Hessian-vector products.

## Verification

- Status: mechanism_failed
- Mechanism evidence: yes
- Mechanism confirmed: no
- Verdict: Built a reproducible synthetic quadratic bilevel MVP with projected regularized primal-dual updates, one-sided and centered finite-difference Hessian-vector estimates, and an exact-autodiff unrolling baseline. The finite-difference claim held locally, with centered estimates generally more accurate at small steps, but the default one-sided method diverged and the best tuned centered result (validation loss 0.0661) was worse than the tuned baseline (0.0292). Thus no robust optimization win was observed.

### Mechanism check

- Verdict: Built a reproducible synthetic quadratic bilevel MVP with projected regularized primal-dual updates, one-sided and centered finite-difference Hessian-vector estimates, and an exact-autodiff unrolling baseline. The finite-difference claim held locally, with centered estimates generally more accurate at small steps, but the default one-sided method diverged and the best tuned centered result (validation loss 0.0661) was worse than the tuned baseline (0.0292). Thus no robust optimization win was observed.
- Confidence: 9/10
- Limitations: Only a small deterministic synthetic quadratic problem was tested, not MNIST, meta-learning, neural networks, minibatch noise, or wall-clock-equivalent large-scale workloads. Hyperparameter sweeps were limited, and the baseline used exact autodiff through one inner step rather than a full comparison against FOMAML, long unrolling, or implicit differentiation.

## Artifacts

- [README.md](https://synthcore.org/code/65/README.md)
- [experiment.py](https://synthcore.org/code/65/experiment.py)
- [report.md](https://synthcore.org/code/65/report.md)
- [tune.py](https://synthcore.org/code/65/tune.py)
- [tune_baseline.py](https://synthcore.org/code/65/tune_baseline.py)
- [Download all files as ZIP](https://synthcore.org/download/65)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
