Let solve_cache! drive a polyalgorithm cache - #1189
Open
singhharsh1708 wants to merge 1 commit into
Open
Conversation
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.
NonlinearSolveBase.solve_cache!throws on aNonlinearSolvePolyAlgorithmCache:It passes the
applicable(InternalAPI.step!, cache)guard, so it is accepted, and then_run_cache_to_completion!readscache.termination_cacheandcache.traceas raw fields atthe end. A polyalgorithm has neither: the subsolver it is currently running owns both. It does
have
nsteps,retcodeandmaxiters, which is why it gets all the way to the last few linesbefore failing.
FastShortcutNonlinearPolyalgfails identically.This follows the hook pattern #1187 just documented for
get_u, whose docstring names "apolyalgorithm forwarding to its active subsolver" as the reason such a hook exists. Two more
accessors in the same shape,
get_termination_cacheandget_trace, each defaulting to thefield it reads today, with
NonlinearSolvePolyAlgorithmCacheforwarding both tocaches[current].get_abstolandget_reltolread the same field and now go through thehook, so those work on a polyalgorithm cache too.
Nothing changes for a cache that has the fields, since the defaults return exactly what the
call sites read before.
Verified
Same problem, checked against what the normal
solvepath returns:solve_cache!sqrt.([2, 3])solve()get_abstolNewtonRaphsonRobustMultiNewtonFastShortcutNonlinearPolyalgTrustRegionAll four throw on master except
NewtonRaphsonandTrustRegion, andget_abstolon apolyalgorithm cache throws on master.
test/Core/cache_solve_tests__item1.jl, the file #1187 extended, passes.Why
ImplicitDiscreteSolvedrives its stage solve throughsolve_cache!so it can use the stepobserver, and today it cannot accept a polyalgorithm as
nlsolvebecause of this(SciML/OrdinaryDiffEq.jl#4138). The
NonlinearSolveNoInitCachebranch #1187 documented coversthe SimpleNonlinearSolve half; this covers the other one.
AI Disclosure
Claude assisted with this work.