A relative tolerance at a zero-valued optimum fails on the runs that search best - #304
Merged
sbryngelson merged 1 commit intoSep 15, 2026
Conversation
…search best The nightly CI has failed since 8 September on 3.14, and since 9 September on 3.13, in test_the_result_records_everything_it_evaluated. Master has not changed since 19 August; numpy 2.4.6 -> 2.5.3 did. The test compared best_value, the GP posterior mean at the best point, against the raw observation there, with rel=1e-3. On a noiseless objective those differ by the interpolation floor -- an ABSOLUTE error of 1e-10 to 7e-08, set by _JITTER and the conditioning of the Cholesky. But _bowl peaks at exactly zero, so the closer the search lands to the optimum, the smaller values[chosen] gets while the numerator stays put. The relative bound therefore tightens without limit as the optimiser improves, and fails precisely on the best runs. That is what happened. The numpy upgrade perturbed the L-BFGS-B rounding enough to move seed 0 from |x*| = 0.053 to |x*| = 0.0029 -- a more accurate answer -- and values[chosen] fell from -2.8e-03 to -8.6e-06. The absolute error was unchanged at 3e-08; the relative error rose from 1.3e-05 to 3.5e-03 and tripped the bound. Pinning numpy 2.5.3 and scipy 1.18.1 locally reproduces the CI failure exactly. bayesian_maximize is not at fault and is not touched. The companion assertion, that the chosen point is still the best observation, passed throughout CI. Adds abs=1e-6, the invariant that actually holds: ~14x the worst interpolation error measured over ten seeds, and six orders of magnitude below the data range, so it still tests that the GP interpolates. The docstring's "~3e-05 relative" was never a property of the code, only of where seed 0 happened to land, and is replaced by the absolute floor and the reason the relative form degenerates. The other twenty rel= assertions in the suite were checked; none compares against a quantity that approaches zero, so the pattern is isolated to this test.
sbryngelson
deleted the
fix-degenerate-relative-tolerance-at-the-optimum
branch
September 15, 2026 04:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is failing
Nightly CI has failed since 8 September on 3.14, and since 9 September on 3.13, in
tests/test_optimize.py::test_the_result_records_everything_it_evaluated. 3.12 is still green. Nothing else fails; the later steps just never run because the test step aborts the job.Master has not changed since 19 August, so the trigger is environmental: numpy 2.4.6 -> 2.5.3.
Root cause
The test compared
best_value(the GP posterior mean at the best point) against the raw observation there, with a relative tolerance:On a noiseless objective those two differ by the GP's interpolation floor, an absolute error of ~1e-10 to 7e-08 set by
_JITTER = 1e-10and the conditioning of the Cholesky inpyimr/optimize.py:70.But
_bowlpeaks at exactly zero. So the closer the search lands to the optimum, the smallervalues[chosen]becomes while the numerator stays put. The bound isconstant / (something -> 0): it tightens without limit as the optimiser improves, and fails precisely on the best runs.The numpy upgrade perturbed L-BFGS-B rounding just enough to move seed 0 to a better point. Reproduced locally in a venv pinned to CI's versions:
|x*|from optimumvalues[chosen]The absolute error is flat; only the denominator collapsed. A seed sweep on the old numpy confirms the mechanism independently: seed 6 lands 0.003 from the optimum and fails identically, while seed 8 lands 0.096 away and passes with a 1e-08 relative error.
bayesian_maximizeis not at fault and is not touched. The companion assertion, that the chosen point is still the best observation, passed throughout CI.The change
Adds
abs=1e-6— the invariant that actually holds. It is ~14x the worst interpolation error measured over ten seeds (7.2e-08) and six orders of magnitude below the data range (~1.8), so it still genuinely tests that the GP interpolates.rel=1e-3is kept to guard the large-magnitude end.The docstring's claim of "~3e-05 relative" was never a property of the code, only of where seed 0 happened to land; it is replaced by the absolute floor and the reason the relative form degenerates.
Verification
-9.288960770237331e-06vs-9.330864970410784e-06): old FAILS, new PASSES.tests/test_optimize.pyin the development env: 11 passed.rel=assertions in the suite were checked; none compares against a quantity that approaches zero, so the pattern is isolated to this test.