Repository navigation
ArcLengthContinuation: consume jac/jac_prototype/sparsity/colorvec (#1020 item 2 follow-up, stacked on #1021) - #1025
Merged
ChrisRackauckas merged 2 commits intoJul 11, 2026
Conversation
…ciML#1020 item 2 follow-up) The user's λ-extended `jac(u, p, λ)` / `jac(J, u, p, λ)` supplies only the n×n ∂H/∂u block, but the arclength driver differentiates two larger systems: the packed path system behind the `:tangent` predictor (the n×(n+1) augmented Jacobian [∂H/∂u | ∂H/∂λ]) and the (n+1)×(n+1) bordered corrector system with the θ-weighted Keller constraint row. ∂H/∂λ-column design: the missing column is a scalar-parameter derivative, so it is taken as ONE forward-mode derivative of the residual in λ at fixed u — a DifferentiationInterface `derivative` of the λ-shifted residual with (u, p) as `Constant` contexts, prepared once at solve start and reused every call — rather than differentiating the packed system wholesale. `AugmentedPathJac` assembles [user ∂H/∂u | ∂H/∂λ] under the standard 2/3-argument Jacobian convention, so the tangent predictor consumes it through `construct_jacobian_cache`'s ordinary `has_jac` path unchanged. The corrector's `AugmentedHomotopyJac` embeds the same path Jacobian as its top block and writes the constraint row analytically — it is the θ-weighted τ, read from the same in-place-updated τ buffer the per-step residual reads, so the Jacobian and the residual cannot desynchronize (`ds`/`xcur` do not enter: the constraint is affine in x, its gradient independent of both). Bordered prototype: `jac_prototype` / matrix `sparsity` are extended to the augmented shapes — one structurally dense ∂H/∂λ column for the predictor's n×(n+1) system, plus the structurally dense constraint row for the corrector's bordered (n+1)×(n+1) system. Sparse/structured prototypes are promoted to SparseMatrixCSC via the STRUCTURAL pattern (`Utils.structural_sparse`, new in the SparseArrays extension — `sparse(x)` would drop zero-valued band entries): a bordered Tridiagonal is no longer tridiagonal, and CSC is what the coloring and sparse-LU machinery handle; without SparseArrays loaded, structured prototypes fall back to a dense bordered prototype. A sparsity detector is forwarded unchanged (it detects the augmented pattern from the augmented residual itself). The user `colorvec` is extended by one fresh color for the predictor's dense λ column; it is not forwarded to the corrector, whose dense constraint row admits no nontrivial column coloring — the bordered pattern's value there is chiefly the sparse linear solve. The λ-fixed anchor/landing solves reuse the sweep's `_sweep_nonlinear_function` forwarding from SciML#1022. When no derivative fields are present, every construction is exactly the previous one (branches decided by the problem's type), verified by unchanged residual-eval counts against the base branch. Tests: test/Core/arclength_jac_tests__item1.jl (registered in the core group) covers analytic-jac consumption through the augmented corrector and through the tangent predictor on the S-fold problem (root to 1e-4, counters > 0, jac evaluations at interior λ prove the corrector consumed it), analytic-vs-AD solution agreement, the augmented/bordered prototype structure (zero-valued band survival, dense borders, CSC promotion), an n = 50 tridiagonal fold-free system solved with `:tangent` both with jac+prototype (asserting the corrector's Jacobian buffer is the bordered (n+1)×(n+1) SparseMatrixCSC) and with prototype+colorvec without an analytic jac, no-field construction type-identity, and no-field root/residual-count determinism. SparseArrays and SparseMatrixColorings are added to the root test target for the sparse assertions. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
…gression it actually guards Empirically, sparse() on band-copying structured types (Tridiagonal, SymTridiagonal, Bidiagonal) preserves zero-valued structural entries — the docstring's Tridiagonal justification was wrong. The type where the plain conversion is value-based is Diagonal: sparse(Diagonal(zeros(n))) has zero stored entries, which would silently drop the pattern sparse AD coloring needs. Test the case that actually requires the helper. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude
force-pushed
the
arclength-jac-fields
branch
from
July 10, 2026 12:08
623dcab to
48df803
Compare
This was referenced Jul 10, 2026
ChrisRackauckas
marked this pull request as ready for review
July 11, 2026 03:58
ChrisRackauckas
added a commit
that referenced
this pull request
Jul 11, 2026
…l) (#1028) Add an opt-in `tracking_abstol` kwarg to HomotopySweep and SimpleHomotopySweep (#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 #1025); it gets the same treatment in a follow-up. Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
ChrisRackauckas
added a commit
that referenced
this pull request
Jul 11, 2026
…1020 P6, stacked on #1025) (#1029) * ArcLengthContinuation: reuse ONE corrector cache across continuation steps Bring the arclength corrector to parity with the HomotopySweep cache driver (#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]> * item8: attribute the residual per-step allocations precisely (review) 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]> --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Fable 5 <[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
added a commit
that referenced
this pull request
Jul 11, 2026
…rseArrays ext (#1035) GROUP=QA for lib/NonlinearSolveBase errors on master (introduced by 7ff3239, PR #1025, which added Utils.structural_sparse and Utils.is_extension_loaded to the SparseArrays extension): - all_qualified_accesses_via_owners: `ArrayInterface` accessed via `NonlinearSolveBase` instead of its owner - all_qualified_accesses_are_public: `ArrayInterface`, `is_extension_loaded`, `structural_sparse` non-public accesses Fix the first by importing ArrayInterface directly (it is a hard dep of NonlinearSolveBase; the ForwardDiff/LinearSolve extensions already do `using ArrayInterface: ArrayInterface`), so `findstructralnz` is now reached through its owner, where it is declared public (7.26+). `is_extension_loaded` and `structural_sparse` are NonlinearSolveBase's own internal extension hooks defined via qualified `Utils.` names, the same pattern as the sibling hooks (make_sparse, condition_number, maybe_symmetric, ...) that already sit in the qa.jl all_qualified_accesses_are_public ignore list; add them there alongside. 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.
Important
Please ignore this PR until it has been reviewed by @ChrisRackauckas. Opened as a draft by an agent; do not merge or act on it before that review.
Implements derivative-field consumption (
jac/jac_prototype/sparsity/colorvec) forArcLengthContinuation— item 2 of the #1020 roadmap for the arclength driver, i.e. the follow-up explicitly left out of #1022 (which did the same for the sweep drivers,HomotopySweep/SimpleHomotopySweep).Stacking
This PR is stacked on #1021.#1021 has merged; this branch is now rebased directly onto master and carries only its own commits (the derivative-field work plus thestructural_sparsedocstring/test correction from review). Full arclength suite re-run locally post-rebase: 145/145 pass.Why this needs more than the sweep's λ-fixing wrapper
The user's λ-extended
jac(u, p, λ)provides only the n×n ∂H/∂u block, but the arclength driver differentiates two larger systems over the packed variablex = [u; λ]:[∂H/∂u | ∂H/∂λ].[∂H/∂u ∂H/∂λ; wᵀ]wherewis the θ-weighted Keller constraint row.Design
derivativeof a λ-shifted residual with(u, p)asConstantcontexts, prepared once per solve and reused) — never a wholesale differentiation of the packed system.AugmentedPathJacassembles[user ∂H/∂u | ∂H/∂λ]under the standard 2/3-argument Jacobian convention and is wired as the analyticjacof the packedHomotopyResidualNonlinearFunction, so the:tangentpredictor consumes it throughconstruct_jacobian_cache's existinghas_jacpath with no changes to the Jacobian tooling.AugmentedHomotopyJacembeds the same path Jacobian as its top n rows and writes the constraint row analytically. It reads the same in-place-updated τ buffer that the per-stepAugmentedHomotopyresidual reads (mirroring the base branch's τ threading), so the Jacobian and residual can never desynchronize;ds/xcurdo not enter the Jacobian because the constraint is affine inx.jac_prototype/ matrixsparsityare extended to the augmented shapes — a structurally dense ∂H/∂λ column for the predictor (n×(n+1)), plus the structurally dense constraint row for the corrector ((n+1)×(n+1), i.e.[proto col; rowᵀ 1]). Sparse/structured prototypes are promoted toSparseMatrixCSC— a borderedTridiagonalis no longer tridiagonal, and CSC is what the coloring and sparse-LU machinery handle. The conversion goes through a newUtils.structural_sparse(SparseArrays extension) that preserves the structural pattern:sparse(x)would silently drop zero-valued band entries (the standardTridiagonal(zeros, ones, zeros)prototype idiom). Without SparseArrays loaded, structured prototypes fall back to a dense bordered prototype. Dense prototypes stay dense; prototypes are not eltype-promoted with λ (same documented choice as Sweep drivers: consume jac/jac_prototype/sparsity/colorvec from the NonlinearFunction (#1020 item 2) #1022).sparsity === jac_prototypeobject identity theNonlinearFunctionconstructor establishes (required byconstruct_concrete_adtype). The usercolorvecis forwarded to the predictor's system extended by one fresh color for the dense λ column (valid for column coloring); it is not forwarded to the corrector — the structurally dense constraint row makes every pair of columns conflict, so no nontrivial column coloring exists for the bordered pattern, and its coloring (when sparse AD applies) is recomputed. The bordered prototype's value for the corrector is chiefly the sparse linear solve._sweep_nonlinear_functionfrom Sweep drivers: consume jac/jac_prototype/sparsity/colorvec from the NonlinearFunction (#1020 item 2) #1022 (λ-fixedFixLambdaJac, fields forwarded unchanged), so the whole driver is consistent._sweep_nonlinear_functionand is byte-identical to the base branch when no derivative field is present. Verified by running a residual-counting closure on the S-fold problem against the unmodified base branch: secant 203 evals / tangent 158 evals and bit-identical roots on both branches.Same SciMLBase wrinkle as #1022:
NonlinearFunction's arity-based conformance check rejects bare λ-extended jacs, so the tests supply loudly-erroring dummy λ-free methods. A SciMLBase-side fix is in flight separately; nothing here waits on it.Tests
New
test/Core/arclength_jac_tests__item1.jl, registered in thecoregroup right afterhomotopy_jac_tests__item1.jl:inner = NewtonRaphson(), default:secant): counters > 0, jac evaluations at interior λ (only the corrector evaluates there — anchor/landing sit at exactly λ = 0/1), S-fold root correct to 1e-4;:tangentpredictor: counter > 0, root correct to 1e-4;:tangent: jac + prototype (asserts the corrector's Jacobian buffer is the bordered (n+1)×(n+1)SparseMatrixCSCand the anchor kept the user's ownTridiagonal), and prototype + colorvec without an analytic jac (sparse AD end-to-end); both solve to residual < 1e-8;SparseArrays(stdlib) andSparseMatrixColoringswere added to the root[extras]/test target for the sparse assertions. No version bumps.What ran locally (Julia 1.11.9)
@safetestsetinclude paths:homotopy_sweep_tests__item{1–21},arclength_tests__item{1–7},homotopy_jac_tests__item1,arclength_jac_tests__item1(new),homotopy_effort_tests__item{1,2},homotopy_polyalg_tests__item1— 338/338 pass, exit 0 (33 items; the battery was run twice — 336/336 on the previous base tip, and 338/338 after rebasing onto the base's latest LinearSolve-backed bordered-solve commit, which added 2 tests).--inplacethen--check(exit 0) on all touched files.Note: this branch is rebased onto the pushed
arclength-bordered-thetatip (currently the LinearSolve-backed bordered-solve review commit), not the stale local copy it started from.🤖 Generated with Claude Code