JuliaDiff / SparseDiffTools.jl

Fast jacobian computation through sparsity exploitation and matrix coloring
MIT License
240 stars 42 forks source link

Make inference's job much easier by avoiding `map` #149

Closed ChrisRackauckas closed 3 years ago

ChrisRackauckas commented 3 years ago

Before:

function lorenz(du,u,p,t)
 du[1] = 10.0(u[2]-u[1])
 du[2] = u[1]*(28.0-u[3]) - u[2]
 du[3] = u[1]*u[2] - (8/3)*u[3]
end

u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)

using OrdinaryDiffEq, SnoopCompile
prob = ODEProblem(lorenz,u0,tspan)
alg = Rodas5()
tinf = @snoopi_deep solve(prob,alg)
ChrisRackauckas commented 3 years ago
function lorenz(du,u,p,t)
 du[1] = 10.0(u[2]-u[1])
 du[2] = u[1]*(28.0-u[3]) - u[2]
 du[3] = u[1]*u[2] - (8/3)*u[3]
end

u0 = [1.0;0.0;0.0]
tspan = (0.0,100.0)

using OrdinaryDiffEq, SnoopCompile
prob = ODEProblem(lorenz,u0,tspan)
alg = Rodas5(chunk_size = 3)
tinf = @snoopi_deep solve(prob,alg)

down from 16 seconds to 2.5

InferenceTimingNode: 1.310514/2.560714 on Core.Compiler.Timings.ROOT() with 17 direct children
codecov-commenter commented 3 years ago

Codecov Report

Merging #149 (73f2018) into master (fb09091) will increase coverage by 0.21%. The diff coverage is 93.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   83.48%   83.69%   +0.21%     
==========================================
  Files          12       12              
  Lines         666      687      +21     
==========================================
+ Hits          556      575      +19     
- Misses        110      112       +2     
Impacted Files Coverage Δ
src/differentiation/compute_jacobian_ad.jl 94.14% <93.54%> (-0.42%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fb09091...73f2018. Read the comment docs.

ChrisRackauckas commented 3 years ago
InferenceTimingNode: 1.158426/2.076904 on Core.Compiler.Timings.ROOT() with 9 direct children

With the last commit.