Skip to content

feat(integrators): parameterize SciML{P<:Union{CPU,GPU}} for GPU support#178

Merged
ocots merged 2 commits into
mainfrom
feat/gpu-sciml-parameter
Jul 18, 2026
Merged

feat(integrators): parameterize SciML{P<:Union{CPU,GPU}} for GPU support#178
ocots merged 2 commits into
mainfrom
feat/gpu-sciml-parameter

Conversation

@ocots

@ocots ocots commented Jul 18, 2026

Copy link
Copy Markdown
Member

What & why

Parameterize the SciML ODE integrator on the execution device, SciML{P<:Union{CPU,GPU}}, exactly along the existing Modelers.Exa{P} / Solvers.MadNLP{P} pattern. This is phase 1 of the CTFlows GPU roadmap (roadmap-v4 §5, decision D1): it makes (:sciml, :gpu) reachable in registries/descriptions so downstream packages (CTFlows) can resolve a GPU integrator through the existing strategy machinery.

SciML() ≡ SciML{CPU}zero breakage for every current caller.

Changes

  • src/Integrators/sciml.jl — struct gains a leading device parameter SciML{P<:Union{CPU,GPU},O,OP,OT}; parameter extracts P; default_parameter = CPU; parameterized SciML{P}(...) constructor + bare SciML(...) delegating through default_parameter; build_sciml_integrator stub takes P; bare metadata(SciML) back-compat delegation (moved to core, mirroring Exa); __consistent_initial_condition stub.
  • ext/CTSolversSciMLIntegrator.jlmetadata(SciML{P}) (option set currently identical for both devices — P marks the seam where GPU-specific defaults/validators land later); build_sciml_integrator(SciMLTag, P; …) builds SciML{P,…}.
  • ext/CTSolversCUDA.jl — device-aware __consistent_initial_condition methods: a CuArray u0 is inconsistent with SciML{CPU}, a host Array u0 inconsistent with SciML{GPU}. Defined here (reusing the existing CUDA extension) so the consuming package can call it without adding its own CUDA extension; its call site lands in CTFlows, where a concrete u0 exists (problem construction / solve).
  • test/suite/integrators/test_sciml_parameter.jl (new) — Family-A contract tests: parameter/default_parameter/id, per-parameter metadata + bare delegation, per-device construction, registry [CPU, GPU] + extract_global_parameter_from_method, and the __consistent_initial_condition validator.
  • test/suite/integrators/test_integrator_stubs.jl — updated the stub calls to the new build_sciml_integrator(tag, P) signature.

Tests

Run locally via ct-dev-mcp / Pkg.test:

  • suite/integrators179 passed
  • suite/strategies391 passed
  • full suite — 2634 passed (including Aqua: no method ambiguities introduced)

Notes

  • build_integrator(; kwargs...) = SciML(; kwargs...) is unchanged; its use is retired later in CTFlows phase 2.
  • Out of scope: GPU-specific alg/option defaults; surfacing __consistent_initial_condition at a real u0 call site (CTFlows); AMDGPU/Metal.

🤖 Generated with Claude Code

Make the SciML ODE integrator a device-parameterized strategy along the
Exa/MadNLP pattern (GPU roadmap phase 1 / D1). SciML() ≡ SciML{CPU}, so every
existing call site is unaffected. Adds per-parameter metadata seam, the
__consistent_initial_condition device validator (CUDA extension), and Family-A
parameter tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… registry back-compat

A consumer that registers SciML without a device parameter (e.g. CTFlows' flow
registry) queries parameter on the bare SciML type. The parameterization dropped
the bare method, and AbstractIntegrator has no family-level fallback (unlike
CTBase's AbstractADBackend), so bare parameter(SciML) threw NotImplemented,
breaking every current CTFlows flow-construction path. Restore the bare method
(nothing) alongside the parameterized one (P); add a regression guard test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ocots
ocots merged commit c2fd586 into main Jul 18, 2026
5 checks passed
@ocots
ocots deleted the feat/gpu-sciml-parameter branch July 18, 2026 22:51
ocots added a commit that referenced this pull request Jul 19, 2026
Bump version to 0.4.30-beta and update CHANGELOG.md / BREAKING.md
for the SciML{P<:Union{CPU,GPU}} integrator parameterization (PR #178).

No breaking changes: SciML() ≡ SciML{CPU}.
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.

1 participant