Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Conversation

avik-pal
Copy link
Member

@avik-pal avik-pal commented Jun 27, 2023

Some very crude benchmarks using a problem size of 1 x 1000 (i.e., 1000 batch size)

Broyden

  • OLD: 11.312 ms (883 allocations: 2.27 MiB)
  • NEW: 10.678 ms (545 allocations: 548.62 KiB)
  • NEW (in-place): 10.915 ms (522 allocations: 373.94 KiB)

LBroyden

  • OLD: Failed Convergence
  • NEW: Same Failed Convergence
  • NEW (in-place): Same Failed Convergence

Not updating it since my updates again broke it. For NN cases anyways BatchedDFSane seems to be more reliable and fast.

SimpleDFSane

  • OLD: 1.389 ms (1510 allocations: 2.61 MiB)
  • NEW: 1.093 ms (261 allocations: 1.05 MiB)
  • NEW (in-place): 1.014 ms (242 allocations: 929.45 KiB)

Raphson

  • OLD: N/A
  • NEW: 997.954 ms (6452 allocations: 142.61 MiB)
  • NEW (in-place): N/A

Summary of Updates:

  • Instead of doing if batching and similar, I am separating the code for batched and unbatched versions for easier maintenance
  • Better caching of arrays lowering allocations significantly
  • Ideally, inputs are Matrices. If not,
    • A vector is assumed to have a batch size of 1
    • Any higher dimension array is treated as a matrix by collapsing all but the last dimension
  • Inplace functions are supported!!

@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Merging #68 (10acbed) into main (516cc8d) will decrease coverage by 0.30%.
The diff coverage is 91.15%.

@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
- Coverage   92.30%   92.01%   -0.30%     
==========================================
  Files          16       20       +4     
  Lines         819      952     +133     
==========================================
+ Hits          756      876     +120     
- Misses         63       76      +13     
Impacted Files Coverage Δ
src/raphson.jl 90.00% <77.77%> (-3.94%) ⬇️
src/batched/utils.jl 87.80% <87.80%> (ø)
src/batched/raphson.jl 88.23% <88.23%> (ø)
ext/SimpleNonlinearSolveNNlibExt.jl 90.24% <90.24%> (ø)
src/batched/dfsane.jl 93.15% <93.15%> (ø)
src/SimpleNonlinearSolve.jl 100.00% <100.00%> (+6.66%) ⬆️
src/batched/broyden.jl 100.00% <100.00%> (ø)
src/broyden.jl 92.10% <100.00%> (+0.92%) ⬆️
src/dfsane.jl 95.94% <100.00%> (-0.80%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@avik-pal avik-pal force-pushed the ap/batch_revamp branch 2 times, most recently from e912230 to 061ec7d Compare June 27, 2023 22:39
@avik-pal avik-pal changed the title [WIP] Revamp working of Batched Solvers Revamp working of Batched Solvers Jun 30, 2023
@avik-pal
Copy link
Member Author

@ChrisRackauckas, this is ready for review. This is quite an aggressive change to how things work internally, but the speedups seem worth it.

The CI failures seem related to SciMLOperators and LinearSolve.

@avik-pal
Copy link
Member Author

@ChrisRackauckas bump on this

@ChrisRackauckas ChrisRackauckas merged commit f20f5e4 into SciML:main Jul 18, 2023
@avik-pal avik-pal deleted the ap/batch_revamp branch July 18, 2023 20:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants