Repository navigation
Reset force_stop/retcode in polyalg reinit!; add get_u/get_fu - #1115
Merged
ChrisRackauckas merged 5 commits intoJul 31, 2026
Merged
ChrisRackauckas merged 5 commits into
ChrisRackauckas merged 5 commits into
Conversation
A NonlinearSolvePolyAlgorithmCache keeps u/fu on its active subcache, not at top level, so the generic get_u/get_fu (cache.u/cache.fu) fallbacks throw for a polyalgorithm cache. Add delegating methods. Its reinit! also reset current/nsteps/stats but not force_stop/retcode. solve! drives the subcaches directly and is unaffected, but a step!-based driver goes through CommonSolve.step!'s not_terminated guard, which reads those fields off the polyalgorithm cache: after one converged solve a warm-started reinit! + step! loop no-ops immediately and reuses the stale iterate. Reset both in reinit!. Regression test drives a polyalgorithm cache one step! at a time across a reinit! (as ODE/DAE implicit solvers do) and checks get_u/get_fu.
Member
Author
ChrisRackauckas
approved these changes
Jul 27, 2026
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.
Two gaps in
NonlinearSolvePolyAlgorithmCachesurface when a polyalgorithm cache is driven onestep!at a time — the pattern implicit ODE/DAE solvers use to run a nonlinear solve across an integrator step — rather than throughsolve!.reinit!doesn't resetforce_stop/retcodeInternalAPI.reinit!(::NonlinearSolvePolyAlgorithmCache)resetscurrent/nsteps/stats/total_timebut leavesforce_stopandretcodeat their converged values.solve!(the@generatedpolyalgorithm method) drives the subcaches directly, so it is unaffected. ButCommonSolve.step!guards onnot_terminated(cache) = !cache.force_stop && cache.nsteps < cache.maxiters, readingforce_stopoff the polyalgorithm cache. So once any branch has converged, a warm-startedreinit!+step!loop no-ops on the firststep!and reuses the stale iterate.Minimal reproduction with the public API, no downstream package:
Fix: reset
force_stop/retcodeinreinit!, next to the existingnsteps/total_timeresets.bestis deliberately left untouched soretain_bestcontinuation is unaffected (polyalg_retention_testsstill passes 43/43).get_u/get_futhrow on a polyalgorithm cacheThe cache holds
u/fuoncaches[current], not at top level, so the genericget_u(cache) = cache.u/get_fu(cache) = cache.fufallbacks throw.SII.state_valuesalready delegates correctly viasymbolic_container; this adds the matchingget_u/get_fumethods so the two accessor families agree.Tests
test/Core/polyalg_step_reinit_tests__item1.jldrives a polyalgorithm cache onestep!at a time across areinit!for bothRobustMultiNewtonandFastShortcutNonlinearPolyalg, and checksget_u/get_fu. It fails on currentmaster(both thenot_terminatedguard and theget_u/get_fuaccessors) and passes with this change. Existingreinit_tests(18/18) andpolyalg_retention_tests(43/43) are unchanged.Found while fixing SciML/OrdinaryDiffEq.jl#3859, where
NonlinearSolveAlgwrapping a polyalgorithm hit both issues; the OrdinaryDiffEq side can drop its local workaround once this is released.AI Disclosure
Claude assisted with this work.