exanauts / ExaPF.jl

A Power Flow Solver for GPUs in Julia
MIT License
58 stars 5 forks source link

Block evaluation - second attempt #241

Closed frapac closed 2 years ago

frapac commented 2 years ago

This PR adds the tools needed to evaluate the functions and their derivatives in blocks, for different set of parameters.

What's the exact goal of this PR?

This PR opens the door to:

What is this PR implementing exactly?

Before, ExaPF was developed to evaluate a single function

g(x_1, p_1)

for one parameter p_1. With this PR, we can now evaluate in batch the N different outputs:

g(x_1, p_1)
...
g(x_N, p_N)

with p_1, ..., p_N being N different parameters.

As the structure of the function g remains the same, the block evaluation streamlines very well on the GPU.

In details, this PR adds:

  1. A BlockNetworkStack structure to store the current values for x_1, ..., x_N and for p_1, ..., p_N
  2. A blockmul! function to dispatch automatically on SpMM when we are using the batched evaluations.
  3. Two structures ArrowheadJacobian and ArrowheadHessian to evaluate the derivative in batched and stores the result in an arrow-head sparse matrix.
codecov-commenter commented 2 years ago

Codecov Report

Merging #241 (2ed20a1) into develop (6e7c9e1) will decrease coverage by 1.83%. The diff coverage is 71.98%.

@@             Coverage Diff             @@
##           develop     #241      +/-   ##
===========================================
- Coverage    73.72%   71.88%   -1.84%     
===========================================
  Files           27       28       +1     
  Lines         2934     3464     +530     
===========================================
+ Hits          2163     2490     +327     
- Misses         771      974     +203     
Impacted Files Coverage Δ
src/Polar/newton.jl 86.79% <ø> (ø)
src/templates.jl 100.00% <ø> (ø)
src/utils.jl 66.26% <44.00%> (-9.60%) :arrow_down:
src/Polar/polar.jl 68.75% <58.73%> (-31.25%) :arrow_down:
src/Polar/second_order.jl 71.68% <60.24%> (-28.32%) :arrow_down:
src/Polar/first_order.jl 70.12% <62.80%> (-29.88%) :arrow_down:
src/cuda_wrapper.jl 89.83% <81.81%> (-7.05%) :arrow_down:
src/Polar/stacks.jl 82.08% <82.08%> (ø)
src/Polar/functions.jl 95.03% <91.20%> (-4.37%) :arrow_down:
src/autodiff.jl 86.02% <91.66%> (-0.80%) :arrow_down:
... and 3 more

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more