Skip to content

Resolve symbolic idxs in the integrator interpolants - #565

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:integrator-symbolic-idxs
Sep 7, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:integrator-symbolic-idxs

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

What changed and why

integrator(t; idxs = sym) passed idxs straight through to out[idxs], so any symbolic
index threw ArgumentError: invalid index and an observed equation could never be
retrieved from an integrator. sol(t; idxs = sym) has resolved both for a long time; this
closes the same gap that SciML/OrdinaryDiffEq.jl#4469 closes for
ODEIntegrator and DDEIntegrator. It came up in
SciML/ModelingToolkit.jl#5006.

The four out-of-place call operators — CVODEIntegrator, ARKODEIntegrator (ARKStep and
ERKStep) and IDAIntegrator — now check SciMLBase.has_symbolic_idxs and route to
SciMLBase.symbolic_interpolation, which evaluates the interpolant and applies the symbolic
getter to it. Integer idxs, nothing, and the in-place integrator(out, t; idxs) methods
are untouched.

Depends on SciMLBase.symbolic_interpolation and SciMLBase.has_symbolic_idxs, added in
SciML/SciMLBase.jl#1585. symbolic_interpolation shipped in
SciMLBase 3.52.0, but has_symbolic_idxs did not make that merge, so the compat floor here
is 3.53 and CI fails with UndefVarError: has_symbolic_idxs not defined until #1585 is
registered.

Verification

New test file test/common_interface/symbolic_interpolation.jl, run across CVODE_Adams,
CVODE_BDF, ARKODE and IDA. It uses a SymbolCache, whose Expr indexes are observed
quantities, so it covers the observed path without adding ModelingToolkit to the test target.

Before, with only the test applied and src/ reverted:

ERROR: LoadError: Some tests did not pass: 3 passed, 0 failed, 4 errored, 0 broken.
Symbolic idxs in the current-step interpolant: CVODE_Adams: Error During Test
  ArgumentError: invalid index: :x of type Symbol
Symbolic idxs in the current-step interpolant: CVODE_Adams: Error During Test
  ArgumentError: invalid index: :y of type Symbol
Symbolic idxs in the current-step interpolant: CVODE_Adams: Error During Test
  ArgumentError: unable to check bounds for indices of type Symbol

After:

Symbolic idxs in the current-step interpolant: CVODE_Adams |    7      7  3.5s
Symbolic idxs in the current-step interpolant: CVODE_BDF   |    7      7  1.4s
Symbolic idxs in the current-step interpolant: ARKODE      |    7      7  2.0s
Symbolic idxs on an IDAIntegrator                          |    3      3  1.7s

Both runs used SciMLBase Pkg.developed to the branch in #1581, since the compat bound
above requires a version that is not yet registered (#1585). Runic --check and typos are clean
on every file touched.

Things a reviewer should push back on

  • A symbolic index evaluates the whole-state interpolant and then projects, while an integer
    index reads that component out of the raw output. The two agree to rounding rather than
    bitwise, so the tests compare those paths with ≈; there is a comment in the test saying
    so.
  • has_symbolic_idxs treats Symbol and Expr as symbolic, since that is what
    SymbolicIndexingInterface.symbolic_type reports. integrator(t; idxs = :x) previously
    threw and now resolves through the symbol cache. That is the intended widening, but it is
    a behavior change for anyone relying on the error.
  • The in-place integrator(out, t; idxs) methods are deliberately left alone: writing a
    symbolic projection into a caller-supplied buffer has no obvious shape contract.

Not verified

The rest of the Sundials test suite, and Julia LTS. This touches only the idxs dispatch of
the four out-of-place call operators; CI covers the rest once #1585 is registered.


This PR should be ignored until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

`integrator(t; idxs = sym)` passed `idxs` straight to `out[idxs]`, so any
symbolic index threw `ArgumentError: invalid index` and an observed equation
could never be retrieved. `sol(t; idxs = sym)` has resolved both for a long time.

Symbolic `idxs` now route to `SciMLBase.symbolic_interpolation` in the
out-of-place `CVODEIntegrator`, `ARKODEIntegrator` and `IDAIntegrator` call
operators. Integer, `nothing`, and in-place calls are unchanged.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 7, 2026 07:43
@ChrisRackauckas
ChrisRackauckas merged commit c810885 into SciML:master Sep 7, 2026
15 of 24 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.

2 participants