Repository navigation
Accept λ-extended derivative arities in NonlinearFunction for HomotopyProblem - #1430
Merged
ChrisRackauckas merged 1 commit intoJul 10, 2026
Conversation
…yProblem HomotopyProblem documents that all functions of the wrapped NonlinearFunction follow the λ-extended argument convention (residual f(u, p, λ) / f(du, u, p, λ), jac jac(u, p, λ) / jac(J, u, p, λ)), and NonlinearSolve.jl's continuation solvers consume the derivative fields as of SciML/NonlinearSolve.jl#1022. But the NonlinearFunction constructor validated jac/jvp/vjp against the standard nonlinear arities, so a bare λ-extended jac was rejected at construction: NonconformingFunctionsError for a 3-argument out-of-place jac and TooManyArgumentsError for a 4-argument in-place jac. Users had to define a dummy λ-free method on their jac just to get past the check. Add a `lambda_extended` keyword (default `false`, not stored as a field) to the NonlinearFunction constructor that shifts the jac/jvp/vjp conformance arities by the one trailing λ argument, and shifts the residual in-place detection in the type-parameter-free constructor the same way. The standard checks are unchanged when the keyword is not passed, and nonconforming λ-extended functions are still rejected with the same errors. Also update the HomotopyProblem docstring: the derivative fields are now consumed by NonlinearSolve.jl's continuation solvers rather than "not consumed yet". Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas
marked this pull request as ready for review
July 10, 2026 07:46
This was referenced Jul 10, 2026
Merged
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Jul 10, 2026
SciMLBase#1430 added the lambda_extended NonlinearFunction kwarg so HomotopyProblem functions can declare λ-extended-only derivative arities without defining decoy (u, p) methods for the interface check. Drop the six error-throwing dummy methods and declare the intent directly. Requires the SciMLBase release containing SciML/SciMLBase.jl#1430 (unreleased as of this commit; latest registered 3.33.1 predates it). 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 10, 2026
The lambda_extended NonlinearFunction kwarg (#1430) is a new public feature, so the next release is a minor bump. Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
ChrisRackauckas-Claude
referenced
this pull request
Jul 11, 2026
* Flesh out solution interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out problem interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out algorithm interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out integrator interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify number type interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out SciMLFunction interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document init solve extension interfaces Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out ensemble interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out ensemble analysis docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document PDE discretization interfaces Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out sensitivity interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out interpolation interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify solution stats docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify solution utility docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document standard ODE problem marker Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify alias specifier docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document structured problem markers Co-Authored-By: Chris Rackauckas <[email protected]> * Flesh out remaining placeholder docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify clock and ODE nonlinear step docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document clock interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify initialization interface docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify optimization algorithm trait docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Clarify core algorithm trait docstrings Co-Authored-By: Chris Rackauckas <[email protected]> * Document symbolic save_idxs solution interface Co-Authored-By: Chris Rackauckas <[email protected]> * Document problem trait interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document callback interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document SciML function wrapper contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document low-level integrator interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document PDE discretization interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document alias specifier interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document sensitivity algorithm interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented algorithm interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented problem interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented solution interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented function interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented solver interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented clock interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented callback ensemble interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare documented algorithm traits public Co-Authored-By: Chris Rackauckas <[email protected]> * Declare remaining documented interfaces public Co-Authored-By: Chris Rackauckas <[email protected]> * Document integrator mutation interface rules Co-Authored-By: Chris Rackauckas <[email protected]> * Document initialization algorithm interface rules Co-Authored-By: Chris Rackauckas <[email protected]> * Document function argument validation rules Co-Authored-By: Chris Rackauckas <[email protected]> * Fix ensemble covariance matrix helpers Co-Authored-By: Chris Rackauckas <[email protected]> * Document integrator control interface rules Co-Authored-By: Chris Rackauckas <[email protected]> * Document specialization extension interfaces Co-Authored-By: Chris Rackauckas <[email protected]> * Document stochastic interpretation and return codes Co-Authored-By: Chris Rackauckas <[email protected]> * Document incrementing ODE interfaces Co-Authored-By: Chris Rackauckas <[email protected]> * Document common solver keyword contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document PDE discretization contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Document container and number contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Correct problem and Jacobian interface contracts Co-Authored-By: Chris Rackauckas <[email protected]> * Correct solution and ensemble interface guidance Co-Authored-By: Chris Rackauckas <[email protected]> * Add public problem layout trait Co-Authored-By: Chris Rackauckas <[email protected]> * Render concrete interface type references Co-Authored-By: Chris Rackauckas <[email protected]> * Remove duplicate interface doc entries Co-Authored-By: Chris Rackauckas <[email protected]> * Bump version for public problem trait Co-Authored-By: Chris Rackauckas <[email protected]> * Restore concrete type-law contracts in Array/Number interface docs The interface rewrite replaced the checkable algebraic type laws (`x::T + y::T = z::T`, `similar(x::T)::T`, `ArrayInterface.zeromatrix`, the mutable broadcast-assignment rules, the Newton-shift diagonal rule, etc.) with prose descriptions. The value of this page is that it is a specification a type can be checked against, so restore the type-signature laws as the normative contract. Where the prose surfaced genuinely-required operations that the old page omitted, add them as additional laws rather than dropping the old ones: subtraction on `T`, promotion closure, `copy`/`copyto!`/`fill!`, `mul!`, `similar` with element-type/dims, and the state-geometry inspection ops. Keep the accurate problem-algorithm-pair framing, the algorithm-capability traits, and the corrected note that no keyword bypasses interface checks (`interface_checks` does not exist in the source). Co-Authored-By: Chris Rackauckas <[email protected]> * Keep LinearProblem(A, b) summary line so doc-content test passes test/public_interface.jl pins that Array_and_Number.md mentions the generated `LinearProblem(A, b)` linear system. The type-law rewrite had replaced it with the typed `LinearProblem(A::M, b::C)` form and dropped the bare mention, failing the assertion at public_interface.jl:65. Restore the human-facing summary sentence alongside the typed law. Co-Authored-By: Chris Rackauckas <[email protected]> --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Jul 11, 2026
SciMLBase#1430 added the lambda_extended NonlinearFunction kwarg so HomotopyProblem functions can declare λ-extended-only derivative arities without defining decoy (u, p) methods for the interface check. Drop the six error-throwing dummy methods and declare the intent directly. Requires the SciMLBase release containing SciML/SciMLBase.jl#1430 (unreleased as of this commit; latest registered 3.33.1 predates it). Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas
added a commit
to SciML/NonlinearSolve.jl
that referenced
this pull request
Jul 11, 2026
…cked on next SciMLBase release) (#1027) * Replace dummy λ-free jac error methods with lambda_extended = true SciMLBase#1430 added the lambda_extended NonlinearFunction kwarg so HomotopyProblem functions can declare λ-extended-only derivative arities without defining decoy (u, p) methods for the interface check. Drop the six error-throwing dummy methods and declare the intent directly. Requires the SciMLBase release containing SciML/SciMLBase.jl#1430 (unreleased as of this commit; latest registered 3.33.1 predates it). Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]> * Raise SciMLBase compat floor to 3.34 for lambda_extended 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]>
5 tasks done
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.
Note
This PR should be ignored until reviewed by @ChrisRackauckas.
What
HomotopyProblem's docstring documents that all functions of the wrappedNonlinearFunctionfollow the λ-extended argument convention: residualf(u, p, λ)(oop) /f(du, u, p, λ)(iip), and derivative fields likewise, e.g.jac(u, p, λ)/jac(J, u, p, λ). As of SciML/NonlinearSolve.jl#1022 (for SciML/NonlinearSolve.jl#1020), NonlinearSolve's continuation solvers actually consume the derivative fields (jac,jac_prototype,sparsity,colorvec).However, the
NonlinearFunctionconstructor validatesjac/jvp/vjpagainst the standard nonlinear arities (jac(u, p)/jac(J, u, p)), so a bare λ-extended jac is rejected at construction time:jac(u, p, λ)→NonconformingFunctionsError(classified as an iip jac attached to an oop function)jac(J, u, p, λ)→TooManyArgumentsErrorNonlinearSolve#1022's tests currently work around this by defining a dummy λ-free method on every jac purely to get past the constructor.
Fix
Add a
lambda_extendedkeyword (defaultfalse, consumed by the constructor, not stored as a field) to theNonlinearFunctionconstructor that shifts thejac/jvp/vjpconformance-check arities by the one trailing λ argument, and shifts the residual in-place autodetection inNonlinearFunction(f; ...)fromisinplace(f, 3)toisinplace(f, 4)the same way:NonlinearProblems are untouched (existing@test_throwsfor both error paths are included in the new tests).lambda_extended = true, nonconforming functions are still rejected with the same error types, just against the λ-extended arities (also tested).Why this design (and not the alternatives)
HomotopyProblem's constructor path instead: not possible for the documented usage patternHomotopyProblem(NonlinearFunction{iip}(f; jac = ...), u0, p)— theNonlinearFunctionis fully constructed (and throws) beforeHomotopyProblemever sees anything, and noHomotopyProblemsignature receives bare derivative fields. MakingHomotopyProblem(f, u0, p; jac = ..., ...)split function-field kwargs out of its solver-kwarg passthrough would be a larger, more ambiguous API change and would still need a check bypass inside.sparsity/colorvec/operator jacs and be brittle to field changes).Docstring updates:
NonlinearFunctiondocuments the new keyword;HomotopyProblemno longer says continuation solvers "do not consume them yet" and points tolambda_extendedfor construction.Verification (all run locally, Julia 1.11.9)
NonconformingFunctionsErroroop /TooManyArgumentsErroriip), then made them pass.test/homotopy_problem_tests.jl(including the new λ-extended testsets): 48/48 pass.test/function_building_error_messages.jl(conformance/isinplace/numargsmachinery): 265/265 pass.test/problem_building_test.jl: 34/34 pass.homotopy-jac-passthroughbranch with this SciMLBasePkg.developed in: rantest/Core/homotopy_jac_tests__item1.jlwith all six dummy λ-free jac methods removed andlambda_extended = trueadded to the jac-carrying constructions — 30/30 pass (analytic jac consumed in oop/iip/polyalg/SimpleHomotopySweep paths, Tridiagonaljac_prototypehonored).🤖 Generated with Claude Code