Repository navigation
HomotopyPolyAlgorithm: warm sweep→arclength handoff (#1020 P7) - #1030
Merged
ChrisRackauckas merged 1 commit intoJul 11, 2026
Merged
Conversation
ChrisRackauckas
marked this pull request as ready for review
July 11, 2026 04:03
When a HomotopySweep stage fails partway along the span, hand the next stage the remaining stretch instead of restarting it cold at λspan[1]: the problem is rebuilt with u0 = the sweep's last accepted iterate and λspan = (λ_h, λspan[2]), where λ_h is backed off 5% of the span width behind the last accepted λ. The backoff matters: the sweep dies at a fold, and arclength seeded exactly at the fold starts with its pure-λ initial tangent nearly orthogonal to the path — measured costlier than a full cold run — while a seed 5% behind is 12–23% cheaper (stage-only) on the benchmarked fold problems. The stage's own λ-fixed anchor solve pulls the off-path u0 back onto the path at λ_h. Span-relative step-size caps (max_step_factor, fixed-size nsteps) are rescaled by full/remaining width (capped at fraction 1) so a user-tightened absolute cap survives the span shrink; the initial step factor stays span-relative (starting small behind the fold measured cheaper). If the warm attempt fails, the stage is retried cold on the original full-range problem before moving on, so the handoff never costs robustness. A sweep that failed at the anchor, or within the backoff width of it, hands off nothing (cold behavior unchanged). Warm successes are rebuilt against the original problem (original λspan semantics and u type), with the shrunken-problem solution attached as `original`. `warm_handoff = false` recovers the plain staged behavior. The sweep's CommonSolve.solve is split into an internal driver that additionally returns the last accepted λ on partway failure; its public solve behavior is unchanged. Benchmarks (residual calls, warm vs cold total including the failed sweep): cubic S-curve fold 344 vs 364 (5.5%); 8-dim coupled fold 436 vs 506 (13.8%); S-curve with max_step_factor = 0.05 arclength 594 vs 704 (15.6%). Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude
force-pushed
the
warm-handoff-polyalg
branch
from
July 11, 2026 04:24
0bc796b to
325e1ea
Compare
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.
Part of #1020 (P7).
Note: This PR should be ignored until reviewed by @ChrisRackauckas.
What
HomotopyPolyAlgorithmtriedHomotopySweepfirst and, on failure, restarted theArcLengthContinuationfallback cold atλspan[1]— redoing the stretch the sweep had already conquered. Now, when the sweep fails partway, the next stage is first attempted on the remaining stretch: the problem is rebuilt withu0= the sweep's last accepted iterate andλspan = (λ_h, λspan[2]). Controlled by a newwarm_handoff::Bool = truekeyword onHomotopyPolyAlgorithm(falserecovers the old always-cold behavior).Design (each choice measured, not guessed)
u³ − 3u = −3 + 6λ, fold at λ = 5/6): arclength warm-started at the fold costs 226 residual calls vs 166 for a full cold run; backed off 5–10% it costs 127–146. The handed-overu0is the last accepted iterate (off-path atλ_hby the backoff distance); the stage's own λ-fixed anchor solve pulls it back onto the path in a few warm Newton iterations, so no extra machinery (and no accepted-point history) is needed in the sweep.max_step_factor(and a sweep stage's fixed-sizensteps) are fractions of the span width, so the shrunken span would silently shrink the absolute cap — measured 2.4× worse than cold on the S-curve withmax_step_factor = 0.05. The caps are rescaled byfull_width/remaining_width, capped at fraction 1 (an absolute step of the remaining width), because unbounded rescaling also measured worse near the fold (166 vs 146 stage calls). The initial step factor stays span-relative: starting small right behind the fold measured cheaper, and adaptivity regrows it within a few steps.λspan[1]anchor itself (no accepted point), or within the backoff width of it, hands off nothing — fallback stages run cold exactly as before (asserted by equal residual-call counts withwarm_handoffon/off).warm_handoff = false(tested with a stage that fails on any shrunken span but succeeds full-range).prob(original λspan semantics, originalutype); the shrunken-problem solution stays reachable throughoriginal. Stats/retcode forwarding is unchanged from the current single-stage return behavior.arclength.jlis untouched (churning in ArcLengthContinuation: consume jac/jac_prototype/sparsity/colorvec (#1020 item 2 follow-up, stacked on #1021) #1025); the sweep only had itsCommonSolve.solvesplit into an internal driver that additionally returns the last accepted λ on partway failure (public behavior unchanged).Benchmarks (residual calls via Ref counter, warm vs cold, totals include the failed sweep stage)
u³−3u = −3+6λ, fold at λ=5/6)max_step_factor = 0.05Stage-only (excluding the identical failed-sweep cost): 146 vs 166, 238 vs 308, 396 vs 506 — 12%, 23%, 22%.
Savings are structurally bounded on these S-curves because the post-fold back-swing (λ 5/6 → 1/6 → 1) dominates the arc; the skipped prefix grows (and with it the savings) the later the fold sits and the tighter the user's step caps are.
Tests
New
test/Core/homotopy_polyalg_tests__item2.jl(30 assertions): warm handoff succeeds on the S-curve fold with the correct root and strictly fewer residual calls than cold restart; the returned solution'sprobis the original with the shrunken-span stage solution asoriginalandutype preserved; anchor-failure and below-backoff-progress edge cases do identical work withwarm_handoffon/off; the double-fallback path (warm fails → cold full-range retry, verified via the spans the stage observed); Float32 handoff preserves eltype. All 33 existing homotopy/arclength/polyalg test files pass locally (Julia 1.12), e.g.:🤖 Generated with Claude Code