Skip to content

Allow vector-backed CallbackSet storage - #1541

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:despecialize-callback-sets
Aug 20, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:despecialize-callback-sets

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed and why

Allow CallbackSet to store its ordered continuous and discrete callbacks in either tuples or abstract vectors. Public callback-combining constructors continue to produce tuples; solver initialization paths can now use vectors to erase callback types and reuse compiled solver code. Vector-specific save traversal avoids splatting dynamically stored callbacks.

This is the SciMLBase prerequisite for despecializing callback storage in OrdinaryDiffEq. It does not change the default tuple-backed callback path.

Verification

Failing before, using this PR's unchanged test file with clean SciMLBase fd427fd3e:

timeout 3600 julia --startup-file=no --compiled-modules=no --project=. -e 'include("../SciMLBase.jl/test/callback_constructors.jl")'
CallbackSet collection storage | Error 1 / Total 1
MethodError: no method matching CallbackSet(::Vector{Any}, ::Vector{Any})

Passing after:

timeout 3600 julia --startup-file=no --compiled-modules=no --project=. -e 'include("test/callback_constructors.jl")'
CallbackSet collection storage                         | 3 Pass / 3 Total
VectorContinuousCallback 3-arg kwarg constructor      | 7 Pass / 7 Total
VectorContinuousCallback rejects affect_neg!          | 2 Pass / 2 Total

Full relevant and QA groups on the rebased branch:

GROUP=Core julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
Callback constructors | 12 Pass / 12 Total
Remake                | 4430 Pass / 4430 Total
Testing SciMLBase tests passed

GROUP=QA julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()'
QA | 51 Pass / 51 Total
Testing SciMLBase tests passed

Documentation and static checks:

julia --startup-file=no --project=docs docs/make.jl
exit 0 after doctests, cross-references, document checks, rendering, and link checking

julia --startup-file=no -m Runic --check src/callbacks.jl test/callback_constructors.jl
git diff upstream/master...HEAD | typos -
git diff --check upstream/master...HEAD
all exit 0 with no output

Not verified

GPU and downstream groups were not run. The OrdinaryDiffEq integration is intentionally kept in a separate follow-up change.

Reviewer note

The direct two-collection struct constructor now accepts vectors, while the documented variadic constructors remain tuple-backed. The intended vector use is solver-internal type erasure.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 20, 2026 15:25
@ChrisRackauckas
ChrisRackauckas merged commit 71c303a into SciML:master Aug 20, 2026
45 of 54 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