Repository navigation
NonlinearFunction docs: jac_prototype may be an AbstractSciMLOperator - #1640
Conversation
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk low. Full reviewVERDICT: MERGE PR: #1640 adds 3 lines to the Blocking findingsNone. Everything the three added lines claim matches the current NonlinearSolveBase/LinearSolve code, and I confirmed each claim by running it (see "What I ran").
Non-blocking findings
What I ran
What I did not verify
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
* Add a specialization marker to `OptimizationFunction`
`OptimizationFunction` had no specialization marker: its second type parameter is
the AD type, and `specialization(::OptimizationFunction)` returned that instead of
an `AbstractSpecialization`. The marker is now stored as the last type parameter,
after the field types, so code that spells out the existing parameters keeps
working. It defaults to `FullSpecialize`, so existing functions are unchanged.
`OptimizationFunction{iip, specialize}(f, adtype; kwargs...)` selects it, and
`specialization` returns it. `remake`, `ConstructionBase.setproperties` (and with
it `@set`) and `OptimizationProblem` keep it. The spelling that passes the AD
type as the second type parameter (`OptimizationFunction{iip, AD}(f; adtype)`)
still builds a `FullSpecialize` function.
What `AutoSpecialize` and `AutoDespecialize` do is up to the solver packages,
as for the other SciML functions.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
* Convert parameter objects to `DespecializedParameters`
Storage typed for despecialized parameters could not be assigned a new parameter
object. For example, an optimization cache built from an `AutoDespecialize`
problem stores `p` as a `DespecializedParameters`, and `reinit!(cache; p = new_p)`
threw `Cannot convert an object of type ... to an object of type
SciMLBase.DespecializedParameters`. `convert` now wraps the object, and returns an
already wrapped one unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
* Bump version to 3.58.0
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
NonlinearSolve.jl (NonlinearSolveBase
construct_jacobian_cache) already passes ajac_prototypethat is anAbstractSciMLOperator, and an operator returned byjac(u, p), to the linear solver as is, but theNonlinearFunctiondocstring only mentions prototype matrices. I hit this wiring a bordered Jacobian: a custom Jacobian type that is not an operator fails withCannot convert ... to Matrix, with no hint of the accepted types. This adds three lines to thejac_prototypeentry saying operators are accepted, and when they must be convertible. I checked the behaviour with NonlinearSolve 4.32 and aNewtonRaphsonusing aLinearSolveFunctionon Float64 and Float32.