Hysteretic Safe Optimizer
Implementation & benchmark of arXiv:2607.13513 — Non-asymptotic Bounds of Learning-based Linear MPC With Input Constraints and Unbounded Stochastic Noise
Source paper: Non-asymptotic Bounds of Learning-based Linear MPC With Input Constraints and Unbounded Stochastic Noise arXiv:2607.13513 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
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.
Formulas
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.
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
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: Significantly worse ✗
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 8/10
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.
- Agent confidence
- 8/10
- Baseline
- SGD, lr=2.0: final loss 0.16987, best loss 0.16797, 0 fallback steps
- Idea
- HystereticSafe, eta=2.0, k=0.25, umax=0.15: final/best loss 0.69080, 100 fallback steps; contraction sweep observed ratios [0.81, 0.49, 0.09, 0.04, 0.64, 1.21] exactly matched predictions; hysteresis 590 switches vs 804 single-threshold switches
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.
How to run: python3 hysteretic_safe_optimizer.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.13513)
Significantly WORSE than the tuned baseline (n/a, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0
- Idea mean
- 0
- Effect (Δ)
- 0.7303 (n/a; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- Hurts
- Baseline tuning
- swept over 0 configs
The implementation used Adam as the learned candidate rather than a separately learned optimizer network, and the uncertainty estimate was a simple candidate-step magnitude proxy. No additional architectures, tracks, or longer training budgets were tested.
How to run: python3 stage2_hysteretic_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
Implemented the Hysteretic Safe Optimizer on the structurally matched dynamics track with shared rnn_small models, paired 8-seed evaluation, and a parity-matched three-point learning-rate sweep. The idea was significantly worse: baseline mean MSE was approximately 0.00054517 versus 0.73085624 for the idea, paired delta was +0.73031107 with permutation p=0.0081. The trained-model mechanism signature was not confirmed because all candidate steps entered fallback and the observed energy ratio was 0.0 rather than the predicted 0.81.
- Baseline
- dynamics/rnn_small, best lr=0.01, 18 epochs; 8-seed mean MSE approximately 0.00054517
- Idea
- dynamics/rnn_small, best reported lr=0.001, 18 epochs; 8-seed mean MSE 0.73085624; fallback fraction 1.0
- Mechanism signature
- predicted fallback ratio 0.81; observed ratio 0.0; confirmed=false
- Paired delta
- +0.73031107, idea_wins=0/8, permutation p=0.0081
Benchmark result
Significantly WORSE than the tuned baseline (n/a, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0
- Idea mean
- 0
- Effect (Δ)
- 0.7303 (n/a; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- Hurts
- Baseline tuning
- swept over 0 configs
The implementation used Adam as the learned candidate rather than a separately learned optimizer network, and the uncertainty estimate was a simple candidate-step magnitude proxy. No additional architectures, tracks, or longer training budgets were tested.
How to run: python3 stage2_hysteretic_bench.py
Artifacts
- bench_report.json 34.6 KB View Raw
- hysteretic_safe_optimizer.py 5.5 KB View Raw
- report.md 1.7 KB View
- report_bench_2026-08-31T015541.md 2.8 KB View
- results.json 3.0 KB View Raw
- stage2_hysteretic_bench.py 7.4 KB View Raw