Skip to content

Homotopy sweeps: loose-then-tight tracking tolerances (tracking_abstol) - #1028

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:loose-tight-tracking-tolerances
Jul 11, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:loose-tight-tracking-tolerances

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Part of #1020 (P5).

Note: This PR should be ignored until reviewed by @ChrisRackauckas.

What

Adds an opt-in tracking_abstol keyword to HomotopySweep and SimpleHomotopySweep. Interior tracking steps of a continuation sweep only need enough accuracy to keep the secant predictor useful and to stay inside the next step's Newton convergence basin — they are warm starts, not answers. With tracking_abstol set, those interior corrector solves run at the loose absolute tolerance while the returned solution still satisfies the user's full tolerances, so the accuracy semantics of the result are unchanged.

This is standard practice in production path trackers: Bertini tracks at 1e-5/1e-6 and only the endgame runs tight; HomotopyContinuation.jl accepts steps on Newton contraction and polishes endpoints; AUTO-07p correctors run at path-tracking tolerances well looser than typical solution reporting tolerances. Values around 1e-4–1e-6 are good starting points when opting in.

Design (mirrors the tracking_maxiters precedent from #1024 exactly)

  • Anchor and landing are exempt. The λspan[1] anchor solve (the one cold start, and the returned solution for a zero-width span) and the final landing on λspan[2] always run at the user's full tolerances.
  • Cache driver (HomotopySweep): the loose abstol is baked into the single shared inner cache. It cannot be changed per-reinit! — the polyalgorithm cache's InternalAPI.reinit! accepts only p/u0, no tolerance kwargs (checked in lib/NonlinearSolveBase/src/polyalg.jl). So the anchor runs as a standalone full-tolerance solve, and the landing is re-polished at the full tolerance warm-started from the loose landing solve (~1–2 extra corrector iterations). The existing _sweep_uncapped_solve rescue was generalized into _sweep_exempt_solve (which now also forwards jac/jac_prototype/sparsity/colorvec like the tracking cache, matching Sweep drivers: consume jac/jac_prototype/sparsity/colorvec from the NonlinearFunction (#1020 item 2) #1022).
  • Value driver (SimpleHomotopySweep): every step is a fresh standalone solve, so the exemption is simply not splicing the loose kwargs into the anchor/landing solves — no re-polish needed. The StaticArray/scalar paths remain allocation-free (AllocCheck run locally, including with tracking_abstol active).
  • Explicit user tolerances win: a user-passed abstol or reltol (solve kwarg or problem kwarg) disables the loosening entirely. Splicing a loose abstol next to a user reltol would let the loose criterion fire first in the default OR-combined termination modes, silently overriding the user's intent.
  • Constructor validation consistent with tracking_maxiters: must be positive, nothing disables.
  • Default is nothing (disabled). Loose interior iterates slightly degrade the secant/quality signals the step controller reads, and on trivial problems the two extra standalone solves (anchor + landing polish) can cost more wall time than the saved residual calls (see benchmarks), so the loosening stays opt-in.

Benchmarks (Julia 1.12, tracking_abstol = 1e-4 vs disabled)

Problem retcode tight→loose resid calls tight resid calls loose time tight time loose final |Δu|
scalar monotone u³-1-λ (Newton inner) Success → Success 53 43 (−19%) 2.88e-05 s 4.85e-05 s (+68%) 0
scalar monotone (SimpleHomotopySweep) Success → Success 43 27 (−37%) 5.63e-06 s 3.65e-06 s (−35%) 0
S-curve u³-3u = -3+6λ (Newton inner) MaxIters → Success 746 98 (−87%) 2.67e-04 s 6.95e-05 s (−74%) n/a
S-curve (SimpleHomotopySweep) Success → Success 76 64 (−16%) 9.93e-06 s 8.29e-06 s (−17%) 0
n=50 coupled cubic (Newton inner) Success → Success 1247 835 (−33%) 1.31e-03 s 8.27e-04 s (−37%) 2.2e-16
n=50 coupled cubic (default polyalg inner) Success → Success 2122 1442 (−32%) 2.93e-03 s 2.21e-03 s (−25%) 2.2e-16

Honest notes on two rows:

  • Scalar HomotopySweep wall time goes up despite fewer residual calls: the anchor's standalone solve and the landing re-polish each pay one full solve pipeline entry (~10 μs), which dominates a trivial scalar problem. The constant is amortized on anything nontrivial (n=50: −37% wall time). This is part of why the default is off — the feature targets problems where residual/Jacobian evaluations are the cost.
  • The S-curve row is a fold problem (turning points at λ = 1/6, 5/6), which natural continuation fundamentally cannot round. Tight, the NewtonRaphson sweep burns 746 residual calls bisecting into the fold and fails with MaxIters; loose, the corrector branch-jumps across the fold and lands (verified at full tolerance by the exempt landing) on the correct λ=1 root. The Simple driver's tight baseline already branch-jumps the same way. Branch jumping at folds is inherent to natural continuation — ArcLengthContinuation remains the right tool there — but it's worth knowing the loose tolerance makes the jump more likely.

Tests

test/Core/homotopy_tolerance_tests__item1.jl (registered in the Core group), covering for both drivers: (a) the final solution meets the full tolerance (residual < 1e-9 with tracking_abstol = 1e-3), (b) residual-call counts drop vs disabled (Ref-counter pattern per the effort tests, with generous margins over the measured reductions), (c) anchor exemption (zero-width span with a loose tolerance that provably stops far from the root standalone) and landing exemption (nsteps = 1, adaptive = false so the only step is the landing), (d) user abstol/reltol override at both solve and problem level (bitwise-identical call counts to disabled), (e) constructor validation. Also verified locally: all 231 Core homotopy tests, all 64 SimpleNonlinearSolve homotopy tests, and the SimpleNonlinearSolve AllocCheck homotopy tests (plus new AllocCheck runs with tracking_abstol enabled) pass.

Follow-up

ArcLengthContinuation intentionally untouched — lib/NonlinearSolveBase/src/arclength.jl is churning in the open #1025. It gets the same loose-then-tight treatment in a follow-up PR once that lands.

🤖 Generated with Claude Code

Add an opt-in `tracking_abstol` kwarg to HomotopySweep and
SimpleHomotopySweep (SciML#1020 Priority 5): interior tracking steps only need
enough accuracy to keep the predictor useful and stay inside the next
corrector's convergence basin, so they may run at a loose absolute
tolerance while the returned solution still satisfies the user's full
tolerances.

Mirroring the tracking_maxiters precedent exactly:

- The λspan[1] anchor solve and the final landing on λspan[2] are exempt.
  HomotopySweep bakes the loose abstol into its single shared inner cache
  (`abstol` cannot be changed through `reinit!` — the polyalgorithm
  cache's `InternalAPI.reinit!` accepts only `p`/`u0`), so the anchor
  runs as a standalone full-tolerance solve and the landing is
  re-polished at the full tolerance warm-started from the loose landing
  solve (~1-2 extra corrector iterations). SimpleHomotopySweep's steps
  are fresh standalone solves, so the exemption is simply not splicing
  the loose kwargs there.
- An explicit user-passed `abstol` OR `reltol` (solve kwarg or problem
  kwarg) disables the loosening entirely: splicing a loose abstol next
  to a user reltol would let the loose criterion fire first in the
  default OR-combined termination modes.
- Constructor validation consistent with tracking_maxiters
  (positive or `nothing`).

Default is `nothing` (disabled): the loose interior iterates slightly
degrade the secant/quality signals the step controller reads, so
loosening stays opt-in; 1e-4-1e-6 are good starting values (Bertini
tracks at 1e-5/1e-6 with only the endgame tight; HomotopyContinuation.jl
accepts on Newton contraction and polishes endpoints).

Measured at tracking_abstol = 1e-4 (Julia 1.12): scalar cubic with
NewtonRaphson inner 53 -> 43 residual calls; n = 50 coupled cubic
1247 -> 835 (-33%, -37% wall time; default polyalg inner 2122 -> 1442);
SimpleHomotopySweep scalar path 43 -> 27 (-37%, -35% wall time). The
SimpleHomotopySweep StaticArray/scalar paths remain allocation-free
(AllocCheck) with the loosening active.

ArcLengthContinuation intentionally untouched (churning in SciML#1025); it
gets the same treatment in a follow-up.

Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 11, 2026 04:01
@ChrisRackauckas
ChrisRackauckas merged commit 8dd0f0d into SciML:master Jul 11, 2026
92 of 95 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants