# Hysteretic Safe Optimizer

- ID: 864
- Canonical URL: https://synthcore.org/idea/864/hysteretic-safe-optimizer
- API JSON: https://synthcore.org/api/idea/864.json
- API Markdown: https://synthcore.org/api/idea/864.md
- Verification status: failed_benchmark
- Source: [arXiv:2607.13513](https://arxiv.org/abs/2607.13513)
- Category: dynamics
- Solves: stability, speedup
- ML areas: optimizer, training-dynamics, scheduler
- Math tags: control-theory, dynamical-systems, optimization, linear-algebra
- Ratings: usefulness 7/10; difficulty 5/10; novelty 7/10

## Idea description

Use a two-mode optimizer: a learned preconditioned update for normal training and a bounded contractive fallback when the learned update is predicted to increase a monitored energy. Use separate entry and exit thresholds so minibatch noise does not cause rapid switching.

## Mathematical statement

Let z_k be the trainable parameter vector, g_k the minibatch gradient, and P_phi(s_k) a learned positive-definite preconditioner based on optimizer state s_k. The learned step is u_learn = -eta P_phi(s_k) g_k. The fallback step is u_safe = sat_umax(-K(z_k-z_ref)), where K is positive semidefinite, z_ref is a reference parameter vector, and sat_umax clips every coordinate to the interval [-umax,umax]. Define V_k = 0.5 (z_k-z_ref)^T Q (z_k-z_ref), with Q positive definite. Let Vpred be the predicted energy after the learned step. Enter fallback mode when Vpred > rho_in V_k + delta_k and leave fallback mode only when Vpred <= rho_out V_k - delta_k, where 0 < rho_out < rho_in < 1. The uncertainty margin is delta_k = D epsilon_k, where D estimates the sensitivity of the update to uncertainty and epsilon_k estimates gradient or optimizer uncertainty. The unsaturated fallback is contractive when the spectral norm of Q^(1/2)(I-K)Q^(-1/2) is below one.

## Key formulas

- z_(k+1) = z_k + u_k, with u_k = u_learn if m_k = 0 and u_k = u_safe if m_k = 1
- u_learn = -eta P_phi(s_k) g_k; u_safe = sat_umax(-K(z_k-z_ref))
- m_(k+1) = 1 if m_k=0 and Vpred > rho_in V_k + delta_k; m_(k+1) = 0 if m_k=1 and Vpred <= rho_out V_k - delta_k; otherwise m_(k+1)=m_k
- ||Q^(1/2)(I-K)Q^(-1/2)||_2 < 1, and delta_k = D epsilon_k

## Implementation notes

Integrate the mechanism at the optimizer-step interface, after gradients are computed and before parameters are updated. Maintain the current mode m, an energy estimate, and an uncertainty estimate. Pseudocode: compute the minibatch gradient g; generate the candidate learned step u_learn = -eta P_phi g; clip the candidate to the allowed update range; compute Vpred using V(z + u_learn), or use the cheaper surrogate L_current + c times the squared step norm; estimate epsilon from gradient variance across two independent minibatches, an ensemble of optimizer heads, or the covariance of a recurrent optimizer state; set delta = D epsilon; apply the hysteresis state machine; and execute either the learned or fallback step. Estimate D online as a high quantile of observed update changes divided by epsilon. Start with diagonal K and Q equal to the identity, making the fallback contraction factor max_i absolute value of 1-K_ii. Run a cheap experiment on a two-layer MLP trained on MNIST, comparing SGD, Adam, and the safeguarded optimizer while increasing the learning rate until ordinary training diverges. The predicted signature is a transition when the learned energy-growth ratio reaches rho_in. Fallback trajectories should decay geometrically at the measured contraction factor. Hysteresis should also produce fewer mode switches than a single-threshold rule, especially when gradient noise is increased.

## Verification

- Status: failed_benchmark
- Mechanism evidence: yes
- Mechanism confirmed: no
- Practical verdict: harms
- Verdict: Built a NumPy HystereticSafe optimizer with learned-step energy prediction, hysteretic entry/exit thresholds, coordinate saturation, and contractive fallback, plus a CUDA-capable tiny MLP test. The toy checks confirmed the mechanism: fallback energy ratios matched (1-k)^2 exactly across k=0.1 to 2.1, contraction changed at the predicted |1-k|=1 boundary, and learned quadratic dynamics diverged exactly when eta*lambda exceeded 2. Hysteresis reduced noisy mode switches from 804 to 590, but the MLP run did not show a training win: SGD reached loss 0.170 while the safe optimizer remained at 0.691 and used fallback on all 100 steps.

### Mechanism check

- Verdict: Built a NumPy HystereticSafe optimizer with learned-step energy prediction, hysteretic entry/exit thresholds, coordinate saturation, and contractive fallback, plus a CUDA-capable tiny MLP test. The toy checks confirmed the mechanism: fallback energy ratios matched (1-k)^2 exactly across k=0.1 to 2.1, contraction changed at the predicted |1-k|=1 boundary, and learned quadratic dynamics diverged exactly when eta*lambda exceeded 2. Hysteresis reduced noisy mode switches from 804 to 590, but the MLP run did not show a training win: SGD reached loss 0.170 while the safe optimizer remained at 0.691 and used fallback on all 100 steps.
- Confidence: 8/10
- Limitations: The neural experiment used a tiny synthetic 2D classification task rather than MNIST, full-batch gradients rather than independent minibatch uncertainty estimates, identity preconditioning rather than a learned P_phi, and a fixed uncertainty margin delta=0. The safe optimizer configuration was conservative and harmed optimization in this test; no claim of practical speedup or superiority over Adam is supported.

### 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_report.json](https://synthcore.org/code/349/bench_report.json)
- [hysteretic_safe_optimizer.py](https://synthcore.org/code/349/hysteretic_safe_optimizer.py)
- [report.md](https://synthcore.org/code/349/report.md)
- [report_bench_2026-08-31T015541.md](https://synthcore.org/code/349/report_bench_2026-08-31T015541.md)
- [results.json](https://synthcore.org/code/349/results.json)
- [stage2_hysteretic_bench.py](https://synthcore.org/code/349/stage2_hysteretic_bench.py)
- [Download all files as ZIP](https://synthcore.org/download/349)

## Disclaimer

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