Skip to content

refactor: Convert SemilinearODEFunction to use SciMLFunctionOptions#4828

Merged
AayushSabharwal merged 1 commit into
masterfrom
as/scimlfn-opts
Jul 24, 2026
Merged

refactor: Convert SemilinearODEFunction to use SciMLFunctionOptions#4828
AayushSabharwal merged 1 commit into
masterfrom
as/scimlfn-opts

Conversation

@AayushSabharwal

Copy link
Copy Markdown
Member

Applies the ModelingToolkitBase.SciMLFunctionOptions pattern to SemilinearODEFunction, the one *Function constructor that lives in the top-level ModelingToolkit package rather than ModelingToolkitBase. Its kwargs... wrapper now assembles a SciMLFunctionOptions and delegates to a new public SemilinearODEFunction{iip,specialize}(sys, opts::SciMLFunctionOptions; kwargs...) method that does the real work without splatting arbitrary keywords, matching every other constructor in the family.

Like the rest of the family, the struct-accepting method branches directly on the struct's own expression type parameter (if E) instead of a separate expression = Val{E} local, and builds its ObservedFunctionCache by forwarding the nested GeneratedFunctionOptions directly rather than re-listing its fields as separate keywords.

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

…olkit)

Applies the ModelingToolkitBase.SciMLFunctionOptions pattern to
SemilinearODEFunction, the one *Function constructor that lives in the
top-level ModelingToolkit package rather than ModelingToolkitBase. Its
kwargs... wrapper now assembles a SciMLFunctionOptions and delegates to
a
new public SemilinearODEFunction{iip,specialize}(sys,
opts::SciMLFunctionOptions;
kwargs...) method that does the real work without splatting arbitrary
keywords, matching every other constructor in the family.

Like the rest of the family, the struct-accepting method branches
directly
on the struct's own `expression` type parameter (`if E`) instead of a
separate `expression = Val{E}` local, and builds its
ObservedFunctionCache
by forwarding the nested GeneratedFunctionOptions directly rather than
re-listing its fields as separate keywords.

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia vlts)

Time benchmarks
master 4b1ff45... master / 4b1ff45...
ODEProblem 7.75 ± 1 ms 6.04 ± 0.42 ms 1.28 ± 0.19
init 0.11 ± 0.027 ms 0.0975 ± 0.031 ms 1.13 ± 0.46
large_parameter_init/ODEProblem 0.0332 ± 0.0047 s 27.1 ± 3.9 ms 1.23 ± 0.25
large_parameter_init/init 0.116 ± 0.029 ms 0.102 ± 0.041 ms 1.14 ± 0.54
mtkcompile 13.8 ± 2.6 ms 11.2 ± 0.73 ms 1.23 ± 0.25
sparse_analytical_jacobian/ODEProblem 0.0346 ± 0.0038 s 28.9 ± 1.7 ms 1.2 ± 0.15
sparse_analytical_jacobian/f_iip 1.89 ± 0.56 μs 1.89 ± 0.84 μs 1 ± 0.53
sparse_analytical_jacobian/f_oop 0.377 ± 0.03 ms 0.36 ± 0.0062 ms 1.05 ± 0.085
time_to_load 7.18 ± 0.29 s 6.2 ± 0.18 s 1.16 ± 0.058
Memory benchmarks
master 4b1ff45... master / 4b1ff45...
ODEProblem 0.0386 M allocs: 2.09 MB 0.0386 M allocs: 2.09 MB 1
init 0.428 k allocs: 0.0723 MB 0.428 k allocs: 0.0723 MB 1
large_parameter_init/ODEProblem 0.325 M allocs: 11.4 MB 0.325 M allocs: 11.4 MB 1
large_parameter_init/init 0.616 k allocs: 0.175 MB 0.616 k allocs: 0.175 MB 1
mtkcompile 0.0618 M allocs: 3.45 MB 0.0618 M allocs: 3.43 MB 1
sparse_analytical_jacobian/ODEProblem 0.193 M allocs: 7.93 MB 0.193 M allocs: 7.93 MB 0.999
sparse_analytical_jacobian/f_iip 0 allocs: 0 B 0 allocs: 0 B
sparse_analytical_jacobian/f_oop 0.634 k allocs: 19.6 kB 0.634 k allocs: 19.6 kB 1
time_to_load 0.153 k allocs: 14.6 kB 0.153 k allocs: 14.6 kB 1

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 4b1ff45... master / 4b1ff45...
ODEProblem 3.9 ± 0.42 ms 3.81 ± 0.25 ms 1.03 ± 0.13
init 0.052 ± 0.0067 ms 0.0535 ± 0.0067 ms 0.972 ± 0.17
large_parameter_init/ODEProblem 22.2 ± 4.8 ms 20.5 ± 5.6 ms 1.09 ± 0.38
large_parameter_init/init 0.058 ± 0.036 ms 0.0559 ± 0.037 ms 1.04 ± 0.95
mtkcompile 6.53 ± 0.68 ms 6.17 ± 0.62 ms 1.06 ± 0.15
sparse_analytical_jacobian/ODEProblem 19.6 ± 3.4 ms 17.9 ± 3 ms 1.1 ± 0.26
sparse_analytical_jacobian/f_iip 0.06 ± 0.01 μs 0.07 ± 0.001 μs 0.857 ± 0.14
sparse_analytical_jacobian/f_oop 0.0913 ± 0.012 ms 0.0914 ± 0.012 ms 0.999 ± 0.18
time_to_load 4.95 ± 0.19 s 4.66 ± 0.033 s 1.06 ± 0.041
Memory benchmarks
master 4b1ff45... master / 4b1ff45...
ODEProblem 0.0375 M allocs: 1.7 MB 0.0375 M allocs: 1.7 MB 1
init 0.426 k allocs: 0.0545 MB 0.426 k allocs: 0.0545 MB 1
large_parameter_init/ODEProblem 0.352 M allocs: 12.8 MB 0.352 M allocs: 12.8 MB 1
large_parameter_init/init 0.809 k allocs: 0.154 MB 0.809 k allocs: 0.154 MB 1
mtkcompile 0.0598 M allocs: 2.75 MB 0.0598 M allocs: 2.75 MB 1
sparse_analytical_jacobian/ODEProblem 0.186 M allocs: 6.89 MB 0.186 M allocs: 6.89 MB 1
sparse_analytical_jacobian/f_iip 0 allocs: 0 B 0 allocs: 0 B
sparse_analytical_jacobian/f_oop 0.848 k allocs: 27 kB 0.848 k allocs: 27 kB 1
time_to_load 0.146 k allocs: 11.4 kB 0.146 k allocs: 11.4 kB 1

@AayushSabharwal
AayushSabharwal merged commit 018d3d4 into master Jul 24, 2026
58 of 68 checks passed
@AayushSabharwal
AayushSabharwal deleted the as/scimlfn-opts branch July 24, 2026 09:36
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