Skip to content

Commit df53363

Browse files
Use shared solver paths for Reactant compilation
Route compiled solves through the ordinary step loop, initial-step estimator, FSAL update, and I/PI controllers. Promote loop-carried state for tracing and retain narrow adapters for static output and endpoint handling. Cover custom controllers, zero dynamics, in-place fixed steps, and rejected first steps. Merge current master to resolve the test-group configuration and retain upstream fixes. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI 0.153.4 Agent-Model: gpt-6-astra Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/05/rollout-2026-09-05T07-40-10-01a0715e-73c9-7e21-a18b-c5b0504a4bf3.jsonl
2 parents 9f78a3c + c241543 commit df53363

98 files changed

Lines changed: 3368 additions & 440 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/src/explicit/SSPRK.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The SSP coefficient determines the maximum allowable timestep for stability pres
6464

6565
- **`SSPRK432`**: Third-order with error control
6666
- **`SSPRK932`**: High-stage adaptive method
67-
- **`SSPRKMSVS43`**: Multistep adaptive variant
67+
- **`SSPRKMSVS43`**: Four-step multistep variant
6868

6969
```@eval
7070
first_steps = evalfile("./common_first_steps.jl")

‎docs/src/usage.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ sol = Reactant.@jit compiled_solve(u0, p)
8787
Array(sol.u[end])
8888
```
8989

90-
Reactant requires statically shaped outputs. A compiled solve therefore returns an endpoint-only `ODESolution`: `sol.u` and `sol.t` contain the final state and time, while `sol.prob`, `sol.stats`, and `sol.interp` are `nothing`. Adaptive solves currently require a `PIController`; the tested algorithms are the `Tsit5` and Verner explicit Runge–Kutta families. Implicit algorithms, saving intermediate or partial states (`saveat` or `save_idxs`), callbacks, user `tstops`, discontinuity handling, `force_dtmin`, progress reporting, custom domain or instability checks, and step limiters are not currently supported inside Reactant compilation and produce an `ArgumentError` instead of silently changing the solve.
90+
Reactant requires statically shaped outputs. A compiled solve therefore returns an endpoint-only `ODESolution`: `sol.u` and `sol.t` contain the final state and time, while `sol.prob`, `sol.stats`, and `sol.interp` are `nothing`. Adaptive solves currently support `IController` and `PIController`; the tested algorithms are the `Tsit5` and Verner explicit Runge–Kutta families. Implicit algorithms, saving intermediate or partial states (`saveat` or `save_idxs`), callbacks, user `tstops`, discontinuity handling, `force_dtmin`, progress reporting, custom domain or instability checks, and step limiters are not currently supported inside Reactant compilation and produce an `ArgumentError` instead of silently changing the solve.
9191

9292
## Available Solvers
9393

‎lib/DiffEqBase/src/solve.jl‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ function promote_f(
10811081
end
10821082

10831083
wrap_path = f isa ODEFunction && isinplace(f) && !(f.f isa AbstractSciMLOperator) &&
1084-
f.mass_matrix isa UniformScaling &&
10851084
f.jac === nothing &&
10861085
!(u0 isa SubArray) &&
10871086
(
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using DiffEqBase, SciMLBase, LinearAlgebra, Test
2+
using DiffEqBase: FunctionWrappersWrappers
3+
4+
# The resolved default algorithm uses finite differences, so concretization takes the
5+
# non-ForwardDiff `promote_f` path. A mass matrix must not disable wrapping there,
6+
# otherwise every mass-matrix model solved with the default algorithm keeps its own
7+
# RHS type in the integrator and recompiles the whole solve.
8+
struct FiniteDiffAlg <: SciMLBase.AbstractODEAlgorithm end
9+
SciMLBase.forwarddiffs_model(::FiniteDiffAlg) = false
10+
SciMLBase.isadaptive(::FiniteDiffAlg) = true
11+
12+
g1(du, u, p, t) = (du[1] = u[1]; du[2] = -u[2] + u[1]; nothing)
13+
g2(du, u, p, t) = (du[1] = u[1]; du[2] = -2u[2] + u[1]; nothing)
14+
M = Diagonal([0.0, 1.0])
15+
u0 = [0.0, 1.0]
16+
17+
@testset "mass-matrix problems are wrapped on the finite-difference path" begin
18+
for spec in (SciMLBase.AutoDespecialize, SciMLBase.AutoSpecialize)
19+
probs = map((g1, g2)) do g
20+
ODEProblem{true, spec}(
21+
ODEFunction{true, spec}(g; mass_matrix = M), u0, (0.0, 1.0), (; k = 1.0)
22+
)
23+
end
24+
concrete = map(p -> DiffEqBase.get_concrete_problem(p, true; alg = FiniteDiffAlg()), probs)
25+
for c in concrete
26+
@test c.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper
27+
@test c.f.mass_matrix === M
28+
du = similar(u0)
29+
c.f(du, u0, c.p, 0.0)
30+
@test du[1] == u0[1]
31+
end
32+
@test typeof(concrete[1]) === typeof(concrete[2])
33+
end
34+
end
35+
36+
@testset "a user Jacobian still opts out of the finite-difference wrapping path" begin
37+
jac!(J, u, p, t) = (J .= [1.0 0.0; 1.0 -1.0]; nothing)
38+
prob = ODEProblem{true, SciMLBase.AutoSpecialize}(
39+
ODEFunction{true, SciMLBase.AutoSpecialize}(g1; mass_matrix = M, jac = jac!),
40+
u0, (0.0, 1.0)
41+
)
42+
c = DiffEqBase.get_concrete_problem(prob, true; alg = FiniteDiffAlg())
43+
@test !(c.f.f isa FunctionWrappersWrappers.FunctionWrappersWrapper)
44+
end

‎lib/DiffEqBase/test/runtests.jl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ end
4949
@time @safetestset "Problem Kwargs Merging" include("problem_kwargs_merging.jl")
5050
@time @safetestset "Opaque-p Hook" include("opaque_p_test.jl")
5151
@time @safetestset "Despecialized-p Hook" include("despecialized_p_test.jl")
52+
@time @safetestset "Despecialized mass-matrix problems" include("despecialize_mass_matrix.jl")
5253
@time @safetestset "Verbose Inference" include("verbose_inference.jl")
5354
end
5455

‎lib/DiffEqDevTools/Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqDevTools"
22
uuid = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "3.6.1"
4+
version = "3.6.2"
55

66
[deps]
77
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"

‎lib/DiffEqDevTools/src/benchmark.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ function WorkPrecisionSet(
920920
# Now time it
921921
_abstols = [get(setups[k], :abstols, abstols) for k in 1:N]
922922
_reltols = [get(setups[k], :reltols, reltols) for k in 1:N]
923-
_dts = [get(setups[k], :dts, zeros(length(_abstols))) for k in 1:N]
923+
_dts = [get(setups[k], :dts, zeros(length(_abstols[k]))) for k in 1:N]
924924
for k in 1:N
925925
# precompile
926926
GC.gc()
@@ -1003,7 +1003,7 @@ function WorkPrecisionSet(
10031003
# First calculate all of the errors
10041004
_abstols = [get(setups[k], :abstols, abstols) for k in 1:N]
10051005
_reltols = [get(setups[k], :reltols, reltols) for k in 1:N]
1006-
_dts = [get(setups[k], :dts, zeros(length(_abstols))) for k in 1:N]
1006+
_dts = [get(setups[k], :dts, zeros(length(_abstols[k]))) for k in 1:N]
10071007
for k in 1:N
10081008
filtered_setup = filter(p -> p.first in SciMLBase.allowedkeywords, setups[k])
10091009

‎lib/DiffEqDevTools/test/analyticless_stochastic_wp.jl‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
using Random
22
using StochasticDiffEq, DiffEqDevTools, Test
3-
using SDEProblemLibrary: prob_sde_additivesystem
3+
using SDEProblemLibrary: prob_sde_additivesystem, prob_sde_linear
44
using SciMLLogging: None
55

6+
linear_prob = remake(prob_sde_linear, tspan = (0.0, 0.1))
7+
wp_default_dts = WorkPrecisionSet(
8+
linear_prob, [1.0e-2, 1.0e-3], [1.0e-2, 1.0e-3], [Dict(:alg => SRIW1())];
9+
numruns = 1, numruns_error = 1, error_estimate = :l2
10+
)
11+
@test wp_default_dts.wps[1].dts == zeros(2)
12+
613
prob = prob_sde_additivesystem
714
prob = SDEProblem(prob.f, prob.g, prob.u0, (0.0, 0.1), prob.p)
815

‎lib/GlobalDiffEq/Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GlobalDiffEq"
22
uuid = "1d72d19b-84cc-4cb7-a099-7cbdb9ccc67c"
33
authors = ["Chris Rackauckas <[email protected]> and contributors"]
4-
version = "1.4.0"
4+
version = "1.4.1"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

‎lib/GlobalDiffEq/test/runtests.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Test
33
using SciMLTesting
44

55
run_tests(;
6-
env = "ODEDIFFEQ_TEST_GROUP",
6+
env = "GROUP",
77
core = function ()
88
@safetestset "Basic functionality" begin
99
include("basic_functionality_tests.jl")

0 commit comments

Comments
 (0)