Skip to content

JuliaC/trim compatibility for Core and Rosenbrock#3326

Closed
asinghvi17 wants to merge 5 commits intoSciML:masterfrom
asinghvi17:as/trimmability
Closed

JuliaC/trim compatibility for Core and Rosenbrock#3326
asinghvi17 wants to merge 5 commits intoSciML:masterfrom
asinghvi17:as/trimmability

Conversation

@asinghvi17
Copy link
Copy Markdown
Contributor

@asinghvi17 asinghvi17 commented Apr 2, 2026

Summary

  • Specialize on tType in initdt to force compiler specialization and type propagation
  • Specialize on deriv type in generic ode_interpolant and interp_at_saveat for trim compatibility
  • Specialize on type input to Rosenbrock tableaus

These changes fix dynamic dispatch paths that cause Julia's --trim=safe (JuliaC AOT compilation) to fail, by adding type parameters that allow the compiler to statically resolve method calls.

🤖 Generated with Claude Code

@asinghvi17 asinghvi17 changed the title Fix type specialization for trim (JuliaC) compatibility JuliaC/trim compatibility for solvers + trim CI Apr 2, 2026
Comment thread lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl
Comment thread lib/OrdinaryDiffEqCore/src/perform_step/composite_perform_step.jl Outdated
@ChrisRackauckas
Copy link
Copy Markdown
Member

This isn't one PR. Please split into the component parts. There's the inference improvements to Rosenbrock, which are missing JET tests. There's adding trim tests. There's adding default solvers. This is a mess.

@asinghvi17
Copy link
Copy Markdown
Contributor Author

I'll split the trim CI out to a separate PR.

@asinghvi17
Copy link
Copy Markdown
Contributor Author

Runic is complaining about files that I haven't touched, so that seems like something for another formatting PR to fix.

@asinghvi17 asinghvi17 changed the title JuliaC/trim compatibility for solvers + trim CI JuliaC/trim compatibility for Core and Rosenbrock Apr 2, 2026

@muladd function _ode_initdt_iip(
u0, t, _tType, tdir, dtmax, abstol, reltol, internalnorm,
u0, t, ::Type{_tType}, tdir, dtmax, abstol, reltol, internalnorm,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this funtion takes t we should see if we can just remove _tType entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a bigger change though, right? I'm assuming a lot of solvers try to look at this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. The only caller of initdit is __init so the initialization happens before any solver specific code runs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asinghvi17 can you resolve this?

@asinghvi17 asinghvi17 requested a review from oscardssmith April 13, 2026 11:40
@oscardssmith
Copy link
Copy Markdown
Member

Other than the initdt issue this seems mostly good to go. It also needs a rebase.

@ChrisRackauckas
Copy link
Copy Markdown
Member

initdt was already handled. Other stuff needs inference tests.

1 similar comment
@ChrisRackauckas
Copy link
Copy Markdown
Member

initdt was already handled. Other stuff needs inference tests.

ChrisRackauckas added a commit that referenced this pull request Apr 23, 2026
…ibility

Backport of #3326 minus the initdt changes (the v6-backport branch already
fixes that via eltype(t) inside the function body, so the ::Type{_tType}
dispatch from the original PR no longer applies).

- Specialize ode_interpolant, default_ode_interpolant, composite_ode_interpolant
  and interp_at_saveat on ::Type{deriv} to force compiler specialization
- Specialize Rosenbrock tableau constructors on ::Type{T}/::Type{T2} so Julia
  propagates the concrete element type through the tableau builders

These changes close dynamic-dispatch paths that cause --trim=safe (JuliaC AOT)
to fail, by adding type parameters that let the compiler statically resolve
method calls.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
ChrisRackauckas added a commit that referenced this pull request Apr 23, 2026
…ibility

Applies the type-inference portions of #3326 (which targets master/v7):

- Specialize ode_interpolant, default_ode_interpolant, composite_ode_interpolant,
  and interp_at_saveat on ::Type{deriv} to force compiler specialization
- Specialize Rosenbrock tableau constructors on ::Type{T}/::Type{T2} (in both
  OrdinaryDiffEqRosenbrock and OrdinaryDiffEqRosenbrockTableaus) so Julia
  propagates the concrete element type through the tableau builders

The initdt changes from #3326 are already obsoleted on master/v6-backport:
both branches now compute _tType = eltype(t) inside the function body instead
of passing _tType as a positional argument.

These changes close dynamic-dispatch paths that cause --trim=safe (JuliaC AOT)
to fail, by adding type parameters that let the compiler statically resolve
method calls.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
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.

3 participants