# Sign-Reset PI Optimizer

- ID: 915
- Canonical URL: https://synthcore.org/idea/915/sign-reset-pi-optimizer
- API JSON: https://synthcore.org/api/idea/915.json
- API Markdown: https://synthcore.org/api/idea/915.md
- Verification status: mech_ok_no_baseline
- Source: [arXiv:2607.14508](https://arxiv.org/abs/2607.14508)
- Category: dynamics
- Solves: stability, speed, accuracy
- ML areas: optimizer, training-dynamics, regularization
- Math tags: control-theory, dynamical-systems, optimization, linear-algebra
- Ratings: usefulness 7/10; difficulty 4/10; novelty 6/10

## Idea description

Replace ordinary gradient descent or momentum with a discrete PI update whose integral gradient state is accumulated only while the gradient direction remains consistent. When the proportional gradient term changes sign, reset the integral state, preventing stale gradients from producing overshoot near minima or after sharp curvature changes.

## Mathematical statement

Let \(\theta_k\) be the parameter vector, \(g_k=\nabla_\theta L(\theta_k)\) the current gradient, \(K_p>0\) and \(K_i\ge 0\) controller gains, and \(I_k\) the integral state. The optimizer uses \(\theta_{k+1}=\theta_k-\eta(K_p g_k+K_i I_k)\). Define a sign-change event by \(r_k=1\) if \(\langle g_k,g_{k-1}\rangle<0\), and \(r_k=0\) otherwise. The reset controller sets \(I_{k+1}=0\) at a sign change and otherwise accumulates \(I_{k+1}=I_k+g_k\). For a scalar quadratic loss \(L(x)=\frac{\lambda}{2}x^2\), the no-reset dynamics have state matrix \(A_\lambda=\begin{bmatrix}1-\eta K_p\lambda&-\eta K_i\\\lambda&1\end{bmatrix}\). Schur stability requires the eigenvalues of this matrix to lie inside the unit disk; a sufficient Jury-condition form is \(0<K_i<K_p\) and \(\eta\lambda(2K_p-K_i)<4\). Resets create a hybrid system that truncates integral memory at gradient sign reversals.

## Key formulas

- $$\theta_{k+1}=\theta_k-\eta\left(K_p g_k+K_i I_k\right),\qquad g_k=\nabla_\theta L(\theta_k)$$
- $$I_{k+1}=\begin{cases}0,&\langle g_k,g_{k-1}\rangle<0\\I_k+g_k,&\langle g_k,g_{k-1}\rangle\ge 0\end{cases}$$
- $$A_\lambda=\begin{bmatrix}1-\eta K_p\lambda&-\eta K_i\\\lambda&1\end{bmatrix},\qquad \rho(A_\lambda)<1\ \Leftarrow\ 0<K_i<K_p,\quad \eta\lambda(2K_p-K_i)<4$$

## Implementation notes

Integrate this as an optimizer on a small MLP or transformer block, initially without Adam-style adaptive normalization so that the control effect is identifiable. Maintain an integral tensor I with the same shape as the parameters, or more cheaply one integral scalar per layer. At every minibatch compute g=torch.autograd.grad(loss, parameters), flatten the gradients, and calculate c=dot(g_flat, previous_g_flat). If c<0, set every integral tensor to zero; otherwise update I=I+g. Apply theta -= eta*(Kp*g+Ki*I), then store detached g as the previous gradient. Add optional gradient clipping only after testing the unclipped dynamics. The paper supplies the PI-plus-reset mechanism and sign-triggered switching rule; curvature and gain calibration must be estimated empirically. First run a one-dimensional and 100-dimensional quadratic with known Hessian eigenvalue lambda, then train a 2-layer MLP on MNIST. Compare SGD, momentum, and PI-reset at matched gradient-evaluation cost. Increase eta until divergence. The no-reset quadratic should become unstable near eta_c=4/[lambda*(2*Kp-Ki)] for 0<Ki<Kp, within about 20 percent. The reset version should show lower overshoot, fewer large oscillations, and a smaller integral norm after each sign reversal. Report reset frequency, settling time to a fixed loss band, and final loss. Test global versus coordinatewise sign detection: the prediction is that global resets are more stable, while coordinatewise resets retain more speed in anisotropic problems.

## Verification

- Status: mech_ok_no_baseline
- Mechanism evidence: yes
- Mechanism confirmed: yes
- Practical verdict: harms
- Verdict: Built a sign-reset PI optimizer and reproducible toy/MLP experiments in experiment.py. The no-reset Jury stability boundary matched prediction exactly at eta=2.5, and the inverse-curvature boundary sweep matched eta*=4/[lambda(2Kp-Ki)] within 0.05%. Sign reversals reset the integral state as specified; resets improved settling in parts of the stable regime and the PI model outperformed SGD on the tiny synthetic MLP, but resets destabilized near-boundary cases and were not a universal stability win.

### Mechanism check

- Verdict: Built a sign-reset PI optimizer and reproducible toy/MLP experiments in experiment.py. The no-reset Jury stability boundary matched prediction exactly at eta=2.5, and the inverse-curvature boundary sweep matched eta*=4/[lambda(2Kp-Ki)] within 0.05%. Sign reversals reset the integral state as specified; resets improved settling in parts of the stable regime and the PI model outperformed SGD on the tiny synthetic MLP, but resets destabilized near-boundary cases and were not a universal stability win.
- Confidence: 9/10
- Limitations: The neural experiment used a small synthetic two-moons dataset rather than MNIST, tested only global sign detection, and did not measure matched FLOPs, wall-clock speed, or larger-scale generalization. The MLP run had no sign reversals, so its improvement is PI accumulation rather than evidence of reset-specific benefit.

### Practical benchmark

- Paired seeds: 8
- Baseline mean: 0
- Idea mean: 0
- p-value: 0.0081
- Paired wins: 0/8
- Benchmark verdict: idea worse (significant)

## Artifacts

- [bench_pi.py](https://synthcore.org/code/379/bench_pi.py)
- [bench_report.json](https://synthcore.org/code/379/bench_report.json)
- [experiment.py](https://synthcore.org/code/379/experiment.py)
- [report.md](https://synthcore.org/code/379/report.md)
- [report_bench_2026-08-31T095842.md](https://synthcore.org/code/379/report_bench_2026-08-31T095842.md)
- [results.json](https://synthcore.org/code/379/results.json)
- [Download all files as ZIP](https://synthcore.org/download/379)

## Disclaimer

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