Skip to content

Solve with a SciMLStructures right-hand side - #1210

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
AJ0070:feat/1208-scimlstructures-rhs
Aug 14, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:mainfrom
AJ0070:feat/1208-scimlstructures-rhs

Conversation

@AJ0070

@AJ0070 AJ0070 commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

  • Closes Support SciMLStructures right-hand sides at the init level #1208, the follow-up to Krylov: support an ArrayPartition right-hand side #1206 for a right-hand side that implements the SciMLStructures interface but is not an array, such as the Parameters object from the SciMLStructures docs or an MTKParameters.
  • It failed in __init at real(eltype(b)) while computing the tolerance defaults, before any algorithm was reached, so this affected every algorithm rather than only the Krylov wrappers.
  • canonicalize gives a flat buffer of the tunable values that the existing machinery already handles, and the interface's own repack rebuilds the container. The buffer is built once at init and the solve writes back with replace!, so a repeated solve does not allocate a new container.
  • The answer goes into its own container rather than into b, which has to survive the solve. There is a test asserting the right-hand side is unchanged, since the first version of this did overwrite it.
  • The solution is constructed directly rather than through build_linear_solution, which derives N from size(u) and has nothing to read from a container that is not an array.
  • Three entry points needed it, not one: init, the defaultalg choice inside solve(prob, ::Nothing) which reads size(b) before a cache exists, and solve!.
  • Tests cover the four algorithm paths, that the container type and its fields come back intact, that b is not overwritten, init with repeated solves against a new b and a new A, and that ordinary array right-hand sides are not diverted through this path.
  • Verified on Julia 1.10 and 1.12. Core and QA groups pass locally.

AI Disclosure: Used Opus 5

A right-hand side that implements the SciMLStructures interface but is
not an array could not be solved with at all. It failed in `__init` at
`real(eltype(b))` while computing tolerance defaults, before any
algorithm was reached, so it affected every algorithm rather than only
the Krylov wrappers.

`canonicalize` gives a flat buffer of the tunable values that the
existing machinery already handles, and the interface's own `repack`
rebuilds the container. The buffer is built once at `init`, and the
solve writes back with `replace!` so a repeated solve does not allocate
a new container.

The answer goes into its own container rather than into `b`, which must
survive the solve, and the solution is constructed directly because
`build_linear_solution` reads `size(u)`, which a container that is not
an array does not answer.

Three entry points needed it: `init`, the `defaultalg` choice in
`solve(prob, ::Nothing)` which reads `size(b)` before a cache exists,
and `solve!`.

Closes SciML#1208.
@ChrisRackauckas
ChrisRackauckas merged commit e0719f1 into SciML:main Aug 14, 2026
58 of 62 checks passed
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.

Support SciMLStructures right-hand sides at the init level

2 participants