perf: Remove redundant evaluations in unconstrained solver loops - #173
Closed
PatWie wants to merge 1 commit into
Closed
perf: Remove redundant evaluations in unconstrained solver loops#173PatWie wants to merge 1 commit into
PatWie wants to merge 1 commit into
Conversation
Progress::Update evaluated a full extra Hessian and computed a dense inverse every iteration of every second-order solve, purely to fill the condition-number diagnostic whose stopping threshold defaults to 0 (disabled). The diagnostic is now computed only when its stopping test is enabled and reports NaN otherwise (which the progress printer already renders as N/A). GradientDescent and ConjugatedGradientDescent re-evaluated the gradient that the incoming FunctionState already carries; GradientDescent additionally returned a value-only state, forcing one post-step re-evaluation in the outer loop -- it now uses the state-returning More-Thuente overload. Armijo gains SearchWithCachedStart variants (both orders) so Newton and CG stop re-evaluating the starting point the caller just evaluated; Newton previously paid a value+gradient+Hessian triple per line search for this. Trial points in Armijo reuse one buffer across backtracks. Measured on 2D Rosenbrock (g++ -O2, median of 201 solves), with iteration counts and final objectives bit-identical: CG 31.2 -> 12.5 us (2.5x), Newton 14.3 -> 7.0 us (2.0x), trust-region Newton 17.3 -> 10.5 us (1.65x), gradient descent 199.5 -> 153.5 us (1.3x). LBFGS and BFGS were already evaluation-clean and are unchanged. Also reflows one over-length line that the upstream rho-precompute commit left unformatted in lbfgs.h; the CI format check scans the whole tree, so the violation failed this PR despite originating on main.
Owner
Author
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.
Progress::Update evaluated a full extra Hessian and computed a dense inverse every iteration of every second-order solve, purely to fill the condition-number diagnostic whose stopping threshold defaults to 0 (disabled). The diagnostic is now computed only when its stopping test is enabled and reports NaN otherwise (which the progress printer already renders as N/A).
GradientDescent and ConjugatedGradientDescent re-evaluated the gradient that the incoming FunctionState already carries; GradientDescent additionally returned a value-only state, forcing one post-step re-evaluation in the outer loop -- it now uses the state-returning More-Thuente overload. Armijo gains SearchWithCachedStart variants (both orders) so Newton and CG stop re-evaluating the starting point the caller just evaluated; Newton previously paid a value+gradient+Hessian triple per line search for this. Trial points in Armijo reuse one buffer across backtracks.
Measured on 2D Rosenbrock (g++ -O2, median of 201 solves), with iteration counts and final objectives bit-identical: CG 31.2 -> 12.5 us (2.5x), Newton 14.3 -> 7.0 us (2.0x), trust-region Newton 17.3 -> 10.5 us (1.65x), gradient descent 199.5 -> 153.5 us (1.3x). LBFGS and BFGS were already evaluation-clean and are unchanged.