SciML / DiffEqGPU.jl

GPU-acceleration routines for DifferentialEquations.jl and the broader SciML scientific machine learning ecosystem
https://docs.sciml.ai/DiffEqGPU/stable/
MIT License
283 stars 29 forks source link

Support DynamicalODEFunction #109

Open ExpandingMan opened 3 years ago

ExpandingMan commented 3 years ago

See here. It is trying to get a field f from a DynamicalODEFunction (at least in my case) and this does not exist.

Looks like this particular object has f1 and f2 but not f, but I didn't dig any further than this.

Stack trace below.

julia> @btime solve(š¯”¢, EnsembleGPUArray(), trajectories=10^4);
ERROR: type DynamicalODEFunction has no field f
Stacktrace:
  [1] getproperty(x::Function, f::Symbol)
    @ Base ./Base.jl:33
  [2] generate_problem(prob::ODEProblem{ArrayPartition{Float32, Tuple{SVector{3, Float32}, SVector{3
, Float32}}}, Tuple{Float32, Float32}, false, SciMLBase.NullParameters, DynamicalODEFunction{false,
ODEFunction{false, DiffEqPhysics.var"#9#17"{var"#43#44", SVector{3, Float32}}, UniformScaling{Bool},
 Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing,
Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, ODEFunction{false, DiffEqPhysics.var"#11#19"{
var"#43#44", SVector{3, Float32}}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing
, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED),
 Nothing}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Noth
ing, Nothing, Nothing, Nothing, Nothing}, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple
{(), Tuple{}}}, SciMLBase.StandardODEProblem}, u0::CUDA.CuArray{Float32, 2}, p::CUDA.CuArray{SciMLBa
se.NullParameters, 2}, jac_prototype::Nothing, colorvec::Nothing)
    @ DiffEqGPU ~/.julia/packages/DiffEqGPU/gGgMY/src/DiffEqGPU.jl:410
  [3] batch_solve_up(ensembleprob::EnsembleProblem{ODEProblem{ArrayPartition{Float32, Tuple{SVector{
3, Float32}, SVector{3, Float32}}}, Tuple{Float32, Float32}, false, SciMLBase.NullParameters, Dynami
calODEFunction{false, ODEFunction{false, DiffEqPhysics.var"#9#17"{var"#43#44", SVector{3, Float32}},
 UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothi
ng, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, ODEFunction{false, Diff
EqPhysics.var"#11#19"{var"#43#44", SVector{3, Float32}}, UniformScaling{Bool}, Nothing, Nothing, Not
hing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLB
ase.DEFAULT_OBSERVED), Nothing}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing,
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Base.Iterators.Pairs{Union{}, Union{
}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#7#9", var"#8#10", typeof(S
ciMLBase.DEFAULT_REDUCTION), Nothing}, probs::Vector{ODEProblem{ArrayPartition{Float32, Tuple{SVecto
r{3, Float32}, SVector{3, Float32}}}, Tuple{Float32, Float32}, false, SciMLBase.NullParameters, Dyna
micalODEFunction{false, ODEFunction{false, DiffEqPhysics.var"#9#17"{var"#43#44", SVector{3, Float32}
}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Not
hing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, ODEFunction{false, Di
ffEqPhysics.var"#11#19"{var"#43#44", SVector{3, Float32}}, UniformScaling{Bool}, Nothing, Nothing, N
othing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciM
LBase.DEFAULT_OBSERVED), Nothing}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing
, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Base.Iterators.Pairs{Union{}, Unio
n{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}}, alg::Nothing, ensemblealg::E
nsembleGPUArray, I::UnitRange{Int64}, u0::Matrix{Float32}, p::Matrix{SciMLBase.NullParameters}; kwar
gs::Base.Iterators.Pairs{Symbol, DiffEqGPU.var"#12#18", Tuple{Symbol}, NamedTuple{(:unstable_check,)
, Tuple{DiffEqGPU.var"#12#18"}}})
    @ DiffEqGPU ~/.julia/packages/DiffEqGPU/gGgMY/src/DiffEqGPU.jl:311
  [4] batch_solve(ensembleprob::EnsembleProblem{ODEProblem{ArrayPartition{Float32, Tuple{SVector{3,
Float32}, SVector{3, Float32}}}, Tuple{Float32, Float32}, false, SciMLBase.NullParameters, Dynamical
ODEFunction{false, ODEFunction{false, DiffEqPhysics.var"#9#17"{var"#43#44", SVector{3, Float32}}, Un
iformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing,
 Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, ODEFunction{false, DiffEqP
hysics.var"#11#19"{var"#43#44", SVector{3, Float32}}, UniformScaling{Bool}, Nothing, Nothing, Nothin
g, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase
.DEFAULT_OBSERVED), Nothing}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Not
hing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Base.Iterators.Pairs{Union{}, Union{},
Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#7#9", var"#8#10", typeof(SciM
LBase.DEFAULT_REDUCTION), Nothing}, alg::Nothing, ensemblealg::EnsembleGPUArray, I::UnitRange{Int64}
; kwargs::Base.Iterators.Pairs{Symbol, DiffEqGPU.var"#12#18", Tuple{Symbol}, NamedTuple{(:unstable_c
heck,), Tuple{DiffEqGPU.var"#12#18"}}})
    @ DiffEqGPU ~/.julia/packages/DiffEqGPU/gGgMY/src/DiffEqGPU.jl:284
  [5] macro expansion
    @ ./timing.jl:287 [inlined]
  [6] __solve(ensembleprob::EnsembleProblem{ODEProblem{ArrayPartition{Float32, Tuple{SVector{3, Floa
t32}, SVector{3, Float32}}}, Tuple{Float32, Float32}, false, SciMLBase.NullParameters, DynamicalODEF
unction{false, ODEFunction{false, DiffEqPhysics.var"#9#17"{var"#43#44", SVector{3, Float32}}, Unifor
mScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Not
hing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing}, ODEFunction{false, DiffEqPhysi
cs.var"#11#19"{var"#43#44", SVector{3, Float32}}, UniformScaling{Bool}, Nothing, Nothing, Nothing, N
othing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEF
AULT_OBSERVED), Nothing}, UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing
, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, Base.Iterators.Pairs{Union{}, Union{}, Tupl
e{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#7#9", var"#8#10", typeof(SciMLBas
e.DEFAULT_REDUCTION), Nothing}, alg::Nothing, ensemblealg::EnsembleGPUArray; trajectories::Int64, ba
tch_size::Int64, unstable_check::Function, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, N
amedTuple{(), Tuple{}}})
    @ DiffEqGPU ~/.julia/packages/DiffEqGPU/gGgMY/src/DiffEqGPU.jl:201
  [7] #solve#61
    @ ~/.julia/packages/DiffEqBase/oe7VF/src/solve.jl:94 [inlined]
  [8] var"##core#311"()
    @ Main ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:479
  [9] var"##sample#312"(__params::BenchmarkTools.Parameters)
    @ Main ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:485
 [10] _run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; verbose::Bool, pad::String, kw
args::Base.Iterators.Pairs{Symbol, Integer, NTuple{4, Symbol}, NamedTuple{(:samples, :evals, :gctria
l, :gcsample), Tuple{Int64, Int64, Bool, Bool}}})
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:98
 [11] #invokelatest#2
    @ ./essentials.jl:710 [inlined]
 [12] #run_result#45
    @ ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:33 [inlined]
 [13] run(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::F
loat64, ndone::Float64, kwargs::Base.Iterators.Pairs{Symbol, Integer, NTuple{5, Symbol}, NamedTuple{
(:verbose, :samples, :evals, :gctrial, :gcsample), Tuple{Bool, Int64, Int64, Bool, Bool}}})
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:116
 [14] #warmup#54
    @ ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:168 [inlined]
 [15] warmup(item::BenchmarkTools.Benchmark)
    @ BenchmarkTools ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:168
 [16] top-level scope
    @ ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:565
AwesomeQuest commented 1 month ago

Is there a solution to this? Having the same problem.

ChrisRackauckas commented 3 weeks ago

There isn't a solution yet. Someone would just need to make an if DynamicalODEFunction branch that then does exactly

https://github.com/SciML/DiffEqGPU.jl/blob/master/src/ensemblegpuarray/problem_generation.jl#L71-L89

with the alternative arguments. Probably would take about half an hour, but needs tests and such.

SplitODEFunction is similar.

I'll label as a good first issue since it wouldn't take much knowledge of the package to solve, it just takes someone to define a few dispatches.