Repository navigation
ArcLengthContinuation: corrector cache parity with the sweep driver (#1020 P6, stacked on #1025) - #1029
Merged
ChrisRackauckas merged 2 commits intoJul 11, 2026
Conversation
ChrisRackauckas
marked this pull request as ready for review
July 11, 2026 03:59
…steps Bring the arclength corrector to parity with the HomotopySweep cache driver (SciML#1020 P6): the corrector's Newton cache — and with it the Jacobian cache and linear-solve cache — is init-ed once around a single AugmentedHomotopy residual and reused every step via reinit!/solve!, instead of rebuilding the problem/function/cache per corrector attempt. - AugmentedHomotopy becomes mutable-with-const-fields (like the sweep's FixLambda): τ and xcur alias stable driver buffers updated in place, ds is a field write, so advancing the continuation never re-creates the residual or anything compiled around it. - The constraint row evaluates ⟨τ, x - x0⟩_θ through _theta_dot_shifted without materializing x .- xcur (which heap-allocated per inner residual call, in Dual eltype under the corrector's AD). - Glue temporaries get preallocated buffers: xpred, the realized chord (reusing the secant scratch), the packed history shift, the accepted u-block, and the landing warm start; the packed point and pure-λ seed are built without the splatting pack() helper. - When tracking_maxiters is active the cap is baked into the one cache (reinit! preserves cache.maxiters); the anchor and landing solves keep the user's full budget as before. Measured per continuation step on the n = 50 coupled cubic system (item7), fixed-ds slope between 50- and 250-step runs, Julia 1.12: iip secant 274 KB -> 56 KB iip tangent 295 KB -> 77 KB oop secant 441 KB -> 160 KB oop tangent 507 KB -> 226 KB The remainder is the inner polyalgorithm's own per-iteration internals (LU workspace, quasi-Newton updates), shared with the sweep — the sweep itself measures ~74 KB/step on the same problem. A regression test (arclength_tests__item8.jl) bounds the post-warmup per-step slope well under half the uncached cost. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude
force-pushed
the
arclength-corrector-cache
branch
from
July 11, 2026 04:15
d7d7031 to
32d7773
Compare
Profile.Allocs attribution: the driver glue is < 1 KB/step; the bulk is LinearSolve's alias_A-gated lu(A) copy (~21.5 KB) and Broyden's maybe_pinv!! initial J⁻¹ (~21.5 KB), both shared Newton-stack behavior addressed in follow-ups, not driver work. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas
added a commit
that referenced
this pull request
Jul 11, 2026
… NonlinearSolve 4.20.4 (#1034) Registered versions (NLSB 2.33.0 on 2026-07-06) predate the merged homotopy work: #1021, #1022, #1024, #1025, #1028, #1029 (NLSB features => minor), #1028's tracking_abstol on SimpleHomotopySweep (=> minor), and #1027's SciMLBase 3.34 compat floor (top-level => patch). Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Jul 11, 2026
…ed tracking steps HomotopySweep and the ArcLengthContinuation corrector now call reinit_retaining! on their tracking reinit!s: a polyalgorithm inner (the default) resumes from the subalgorithm that won the previous solve instead of re-running the ladder from its start every step; non-polyalgorithm inners get a plain reinit! (no change). The cold anchor solve at λspan[1] (and arclength's λ-fixed anchor/landing solves) still runs the full ladder — that is where the winner is discovered. Residual calls on the post-SciML#1029 benchmark set (default inner, master → this branch, vs NewtonRaphson() inner): - P1 scalar monotone sweep: 150 → 94 (Newton 86) - P2 S-curve sweep cost-to-fail: 2506 → 2344 (Newton 746) - P2 S-curve arclength: 381 → 267 (Newton 188) - P3 n=50 coupled cubic sweep: 2295 → 1577 (Newton 1400) - P4 hard ramp sweep: 246 → 204 (Newton 123; the remaining gap is entirely the full-ladder anchor: interior overhead is zero) SimpleHomotopySweep is deliberately untouched: it reconstructs a fresh stack-allocated solve per step (no persistent inner cache) and defaults to SimpleNewtonRaphson, so there is nothing to retain. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
This was referenced Jul 11, 2026
ChrisRackauckas
added a commit
that referenced
this pull request
Jul 11, 2026
…ky polyalg rung + lazy reinit!) (#1036) * NonlinearSolvePolyAlgorithm: best-subalgorithm retention via reinit!(cache; retain_best = true) When a polyalgorithm cache is reused across warm-started solves (init/reinit!/solve!), every reinit! restarted the ladder at start_index and eagerly reinitialized all subcaches — each of which evaluates the residual at the new u0 — so drivers like the homotopy continuation loops paid one residual call per rung per step plus a re-fail of every cheap rung below the winner. reinit!(cache; retain_best = true) (opt-in; plain reinit! is byte-for-byte the status quo) makes the next solve! start from the subalgorithm that produced the last recorded success: - Escalation is preserved: a failing sticky rung continues up the ladder. - A fully-failed pass wraps around to the skipped cheaper rungs, floored at the algorithm's own start_index (measured: wrapping to rung 1 made the failure path more expensive than the status quo on small systems whose ladder starts at Newton), so retention never attempts fewer rungs than a full ladder run and never attempts rungs start_index excludes. - Subcache reinitialization is lazy: only the starting rung is reinitialized up front; escalation freshens further rungs when it reaches them, cutting the per-reinit! residual cost from one call per rung to one per rung attempted. - Every 8th retained reinit! whose retained rung sits above start_index re-probes from start_index, so a cheap rung that failed once transiently is rediscovered instead of locked out forever. cache.best is now also recorded on the generated solve! path (previously only step! set it), which the retention start relies on. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]> * Homotopy drivers: retain the winning inner subalgorithm on warm-started tracking steps HomotopySweep and the ArcLengthContinuation corrector now call reinit_retaining! on their tracking reinit!s: a polyalgorithm inner (the default) resumes from the subalgorithm that won the previous solve instead of re-running the ladder from its start every step; non-polyalgorithm inners get a plain reinit! (no change). The cold anchor solve at λspan[1] (and arclength's λ-fixed anchor/landing solves) still runs the full ladder — that is where the winner is discovered. Residual calls on the post-#1029 benchmark set (default inner, master → this branch, vs NewtonRaphson() inner): - P1 scalar monotone sweep: 150 → 94 (Newton 86) - P2 S-curve sweep cost-to-fail: 2506 → 2344 (Newton 746) - P2 S-curve arclength: 381 → 267 (Newton 188) - P3 n=50 coupled cubic sweep: 2295 → 1577 (Newton 1400) - P4 hard ramp sweep: 246 → 204 (Newton 123; the remaining gap is entirely the full-ladder anchor: interior overhead is zero) SimpleHomotopySweep is deliberately untouched: it reconstructs a fresh stack-allocated solve per step (no persistent inner cache) and defaults to SimpleNewtonRaphson, so there is nothing to retain. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]> --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Fable 5 <[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.
Stacked on #1025.#1025 has merged; this branch is rebased directly onto master and carries only its own commit. Full arclength suite (including the new allocation-regression test) re-run locally post-rebase: 153/153 pass.Note: This PR should be ignored until reviewed by @ChrisRackauckas.
Part of #1020 (P6 — the remaining per-step allocation bulk in
ArcLengthContinuation).What
The merged #1021 moved the bordered tangent solve into a preallocated workspace, but the arclength corrector still rebuilt its residual closure,
NonlinearProblem, and inner-solver cache (Newton state + Jacobian cache + linear-solve cache) on every continuation step, plus a pile of glue temporaries (vcat/copy/broadcast temporaries in the predictor/accept/landing paths). TheHomotopySweepdriver already had the one-cachereinit!/solve!pattern; this PR gives the arclength corrector parity:AugmentedHomotopybecomes mutable-with-const-fields (mirroring the sweep'sFixLambda):τ/xcuralias stable driver buffers updated in place,dsis a field write — the ONE residual (and the one inner-solver cache built around it at init) is reused for every corrector attempt.⟨τ, x − x₀⟩_θvia a new_theta_dot_shiftedwithout materializingx .- xcur(that temporary heap-allocated on every inner residual call, in Dual eltype under the corrector's AD).xpred, the realized chord (reusing the secant scratch), the packed-history shift, the accepted u-block, the landing warm start; the splattingpack()helper is gone.tracking_maxitersis active the cap is baked into the one cache (reinit!preservescache.maxiters); the anchor and landing solves keep the user's full budget, exactly as before.Measured per-step allocations
n = 50 coupled cubic system (the
arclength_tests__item7.jlbenchmark), fixed-ds slope between 50- and 250-step runs, post-warmup, Julia 1.12:The remainder is the inner polyalgorithm's own per-iteration internals (LinearSolve LU workspace, quasi-Newton update rules), which are shared with the sweep —
HomotopySweepitself measures ~74 KB/step on the same problem, so the corrector driver is now at (slightly better than) sweep parity. The oop rows additionally carry the user residual's ownsimilar(u)+vcatper call, inherent to oop.Tests
test/Core/arclength*.jlfiles pass unmodified (153 tests), plus thehomotopy_effort/homotopy_polyalg/homotopy_jacsuites that exerciseArcLengthContinuation(102 tests), run locally against this branch.test/Core/arclength_tests__item8.jlbounds the post-warmup per-step slope (secant < 128 KB, tangent < 160 KB — ~2× the cached cost, under half the uncached cost, so a per-step cache rebuild regression trips it with wide margin).🤖 Generated with Claude Code