Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign default ODE solver to be type-grounded and lazy #2184

Merged
merged 32 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aa1c546
Redesign default ODE solver to be fully type-grounded
ChrisRackauckas Jan 1, 2024
dc7e96f
fix typo
oscardssmith May 9, 2024
4648f3a
typos
oscardssmith May 9, 2024
96147c9
rebase typos
oscardssmith May 9, 2024
b946f2e
typo
oscardssmith May 9, 2024
5f19a80
fix DelayDiffEq issue
oscardssmith May 13, 2024
51a84e0
bugfix
oscardssmith May 14, 2024
75ef069
use the default solver by default
oscardssmith May 14, 2024
0458d40
init current to 0
oscardssmith May 14, 2024
9bdc84b
add tests
oscardssmith May 14, 2024
59539d8
improve tests
oscardssmith May 15, 2024
66fd522
switching works other than functionwrappers
oscardssmith May 15, 2024
4901a02
it works
oscardssmith May 15, 2024
971fdf6
better test
oscardssmith May 15, 2024
868d836
better tests
oscardssmith May 15, 2024
217fb53
better tests
oscardssmith May 15, 2024
43e117a
fix composite chunksize
oscardssmith May 15, 2024
a5fa00f
fix test
oscardssmith May 15, 2024
b6ddc9e
forgot to save before commit
oscardssmith May 15, 2024
9e82e80
fix rober test
oscardssmith May 16, 2024
e046bbe
add FBDF tests
oscardssmith May 16, 2024
091623a
in place works
oscardssmith May 16, 2024
569a25e
don't bypass pipeline
oscardssmith May 17, 2024
28c7fe7
Update src/solve.jl
ChrisRackauckas May 17, 2024
3bd4a71
Update src/solve.jl
ChrisRackauckas May 17, 2024
ba897b9
fix test failures and re-enable autodiff
oscardssmith May 17, 2024
fdf946b
disable autodiff
oscardssmith May 17, 2024
b832f2f
fix non-identity mass matrix with default solver and test
oscardssmith May 20, 2024
4cef511
typo
oscardssmith May 20, 2024
cbf273a
fix chunksize inference
oscardssmith May 20, 2024
fc76006
add inferred test
oscardssmith May 20, 2024
d7193fb
fix tests
oscardssmith May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/derivative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ function build_jac_config(alg, f::F1, uf::F2, du1, uprev, u, tmp, du2,

if alg_autodiff(alg) isa AutoForwardDiff
_chunksize = get_chunksize(alg) === Val(0) ? nothing : get_chunksize(alg) # SparseDiffEq uses different convection...

T = if standardtag(alg)
typeof(ForwardDiff.Tag(OrdinaryDiffEqTag(), eltype(u)))
else
Expand Down
6 changes: 4 additions & 2 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,13 @@
integrator
end

function DiffEqBase.__init(prob::ODEProblem, ::Nothing, args...; kwargs...)
DiffEqBase.__init(prob, DefaultODEAlgorithm(), args...; kwargs...)
alg = DiffEqBase.prepare_alg(DefaultODEAlgorithm(), prob.u0, prob.p, prob)
oscardssmith marked this conversation as resolved.
Show resolved Hide resolved
oscardssmith marked this conversation as resolved.
Show resolved Hide resolved
DiffEqBase.__init(prob, alg, args...; kwargs...)

Check warning on line 537 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L535-L537

Added lines #L535 - L537 were not covered by tests
oscardssmith marked this conversation as resolved.
Show resolved Hide resolved
end
function DiffEqBase.__solve(prob::ODEProblem, ::Nothing, args...; kwargs...)
DiffEqBase.__solve(prob, DefaultODEAlgorithm(), args...; kwargs...)
alg = DiffEqBase.prepare_alg(DefaultODEAlgorithm(), prob.u0, prob.p, prob)
DiffEqBase.__solve(prob, alg, args...; kwargs...)

Check warning on line 541 in src/solve.jl

View check run for this annotation

Codecov / codecov/patch

src/solve.jl#L539-L541

Added lines #L539 - L541 were not covered by tests
end

function DiffEqBase.solve!(integrator::ODEIntegrator)
Expand Down
9 changes: 6 additions & 3 deletions test/interface/default_solver_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using OrdinaryDiffEq, Test, LinearSolve
using OrdinaryDiffEq, Test, LinearSolve, LinearAlgebra, SparseArrays

f_2dlinear = (du, u, p, t) -> (@. du = p * u)

Expand Down Expand Up @@ -52,10 +52,13 @@ function exrober(du, u, p, t)
k₂ * y₂^2, ], u[4:end])
end

for n in (100, 1000)
for n in (100, 600)
stiffalg = n < 500 ? 5 : 6
linsolve = n < 500 ? nothing : KrylovJL_GMRES()
prob_ex_rober = ODEProblem(exrober, vcat([1.0,0.0,0.0], ones(n)),(0.0,100.0),(0.04,3e7,1e4))
jac_prototype = sparse(I(n+3))
jac_prototype[1:3, 1:3] .= 1.0

prob_ex_rober = ODEProblem(ODEFunction(exrober; jac_prototype), vcat([1.0,0.0,0.0], ones(n)),(0.0,100.0),(0.04,3e7,1e4))
sol = solve(prob_ex_rober)
fsol = solve(prob_ex_rober, AutoTsit5(FBDF(;linsolve)))
# test that default has the same performance as AutoTsit5(Rosenbrock23()) (which we expect it to use for this).
Expand Down
Loading