Repository navigation
Add AutoDePSpecialize specialization level - #1458
Merged
ChrisRackauckas merged 1 commit intoJul 22, 2026
Merged
Conversation
A new AbstractSpecialization marker that extends AutoSpecialize by also de-specializing the parameter object: solver paths with an opaque-parameter strategy (e.g. RespecializeParams.OpaqueParams in DiffEqBase's promote_f) pack isbits p into a fixed-type container and wrap callables with the container type in the p slot, making the concretized problem type — and the solver compilation — independent of the user's parameter struct type. One precompiled solve is then shared across all isbits parameter types, while the user's f still receives p at its original concrete type via a type-stable, allocation-free unpack. SciMLBase only defines the marker (public, documented, allowed in the SpecializationLevel preference); the wrapping itself is solver-owned so any function family can implement it — the immediate consumers are DiffEqBase (SciML/OrdinaryDiffEq.jl#3692) and, prospectively, NonlinearSolve.jl. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Jul 22, 2026
Per @ChrisRackauckas's direction the AutoDePSpecialize marker belongs in SciMLBase so other solver stacks (NonlinearSolve.jl) can implement the same level for their own function families. The type is now defined and documented in SciMLBase (SciML/SciMLBase.jl#1458); this repo imports it from SciMLBase (the owner) rather than defining it in DiffEqBase. - DiffEqBase: import SciMLBase.AutoDePSpecialize (was a local struct in opaque_void.jl); still re-exported. opaque_void.jl keeps only the opaque-p machinery (OpaqueVoid, wrap_void_opaque, ...). - OrdinaryDiffEqCore / OrdinaryDiffEq: import the marker from SciMLBase (owner) instead of forwarding through DiffEqBase, and re-export. - docs/src/api/diffeqbase.md: @docs entry now targets SciMLBase.AutoDePSpecialize, framed as the level DiffEqBase implements. - compat: SciMLBase = "3.37" floor in DiffEqBase, OrdinaryDiffEqCore, and OrdinaryDiffEq (the release that adds the marker). Verified: GROUP=Core DiffEqBase tests pass against dev SciMLBase 3.37 (13/13 opaque tests + rest of Core); end-to-end AutoDePSpecialize across Tsit5/Vern7/Vern9/Rosenbrock23/Rodas5P/FBDF/Default with the SciMLBase-owned marker, interpolation, unpack roundtrip, and function-barrier zero-alloc all green. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
3 of 4 tasks
ChrisRackauckas
marked this pull request as ready for review
July 22, 2026 20:38
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/OrdinaryDiffEq.jl
that referenced
this pull request
Jul 23, 2026
…paque The AutoDePSpecialize glue that is identical across solver stacks now lives in the shared packages, so NonlinearSolve.jl can reuse it verbatim: - should_opaque_p → SciMLBase (SciML/SciMLBase.jl#1458), next to the marker and NullParameters. - wrap_void_opaque installer + container/signature helpers → RespecializeParams (SciML/RespecializeParams.jl#23, v0.1.4). opaque_void.jl drops from ~73 to ~24 lines — only the DiffEqBase-owned wrapfun_iip_opaque stub (FD-ext methods) remains. promote_f calls SciMLBase.should_opaque_p, RespecializeParams.wrap_void_opaque(ff, P, (natural_sig,)), and pack_auto. What stays here is genuinely ODE-specific: the ODEFunction tgrad/jac/sparsity threading in promote_f and the FD-ext 4-variant dual-signature builder. Compat floor RespecializeParams = "0.1.4". Verified against dev SciMLBase 3.37 + RespecializeParams 0.1.4: GROUP=Core passes (Opaque-p Hook 13/13, ForwardDiff Dual Detection); end-to-end across all seven solver configs green. Co-Authored-By: Claude Fable 5 <[email protected]> Co-Authored-By: Chris Rackauckas <[email protected]>
Member
Author
|
Added |
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.
Note
Draft PR — please ignore until reviewed by @ChrisRackauckas.
Adds
AutoDePSpecialize <: AbstractSpecialization, a specialization level that extendsAutoSpecializeby also de-specializing the parameter object: solver paths with an opaque-parameter strategy pack an isbits, non-NullParameterspinto a fixed-type opaque container (e.g.RespecializeParams.OpaqueParams) and install wrappers whose signatures carry the container type in thepslot. The concretized problem type — and the solver compilation — becomes independent of the user's parameter struct type, so one precompiled solve covers all isbits parameter types, while the user'sfstill receivespfully typed via an allocation-free unpack.SciMLBase only defines the marker: type + docstring,
@public,@docsentry in the Specialization Levels section ofinterfaces/Problems.md, and"AutoDePSpecialize"added to theSpecializationLevelpreference allowlist. No new dependencies — the wrapping is solver-owned, so any function family (ODE, nonlinear, …) can implement its own strategy.Placing the level here (rather than in DiffEqBase, where an earlier revision defined it) is per @ChrisRackauckas's direction so that NonlinearSolve.jl can implement the same level for its residual wrappers. The ODE-stack implementation and benchmarks live in SciML/OrdinaryDiffEq.jl#3692 (measured there: first-solve TTFX for a never-seen parameter struct 12.1 s → 0.43 s for
DefaultODEAlgorithm, runtime within ~2% ofAutoSpecialize).Construction through the generic
AbstractSciMLFunctionconstructor branches already works for arbitrary specialization types, so no constructor changes are needed; the marker alone performs no wrapping in SciMLBase (fields stay concretely typed,puntouched), which the new tests intest/problem_building_test.jlassert, along withspecialization()round-tripping andunwrapped_fpreserving the marker.Version: 3.36.1 → 3.37.0 (new public API).
Tests run locally:
test/problem_building_test.jlwith dev'd SciMLBase — all pass including the 8 new assertions (AutoDePSpecialize specialization marker | 8 pass). Runic applied to changed .jl files.🤖 Generated with Claude Code
https://claude.ai/code/session_01UuAbA8hSnrirMrJjFqxwn5