The Question
Every tuner of anything noisy has lived this moment: you change a knob, the number improves, and a small voice asks — improved, or got lucky? This study puts that moment under a microscope with the cleanest possible specimen: minimize the Rosenbrock banana function when every evaluation you request comes back corrupted by Gaussian noise (σ = 0.5), and you may ask for only 200 evaluations. The true surface has a known minimum, f* = 0 at (1, 1) — so unlike real life, we can score every answer against truth.
Three contenders, one fixed budget: single-start Nelder-Mead (the default reflex), the same budget split across random restarts, and SPSA — the stochastic-approximation method literally designed for noisy evaluations. Three research questions were registered with priors before any run: do restarts pay (RQ1)? does SPSA beat them at this budget (RQ2)? does finer restart fragmentation keep paying (RQ3)?
The real subject, though, is the discipline: a measured noise floor instead of a guessed significance bar, a sealed fresh-noise confirmation spent exactly once, every discard and crash kept as evidence — and, as it turned out, the study's biggest finding was made by a gate before the first experiment ran.
The Method
SPSA (Simultaneous Perturbation Stochastic Approximation, Spall 1992) is the unfamiliar method here, so it got the full method-card treatment before any run. The idea in one breath: a finite-difference gradient in d dimensions costs 2d evaluations, but if you nudge all coordinates at once with a random ±1 vector Δ and take just two measurements, the quantity
is a wrong gradient whose wrongness has mean zero — so gradient descent on it still walks downhill, at two evaluations per step regardless of dimension. The catch is the gain sequences and : SPSA's guarantees are asymptotic, and its first steps are only as sane as is matched to your gradient magnitudes. Spall's 1998 implementation paper says exactly how to size it — from the desired magnitude of the first step. Remember that sentence; the journey section shows what happens to a researcher who reads it and then doesn't apply it.
The baselines: Nelder-Mead maintains a simplex of 3 points (in 2-D), reflecting/expanding/contracting by comparing function values — comparisons that noise can silently invert. Random restarts split the same 200 evaluations across k independent starts and keep the best finisher: exploration purchased at the price of per-start depth.
The Data
A synthetic lab's "data" is its generator plus its seed discipline. The generator is
fixed: true Rosenbrock plus per evaluation, hard 200-evaluation budget,
R = 40 independent repetitions per experiment, each rep scored as
true f(answer) − f* — the optimizer never sees the truth it is
scored on. The seed contract does the work a train/test split does elsewhere:
development block 42–81, four extra floor-measurement blocks, and a sealed
final-test block 10042–10081 — pairwise disjoint by construction, proven
mechanically by prepare.py.
The DATA gate's clean-room audit then ran its harness-sanity check — and made the study's biggest single discovery before experiment one: plain random search (200 uniform darts, keep the best-looking) scores a mean true gap of 0.397, while single-start Nelder-Mead scores 1.251. The no-information baseline beats the default method 3.2×. A noiseless probe (NM solves the clean function to exactly 0.0 on all 40 starts) proved the harness sane: the noise is the entire problem — it corrupts NM's simplex comparisons until the search stalls wherever the noise first confuses it.
The other Phase-0 ritual: the measured noise floor. The anchor config
was rerun on five disjoint seed blocks: means 1.25–2.00, std
0.2848. The keep bar (minimum_delta) was set to 2×
that — 0.5695 — and the contract records the whole measurement. One humbling
detail: the development block turned out to be the luckiest of the five.
The Journey
Seven ledger rows, every one still resolvable to its exact code. The full-range trajectory is the honest record — note the DECLARED log scale, forced by two discards in the numeric stratosphere:
And the zoom where the actual frontier lives (divergent discards excluded, as labeled):
| Exp | Metric | Status | Description |
|---|---|---|---|
| E0001 | 1.251208 | keep | anchor: single-start Nelder-Mead, budget 200, dev block — must reproduce the prepared reference cell to 1e-9; first valid result on this track |
| E0002 | 1.251208 | discard | NM adaptive=True (Gao-Han) — calibration probe: prediction says within 2x floor std of the anchor; did not improve track frontier 1.251208 by minimum_delta=0.569532 |
| E0003 | 0.407072 | keep | 4 restarts x 50 evals, same 200-eval budget — RQ1: must clear minimum_delta 0.5695; the honest bar is also random-search 0.397; frontier improvement over 1.251208 with minimum_delta=0.569532 |
| E0004 | 1.11557605229e+196 | discard | SPSA a0=50 aggressive gains — registered prediction: iterates diverge, objective overflows non-finite, honest crash; did not improve track frontier 0.407072 by minimum_delta=0.569532 |
| E0005 | NA | crash | SPSA c0=0 — the estimator's own denominator: registered crash, mechanism corrected after E0004; process exit code 1 |
| E0006 | 1.85070982844e+178 | discard | SPSA tuned a0=0.1 c0=0.1 — RQ2: prediction says within 2x floor std of restarted NM (discard); did not improve track frontier 0.407072 by minimum_delta=0.569532 |
| E0007 | 0.312078 | discard | sealed confirmation: incumbent 4x50 restarts on the fresh seed block 10042..; sealed final-test evidence; excluded from the adaptive frontier |
The beats, in order. E0001 anchored the study: it reproduced the prepared reference cell to 1e−9, proving the seed plumbing end to end. E0002 was designed as a cheap calibration probe — "adaptive" Nelder-Mead — and returned a delta of exactly zero: the Gao–Han adaptive coefficients are algebraically identical to standard NM at n = 2. A no-op by mathematics, caught because the run was bit-reproducible.
E0003 was the payoff: 4 restarts × 50 evaluations, 1.2512 → 0.4071 — a 0.844 improvement, 2.96× the floor std, clearing the measured bar almost exactly as the registered prediction ("≥3×") demanded. The sting is in the comparison nobody registered: 0.407 only ties random search's 0.397. At this budget, restarts' entire value is their random-sampling component; the local polish buys nothing the noise doesn't take back.
E0004 falsified our crash prediction in the most educational way possible: SPSA at diverged as predicted — to a mean gap of — and stayed finite, so the arithmetic filed a discard, not a crash. Divergence saturates: the decaying gains strangle the step size before float overflow. Off-ledger probes at and 5000 confirmed the ceiling moves (1e81, 1e97) but never breaks. The re-registered E0005 found the true crash where it structurally must live: divides the estimator by its own perturbation size — ZeroDivisionError, honest crash, NA metric, candidate commit retained.
E0006 supplied the humility: "textbook" SPSA () ALSO diverged, to — because Spall 1998's own first-step rule, quoted in this study's method card, prescribes for gradients this steep. The cure was in the card; the researcher didn't apply it. Finally E0007 spent the track's one sealed evaluation: the incumbent on fresh noise scored 0.3121 — replicating the development result within 0.33× the floor std. Confirmed.
Findings
Verdicts against the registered questions (claim IDs are stable and citable as
03-noisy-rosenbrock-dfo#C<n>):
| Claim | Question | Verdict | Evidence |
|---|---|---|---|
| [C1] | Do restarts beat single-start NM? | Supported — confirmed. 1.2512 → 0.4071 (2.96× floor std); sealed fresh-block 0.3121 replicates. | E0001, E0003, E0007 |
| [C2] | Does SPSA beat restarted NM here? | Refuted, more strongly than predicted — it diverges rather than merely losing. | E0004, E0006 |
| [C3] | Does 8×25 fragmentation keep paying? | Untested — deferred at the logged mid-phase re-plan. | program.md |
The four surprises that outrank the verdicts: the DATA gate's discovery that random search beats the default method 3.2× before any experiment ran; the dimensional illusion of "adaptive" NM at n = 2; finite-saturating SPSA divergence (a very confident wrong answer is not a crash); and a mis-tuning the method card itself had already warned against. The priors' scorecard closed the loop: method-card-sourced priors went 2/2, uninformed priors 1/2 — accumulated knowledge measurably outpredicted vibes.
Coding Advice
- Measure the floor before judging any delta [C4]. Five reruns of the identical config across seed blocks cost seconds and re-priced every later comparison: the bar became 0.5695, and the development block turned out to be the luckiest of five. A delta below your floor is weather, not climate.
- Run the dumb baseline first [C5]. Random search at the same budget would have re-framed this study before it began — and the clean-room audit's chance check is exactly where it surfaced. Budget one ledger row for it next time.
- Scale gain sequences from YOUR landscape, not from the paper's example [C6]. Apply Spall 1998's first-step rule to your measured gradient magnitudes; here it prescribes , four orders below the "textbook" 0.1 that diverged.
- Register crash predictions on mechanisms [C7]. "It will diverge" and "it will be non-finite" are different claims; only the denominator is structurally guaranteed to die. The ledger now teaches both.
- Let the harness keep your losers. E0004's 1e196 and E0005's ZeroDivisionError are this study's most-cited rows — and both resolve to their exact candidate commits because the loop commits before it runs.
The winning train.py, verbatim
The exact script behind the sealed confirmation — included by reference at build time, so these are the actual bytes:
"""The only per-candidate mutable surface in a Klein v2 study.
Simulation harness for noisy-Rosenbrock derivative-free optimization: the
CONFIG block below is the 5–15-line experiment surface; objective.py and
optimizers.py are stable study libraries.
"""
from __future__ import annotations
import csv
import os
import statistics
import time
from pathlib import Path
from kleinlib.eval import evaluate_scalar
from objective import (
DEV_BASE,
EVAL_BUDGET,
F_STAR,
FINAL_BASE,
N_REPS,
NoisyBudgetedObjective,
block,
rosenbrock,
)
from optimizers import nelder_mead, nm_restarts, spsa
EXPERIMENT_ID = os.environ.get("KLEIN_EXPERIMENT_ID")
TRACK = os.environ.get("KLEIN_TRACK")
# ---- CONFIG: the per-experiment surface (keep diffs 5-15 lines) ----
OPTIMIZER = "nm_restarts" # nm | nm_restarts | spsa
ADAPTIVE = False # Nelder-Mead adaptive (Gao-Han) parameters
N_RESTARTS = 4 # nm_restarts: starts sharing the SAME total budget
SPSA_A0 = 0.1 # SPSA gain-sequence scale
SEED_BASE_OVERRIDE = None # measurement sweeps only; never for frontier runs
# --------------------------------------------------------------------
def run_rep(seed: int) -> float:
objective = NoisyBudgetedObjective(seed, budget=EVAL_BUDGET)
x0 = objective.random_start()
if OPTIMIZER == "nm":
answer = nelder_mead(objective, x0, EVAL_BUDGET, adaptive=ADAPTIVE)
elif OPTIMIZER == "nm_restarts":
answer = nm_restarts(objective, N_RESTARTS, EVAL_BUDGET, adaptive=ADAPTIVE)
elif OPTIMIZER == "spsa":
answer = spsa(objective, x0, EVAL_BUDGET, a0=SPSA_A0)
else:
raise RuntimeError(f"unknown OPTIMIZER {OPTIMIZER!r}")
return rosenbrock(answer) - F_STAR # scored on the TRUE function
def seed_base(evaluation_kind: str) -> int:
if SEED_BASE_OVERRIDE is not None:
return int(SEED_BASE_OVERRIDE)
return FINAL_BASE if evaluation_kind == "final_test" else DEV_BASE
def main() -> None:
t0 = time.time()
evaluation_kind = os.environ.get("KLEIN_EVALUATION_KIND")
missing = [
name
for name, value in (
("KLEIN_EVALUATION_KIND", evaluation_kind),
("KLEIN_EXPERIMENT_ID", EXPERIMENT_ID),
("KLEIN_TRACK", TRACK),
)
if value is None
]
if missing:
raise RuntimeError(
"train.py must be invoked through `klein run-one`; missing "
+ ", ".join(missing)
)
if evaluation_kind not in {"development", "final_test"}:
raise RuntimeError(f"invalid KLEIN_EVALUATION_KIND={evaluation_kind!r}")
base = seed_base(evaluation_kind)
gaps = [run_rep(seed) for seed in block(base, N_REPS)]
mean_gap = statistics.fmean(gaps)
if OPTIMIZER == "nm" and not ADAPTIVE and base == DEV_BASE:
reference = Path("data/prepared/reference_cell.csv")
if reference.is_file():
with reference.open("r", encoding="utf-8", newline="") as f:
rows = list(csv.DictReader(f))
ref_mean = statistics.fmean(float(r["final_gap"]) for r in rows)
if abs(ref_mean - mean_gap) > 1e-9:
raise RuntimeError(
f"split-identity anchor FAILED: prepared reference mean {ref_mean!r} "
f"vs recomputed {mean_gap!r} — seed plumbing drifted, STOP"
)
evaluate_scalar(
mean_gap,
exp_id=EXPERIMENT_ID,
metric_name="mean_final_gap",
metric_goal="lower",
study_dir=".",
t0=t0,
extra={
"gap_std_across_reps": statistics.stdev(gaps),
"gap_median": statistics.median(gaps),
"gap_worst": max(gaps),
"n_reps": float(N_REPS),
"wall_seconds": time.time() - t0,
},
)
if __name__ == "__main__":
main()
Next Steps
- Random search as a frontier citizen. Promote the data-card finding to a ledger experiment with its own floor; it is the honest baseline every later study of this landscape must beat.
- SPSA, actually tuned by its own reference: from the Spall-rule, and a gradient-normalized variant — does the method compete once its one paragraph of guidance is applied?
- Fragmentation (RQ3): 8×25 vs 4×50, the deferred probe.
- Common random numbers: pair configs on identical noise draws to shrink the paired floor below 0.57 and sharpen the keep bar.
Verified references: Spall (1992), IEEE Trans. Automatic Control 37(3):332–341; Spall (1998), IEEE Trans. Aerospace & Electronic Systems 34(3):817–823. Both verified against publisher indexes on 2026-07-30 (see method_card.md).