Repository navigation
Fix polyalgorithm cache residual access using get_fu - #773
Merged
ChrisRackauckas merged 3 commits intoJan 11, 2026
Merged
ChrisRackauckas merged 3 commits into
ChrisRackauckas merged 3 commits into
Conversation
The polyalgorithm solve!() generated function was incorrectly accessing `.resid` directly on cache objects, but caches have a `fu` field not `resid`. This caused intermittent errors with the message "type GeneralizedFirstOrderAlgorithmCache has no field resid" when all sub-algorithms of the polyalgorithm failed to converge early and the code fell through to find the best result among failures. The fix uses NonlinearSolveBase.get_fu(cache) instead of cache.resid, which is consistent with how the early success path at line 367 already correctly accesses the residual. Fixes SciML/CurveFit.jl#76 Co-Authored-By: Claude Opus 4.5 <[email protected]>
This test exercises the code path in solve!() where all sub-algorithms of the polyalgorithm fail to converge early, forcing the fallback path that selects the best result among failures. Previously this path incorrectly accessed cache.resid (which doesn't exist) instead of using get_fu(cache). Related: SciML/CurveFit.jl#76 Co-Authored-By: Claude Opus 4.5 <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Jan 12, 2026
…ciML#779) PR SciML#773 introduced a regression where `findmin_caches` was called with residual vectors (results of `get_fu`) instead of cache objects. This caused `MethodError: no method matching get_fu(::Vector{Float64})` because `findmin_caches` internally calls `get_fu` on each element, expecting cache objects. The fix uses `findmin_resids` directly since the `fus` tuple already contains residual vectors extracted by `get_fu` at line 386. Fixes SciML#779 Related: SciML/CurveFit.jl#76 Co-Authored-By: Claude Opus 4.5 <[email protected]>
3 tasks done
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Jan 12, 2026
Adds a test that exercises the polyalgorithm cache-based solve! path which was broken by PR SciML#773. The test uses init() + solve!() to ensure the code path through __generated_solve_cache! is exercised. Without the fix, this test would fail with: MethodError: no method matching get_fu(::Vector{Float64}) Co-Authored-By: Claude Opus 4.5 <[email protected]>
ChrisRackauckas
pushed a commit
that referenced
this pull request
Jan 12, 2026
…780) * fix: use findmin_resids for residual vectors in polyalgorithm solve (#779) PR #773 introduced a regression where `findmin_caches` was called with residual vectors (results of `get_fu`) instead of cache objects. This caused `MethodError: no method matching get_fu(::Vector{Float64})` because `findmin_caches` internally calls `get_fu` on each element, expecting cache objects. The fix uses `findmin_resids` directly since the `fus` tuple already contains residual vectors extracted by `get_fu` at line 386. Fixes #779 Related: SciML/CurveFit.jl#76 Co-Authored-By: Claude Opus 4.5 <[email protected]> * test: add regression test for issue #779 Adds a test that exercises the polyalgorithm cache-based solve! path which was broken by PR #773. The test uses init() + solve!() to ensure the code path through __generated_solve_cache! is exercised. Without the fix, this test would fail with: MethodError: no method matching get_fu(::Vector{Float64}) Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]>
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.
Summary
cache.residwas accessed directly instead of usingget_fu(cache)fufield, notresid- this caused intermittent errors when all sub-algorithms failed to converge earlyRoot Cause
The error "type GeneralizedFirstOrderAlgorithmCache has no field resid" occurred in the fallback path of the polyalgorithm (line 385) when none of the sub-algorithms achieved early success. The code tried to access
cache.residbut caches usefufor storing residuals.This was an intermittent issue because:
get_fu()correctlyTest plan
Fixes SciML/CurveFit.jl#76
🤖 Generated with Claude Code