SciML / NonlinearSolve.jl

High-performance and differentiation-enabled nonlinear solvers (Newton methods), bracketed rootfinding (bisection, Falsi), with sparsity and Newton-Krylov support.
https://docs.sciml.ai/NonlinearSolve/stable/
MIT License
234 stars 40 forks source link

Use approximate sparsity detection by default #320

Closed avik-pal closed 10 months ago

avik-pal commented 10 months ago

See https://github.com/SciML/NonlinearSolve.jl/pull/318. Opening a new PR so that I can see the documentation previews

codecov[bot] commented 10 months ago

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (d7ef4af) 80.48% compared to head (540ef5b) 85.58%.

Files Patch % Lines
src/jacobian.jl 45.45% 6 Missing :warning:
src/utils.jl 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #320 +/- ## ========================================== + Coverage 80.48% 85.58% +5.09% ========================================== Files 23 24 +1 Lines 1942 1956 +14 ========================================== + Hits 1563 1674 +111 + Misses 379 282 -97 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

avik-pal commented 10 months ago

Don't merge this. I am working on a way to control this from outside and add a manual entry explaining the choices.

But results are very promising:

132.129 s (1713050 allocations: 161.91 MiB)  # No Sparsity
  7.050 s (1784519 allocations: 4.00 GiB)    # Approx Sparsity + Default Linsolve
  6.579 s (1751088 allocations: 224.89 MiB)  # Approx Sparsity + KLU
  103.329 ms (52777 allocations: 387.83 MiB) # Approx Sparsity + GMRES
  5.082 s (84270 allocations: 3.90 GiB)      # Default Linsolve with Precomputed Sparsity
  6.408 s (50843 allocations: 119.60 MiB)    # KLU with Precomputed Sparsity

I will add the numbers for how long Symbolics takes to do the detection

ChrisRackauckas commented 10 months ago

103.329 ms (52777 allocations: 387.83 MiB) # Approx Sparsity + GMRES

Why would that use sparsity at all?

avik-pal commented 10 months ago

It's not using it, I just ran it with the option on. In the tutorial, the point for that being even if you supply a sparse AD type, we are smart enough to switch to the corresponding non-sparse type if concrete_jac is false

ChrisRackauckas commented 10 months ago

we are smart enough to switch to the corresponding non-sparse type if concrete_jac is false

By non-sparse you mean Jacobian-free?