Allow matrix-backed operator Jacobians in LHL defaults - #1274
Merged
ChrisRackauckas merged 1 commit intoAug 30, 2026
Merged
Conversation
Let the LHL default predicate inspect the matrix backing a MatrixOperator while leaving matrix-free operators on the Krylov path. Preserve WOperator identity in DefaultLinearSolver so Jacobian staleness updates reach the cached reduction. Add a regression covering default selection, cache initialization, and a marked in-place Jacobian update, and document the expanded default. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: OpenAI Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.151.0 Agent-Model: unknown Agent-Session: local session ID 01a0507d-8515-73c0-841a-d7231caf221a
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.
What changed and why
Now that OrdinaryDiffEq marks a
WOperatorstale when an operator-backed Jacobian moves in place, LinearSolve can remove the consumer-side exclusion added in #1215. The LHL default predicate now inspects the matrix backing aMatrixOperator, while matrix-free operators still fall through to Krylov.DefaultLinearSolveralso aliasesWOperatorinputs. The staleness flag belongs to the wrapper, so copying the wrapper atinitdisconnected the producer'smark_jacobian_updated!call from the wrapper observed by the LHL cache even though both wrappers shared the same matrix data.The regression covers default selection, LHL cache initialization, wrapper identity, the first solve, and a marked in-place Jacobian update. The LHL docstring and shifted-systems tutorial describe the expanded default.
Failing before / passing after
Test-only state on unmodified
main:Widening the predicate alone exposed the second half of the bug: the default selected LHL, but the copied wrapper did not receive the staleness signal, so the updated-J assertion failed with the old solution (
4 passed, 1 failed). After preservingWOperatoridentity:Verification
The first standard QA invocation spent its full one-hour budget in automatic Reactant extension precompilation before any QA assertion ran. Disabling only automatic precompilation allowed the unchanged QA group to execute and pass. The docs environment likewise needed a temporary Python environment for its already-declared PyAMG dependency after the machine-local Pixi environment failed to load Python's
encodingsmodule; the actual Documenter build then completed.CI
At commit
f8276dd69e3a616abfc5fa2875fe698688ad1f18, 60 checks passed and one generated matrix entry was skipped. The sole failure was ModelingToolkit's downstreamAllsuite:The identical CasADi failure occurs on unmodified upstream
mainat85b24a13f17cf6c0813a34c3f906f7cac92c527c, so this branch did not introduce it. A clean local checkout reproduced the same first Optimization error with LinearSolve 5.15.0, ModelingToolkit 11.40.1, CasADi 1.3.0, and SymbolicUtils 4.46.1 (1 passed, 1 errored).Commit-level boundary testing identified CasADi
54f83b489d1d99afd53a7571d94e5e66d03bb1c7as good andb041ed63a5beb49f24620cd97de0e35c514c3115as the first bad commit. CasADi PR 42 already restores the removed SymbolicUtilscreate_arrayintegration. With its merge commita879b555aab7ea46ab24409c49025d7b99f15f35, the actual previously failing ModelingToolkitadd_solve_constraints!path returnedOptiand passed. A later full-file local run hit an unrelated pip-CasADi/Julia-Ipopt ABI symbol error, so the entire file was not verified locally with the fix.No duplicate issue was opened. CasADi's draft 1.3.1 release PR is the existing delivery path and currently has eight passing checks.
Not verified
GROUP=Everythinglocally; CI ran the declared version, platform, sublibrary, and downstream matrix, with only the pre-existing ModelingToolkit failure documented above.Reviewer decision
This default is safe only when the producer honors the
WOperatorstaleness contract. OrdinaryDiffEqmasternow does, but older OrdinaryDiffEq releases do not, and LinearSolve cannot express a compat bound on a downstream package. Release sequencing or an explicit capability signal may be preferable to immediately shipping the widened default.Aliasing all
WOperatorinputs inDefaultLinearSolveris intentional because its eligible branches are operator algorithms (LHL or Krylov) that need the live operator. Please push back if copying aWOperatoris expected public behavior for another default-solver path.Links
🤖 Generated with Codex CLI 0.151.0 (model: unknown; session: local session ID 01a0507d-8515-73c0-841a-d7231caf221a).