Skip to content

Resolve symbolic idxs in the ODE and DDE integrator interpolants - #4469

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

ChrisRackauckas merged 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:integrator-symbolic-interpolation

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

What changed and why

integrator(t; idxs = sym) only accepted integer component indices, so it threw
ArgumentError: invalid index for any symbolic index and could never resolve an observed
equation. sol(t; idxs = sym) has resolved both for a long time; this closes that gap in
the integrator interface, which came up in
SciML/ModelingToolkit.jl#5006.

(integrator::ODEIntegrator)(t; idxs) and (integrator::DDEIntegrator)(t; idxs) now route
symbolic idxs to SciMLBase.symbolic_interpolation, which evaluates the current step's
interpolant and applies the symbolic getter to it. Integer, nothing, and in-place calls
are untouched and still go straight to current_interpolant.

StochasticDiffEq needs no change of its own — SDEIntegrator is an alias for
ODEIntegrator{<:SDEAlgTypes}, so it is covered by the ODEIntegrator method here.

HistoryODEIntegrator is deliberately not routed. It implements none of the
SymbolicIndexingInterface methods a DEIntegrator needs — it has no p field, so
parameter_values throws — which means symbolic indexing against it is unsupported both
before and after this PR. Making that work is a feature addition, not part of closing this
gap, so there is a comment in the test file saying so rather than a silent omission.

Depends on SciMLBase.symbolic_interpolation and SciMLBase.has_symbolic_idxs, both added
in SciML/SciMLBase.jl#1581 and
SciML/SciMLBase.jl#1585. The predicate lives in SciMLBase rather
than here because Sundials and ODEInterfaceDiffEq need the same decision and should not
reach into an OrdinaryDiffEqCore internal to get it. symbolic_interpolation shipped in
SciMLBase 3.52.0, but has_symbolic_idxs did not make that merge, so the compat floor in
OrdinaryDiffEqCore and DelayDiffEq is 3.53 and CI fails with
UndefVarError: has_symbolic_idxs not defined until #1585 is registered.

Verification

New test files test/Integrators_I/symbolic_interpolation_tests.jl and
lib/DelayDiffEq/test/interface/symbolic_interpolation.jl. Both use a SymbolCache, whose
Expr indexes are observed quantities, so they cover the observed path without adding
ModelingToolkit to either test target.

Before (this branch's test file against unmodified lib/):

Test Summary:                                 | Pass  Fail  Error  Total  Time
Symbolic idxs in the current-step interpolant |    3     1      8     12  8.6s
ERROR: LoadError: Some tests did not pass: 3 passed, 1 failed, 8 errored, 0 broken.

After, and the same file for DelayDiffEq, both run against SciMLBase #1581:

DelayDiffEq    |    9      9  12.9s
OrdinaryDiffEq |   12     12   4.6s

End to end against the ModelingToolkit system from the issue, with w ~ x + y + z
observed — before, on OrdinaryDiffEq master:

FAIL  integrator(t; idxs = x)            ArgumentError: invalid index: x(t) of type SymbolicUtils...
FAIL  integrator(t; idxs = w)  # observed ArgumentError: invalid index: w(t) of type SymbolicUtils...
FAIL  integrator(ts; idxs = [x, w])      ArgumentError: invalid index: x(t) of type SymbolicUtils...

after:

PASS  integrator(t; idxs = x)
PASS  integrator(t; idxs = w)  # observed
PASS  integrator(ts; idxs = [x, w])

Also run locally: GROUP=Integrators_I (output below), Runic and typos on every file
touched.

Reinit Tests                            |   31     31  36.3s
Events Tests                            |   57     57   4m32.5s
Alg Events Tests                        |  177    177  14m18.0s
Discrete Callback Dual Tests            |    4      4   9.1s
Callback Allocation Tests               |    1      1   9.0s
Iterator Tests                          |   15     15  12.9s
Integrator Interface Tests              |   36     36  17.7s
Integrator Symbolic Interpolation Tests |   12     12   8.0s
Error Check Tests                       |   10  1 broken  11  26.8s
Event Detection Tests                   |   23     23   4m05.5s
Event Repetition Detection Tests        |    6      6   7.3s
Multi-VCC Mask Tests                    |   28     28  28.3s
Step Limiter Tests                      |  347    347  25m19.4s
Discontinuity Detection Tests           |   28     28   4m10.4s

     Testing OrdinaryDiffEq tests passed

(The single broken in Error Check Tests is a pre-existing @test_broken on master, not
introduced here. SciMLBase was Pkg.developed to the branch above for this run, since
the compat bound below requires a version that is not yet registered.)

Things a reviewer should push back on

  • A symbolic index evaluates the whole-state interpolant and then projects, while an
    integer index evaluates the interpolant for that component alone. The two agree to
    rounding, not bitwise, so the tests compare those two 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 who was relying on the error.
  • The in-place form integrator(val, t; idxs) is deliberately left alone: writing a
    symbolic projection into a caller-supplied buffer has no obvious shape contract. It
    still errors for symbolic idxs.

Not verified

Other test groups, the GPU group, and downstream packages. This touches only the
idxs-dispatch of the integrator call, so the blast radius is the interpolation path that
GROUP=Integrators_I and GROUP=InterfaceI cover; CI runs the rest.


This PR should be ignored until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

CI is red across every job here for a single reason, and it is the expected one for a stacked PR rather than a defect in the change. From the Documentation job log:

ERROR: Unsatisfiable requirements detected for package SciMLBase [0bca4576]

This PR calls SciMLBase.symbolic_interpolation and raises its SciMLBase compat floor to 3.52, which is not registered yet. Every job fails at resolution before running a line of test code.

The unblocking order is SciML/SciMLBase.jl#1581 merged and registered as 3.52.0, then this. I will re-run CI here once that tag exists.

Locally, with SciMLBase Pkg.developed to that branch, GROUP=Integrators_I passes in full, including the new Integrator Symbolic Interpolation Tests at 12/12.

🤖 Generated with Claude Code

https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam

ChrisRackauckas and others added 2 commits September 6, 2026 21:30
`integrator(t; idxs = sym)` passed `idxs` straight to the dense-output
interpolant, which only accepts integer component indices, 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`, which evaluates
the current step's interpolant and applies the symbolic getter to it. 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
`DDEIntegrator` has the same gap `ODEIntegrator` did: `integrator(t; idxs = sym)`
went straight to the dense-output interpolant, which only accepts integer
component indices, so symbolic indexes threw and observed equations were
unreachable.

The predicate moves to the public `SciMLBase.has_symbolic_idxs` rather than
staying an OrdinaryDiffEqCore internal, since DelayDiffEq, Sundials and
ODEInterfaceDiffEq all need the same decision.

`HistoryODEIntegrator` is deliberately left alone: it implements none of the
`SymbolicIndexingInterface` methods a `DEIntegrator` needs, so symbolic indexing
against it is unsupported before and after this change.

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-Claude
ChrisRackauckas-Claude force-pushed the integrator-symbolic-interpolation branch from 3e2675d to b50002a Compare September 7, 2026 01:31
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title Resolve symbolic idxs in the integrator interpolant Resolve symbolic idxs in the ODE and DDE integrator interpolants Sep 7, 2026
ChrisRackauckas and others added 2 commits September 6, 2026 22:56
`has_symbolic_idxs` did not make it into the 3.52.0 release, so the floor moves
to the version that carries it.

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 09:02
@ChrisRackauckas
ChrisRackauckas merged commit 64081c6 into SciML:master Sep 7, 2026
265 of 267 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships the callback despecialization (#4376, using the existing Base.isempty(::CallbackSet)) and symbolic-index resolution in the ODE/DDE integrator interpolants (#4469).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude <[email protected]>
Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas added a commit that referenced this pull request Sep 17, 2026
Ships the callback despecialization (#4376, using the existing Base.isempty(::CallbackSet)) and symbolic-index resolution in the ODE/DDE integrator interpolants (#4469).



Agent-Harness: Claude Code 2.1.273
Agent-Model: claude-opus-5[1m]
Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)

Co-authored-by: Claude <[email protected]>
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