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

[v14 ready] Tutorial for ensuring performance for ODE simulations #751

Merged
merged 17 commits into from
May 25, 2024

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Dec 25, 2023

Creates a new doc page, providing some performance advice for ODE simulations. Stuff covered:

  • Stiff vs non-stiff ODEs.
  • Selecting a solver for ODE simualtions.
  • Various options for Jacobian computations (symbolic jacobian, sparse jacobian, lienar solver selection, and preconditioners).
  • Parallelisation on CPUs.
  • Parallelisation on GPUs.

The GPU parallelization part is not ready, I have only started. However, I need to go through some stuff with Utkarsh before finishing that part.

Also, if someone have a link to a good reference book introducing this kind of stuff, that would be useful

@TorkelE TorkelE changed the title Tutorial for ensuring performance for ODE simualtions [WIP] Tutorial for ensuring performance for ODE simulations Dec 25, 2023
@TorkelE TorkelE changed the title [WIP] Tutorial for ensuring performance for ODE simulations Tutorial for ensuring performance for ODE simulations Dec 27, 2023
When implicit solvers use e.g. the Newton-Raphson method to, in each simulation time step, solve a (typically non-linear) equation, they actually solve a linearised version of this equation. For this they use a linear solver, the choice of which can impact performance. To specify one, we use the `linsolve` option (given to the solver function, *not* the `solve` command). E.g. to use the `KLUFactorization` linear solver we run
```@example ode_simulation_performance_3
using DifferentialEquations
solve(oprob, Rodas5P(linsolve = KLUFactorization()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong solver for anything of this size and we should demonstrate this more correctly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should recommend using MKL and trying UMFPACK

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that Rodas5P is wrong for large problems (where we would do something like this) and should be changed, or that since preconditioners and stuff like this is not good for a 2-state brusselators we should demonstrate on a larger model?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't find any examples for MKL, so was unsure on how to implement it here.

```
Next, `incompletelu` can be supplied to our solver using the `precs` argument:
```@example ode_simulation_performance_3
solve(oprob, Rodas5P(precs = incompletelu))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this won't use the preconditioner

```
Finally, we note that since matrix-free linear solvers (like `KrylovJL_GMRES`) by default do not build a Jacobian. Hence, if we want to use them with a preconditioner we must tell them to build it. This can be done using the `concrete_jacobian=true` option:
```@example ode_simulation_performance_3
solve(oprob, Rodas5P(linsolve = KrylovJL_GMRES(), precs = incompletelu, concrete_jac=true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to skip straight to here because the line above is just incorrect

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does preconditioners make sense for linear solvers except for KrylovJL_GMRES then? Or should concrete_jac=true be used for the previous case?

@isaacsas
Copy link
Member

isaacsas commented Jan 5, 2024

Why don’t we just use some of the examples from the Catalyst paper that show different performance characteristics to illustrate which solvers and configurations work best in different cases? Then we’ve already done the benchmarking and know what is fastest.

@TorkelE
Copy link
Member Author

TorkelE commented Jan 5, 2024

Thanks for the input! I'm a little bit uncertain how to deal with the precondition part, but otherwise all good.

@TorkelE
Copy link
Member Author

TorkelE commented Jan 9, 2024

Did you have any further input on the preconditioners @ChrisRackauckas?

Also, what is the progress on moving default solvers to OrdinaryDiffEq? If that is coming soon then useful, but it would be useful to have a quick and dirt solver selection advice that did not depend on reading through all the doc, nor loading the full DifferenitalEquations suite.

@TorkelE TorkelE changed the title Tutorial for ensuring performance for ODE simulations [v14 ready] Tutorial for ensuring performance for ODE simulations Apr 8, 2024
@TorkelE TorkelE mentioned this pull request May 18, 2024
48 tasks
@TorkelE TorkelE merged commit 0eb9323 into master May 25, 2024
2 of 3 checks passed
@TorkelE TorkelE deleted the ode_performance_tutorial branch May 25, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants