DifferentialEquations.jl icon indicating copy to clipboard operation
DifferentialEquations.jl copied to clipboard

Compilation time with a large system of ODEs and autodiff=true

Open timknab opened this issue 4 years ago • 4 comments

The first run of a large (>1000) system of ODEs, using an algorithm that has autodiff=true as the default (i.e AutoTsit5(Rosenbrock23())) results in a very long compilation time.

Setting autodiff=false very significantly reduces compilation time for these large problems. Can a heuristic be modified to detect the problem size and change the defaults and/or a note be added in the documentation to point out that disabling autodifferentiation for large systems of ODEs may be beneficial.

timknab avatar Jun 12 '20 18:06 timknab

Summing up from the Slack chat, it seems like AutoTsit5(Rosenbrock23(chunk_size=8)) and AutoTsit5(Rosenbrock23(chunk_size=4)) both reduce the compile time by half, and going to AutoTsit5(Rosenbrock23(chunk_size=1)) reduces the compile time down to the same as AutoTsit5(Rosenbrock23(autodiff=false)) without causing a runtime difference on this problem. For large enough problems, the differentiation isn't necessarily the issue (since time is probably spent in LU), so reducing the chunksize on asymtopically large problems could be helpful.

@YingboMa

ChrisRackauckas avatar Jun 13 '20 01:06 ChrisRackauckas

It would be good to run similar tests on BCR (@isaacsas ) to see if that behaves the same. If it's standard, then one trick might be to:

  • Lower the chunk_size cap
  • Slap a limit on there where if there's >100 ODEs, set the chunk size to 1

ChrisRackauckas avatar Jun 13 '20 01:06 ChrisRackauckas

I never even got autodiff to finish on BCR - I gave up after waiting a while. This was last year though...

isaacsas avatar Jun 13 '20 01:06 isaacsas

and going to AutoTsit5(Rosenbrock23(chunk_size=1)) reduces the compile time down to the same as AutoTsit5(Rosenbrock23(autodiff=false)) without causing a runtime difference on this problem.

The compile time is probably not accurate, because AutoTsit5(Rosenbrock23(chunk_size=N)) compiles Rosenbrock23(chunk_size=1) (for clean up loops) for all natural number N.

YingboMa avatar Jun 13 '20 20:06 YingboMa