Fix gradient norm scaling in pounders convergence checks - #708
Merged
Merged
Conversation
The residual model is fitted in coordinates scaled by the trust-region radius, so main_model.linear_terms already equals delta times the gradient. The convergence checks multiplied this by delta again, so the gtol_abs, gtol_rel and gtol_scaled tests compared delta**2 * ||grad|| against the tolerances. Once the trust region shrank, runs could report gradient convergence at points far from a minimum. Divide the model gradient by delta instead, so the checks use the gradient in the original coordinates, as in Stefan Wild's reference POUNDERs implementation (IBCDFO formquad.m returns G / delta). Remove the Linux and Windows skips on test_bntr, assert the final criterion value, and add a regression test with jittered start values.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Member
Author
|
CI confirms that the previously skipped Before (latest After (this PR, run 36701300636): The five |
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.
Fixes #657.
Problem
POUNDERS fits its residual model in coordinates scaled by the trust-region radius,
(x - center) / delta. The model'slinear_termstherefore already equaldelta * gradient. The convergence checks multiplied this bydeltaagain, soconvergence_gtol_abs,convergence_gtol_relandconvergence_gtol_scaledcompareddelta**2 * ||gradient||against the tolerances.Once the trust region shrank, runs reported "Norm of the gradient relative to the criterion value is less than relative_gradient_tolerance" at points far from the minimum. From the start vector
[1e-6, 1e-6, 1e-6]the iteration path is chaotic: a relative perturbation of 1e-15 changes where it ends. Tiny floating-point differences between platforms then decided whether the run hit the minimum. That explains the scattered results in #657. None of the reported Linux results were minima (criterion 2455 to 3922, optimum 2384.48). In one traced run the true gradient was about 5e5 while the tested norm was 7e-4.Fix
Use
||linear_terms|| / delta, the gradient in the original coordinates. This matches Stefan Wild's reference implementation (IBCDFOformquad.mreturnsG / delta, whichpounders.mcompares againstg_tol), and the docs, which describe the criterion as the norm of the gradient. The double scaling was copied from PETSc TAO'spounders.c(gnorm *= mfqP->delta) in the original port.Tests that previously failed now run
test_bntr(all 5 cases, includingstart_vec3-cg, which failed in #657)test_bntrassertionsdecimal=3)test_bntr_no_false_convergence_under_start_value_jitter(new,slow)main: 4 of 10 jittered runs stop away from the minimum.tests-with-cov).Locally (macOS): pounders tests 100 passed, 1 skipped, 1 xfailed.
tests/optimagic/optimizers,test_many_algorithmsandtest_estimate_msm: 647 passed, 12 skipped, 1 xfailed. This PR's CI is the first run oftest_bntron Linux and Windows since the skips were added.Behavior change
Stopping changes for all POUNDERS users. Robustness and cost with 1e-15 start value jitter, 20 runs per case:
[0.15, 0.008, 0.01][1e-6]*3With the correct gradient norm, the default gradient tolerances (1e-8) rarely trigger. Most runs now stop because the model was identical in successive iterations. Whether the default tolerances should change is a separate question.
Suggested CHANGES.md entry: