Surprising behaviour for cudss, uniform batch mode

Hello,

When trying to use cuDSS for solving sparse linear system, in a Newton-Raphson algorithm for solving powerflow equations (code open source here GitHub - Grid2op/gpusim2grid Β· GitHub I can provide data to reproduce what I observe) I noticed something rather strange.

Matrices are real, non symmetrical, sometimes not really well conditionned. The software works by batching lots of power flow matrices. And I wanted to optimize the throughput (for different power grid sizes, from 30 buses, jacobian say 50x50 up to 70k buses, jacobian of dimension 130kx130k).

So I run the experiments: perform 2**15 powerflows (a large number) by batch of size b, with b varying like 1, 2, 4, 8, 16, etc. for all synthetic grid on this dataset.

And each time the same things happen: there is a large drop in performances between a batch of 8 (CUDSS_CONFIG_UBATCH_SIZE=8) and a batch of 16 (CUDSS_CONFIG_UBATCH_SIZE=16).

I have graphs like this (the most severe one on the largest grid), for 3 different GPU: an old T4, a more recent l20 and an even more recent rtx 6000

This happens on the 3 machines for all grid sizes.

I thought it was some error on my side so I double checked this result, and reproduce it in a different experiment on real data (around 10k grids simulated, still varying the batch size, jacobian around 16kx16k in dimension) this time being more exhaustive in the saved timings.

I also did experiments with batches of 8, 9, …, 15, 16 and have the following table (only for batch 15 and batch size 16):

β”‚ batch β”‚ total(ms) β”‚ first_factor β”‚ refactorize β”‚ solve β”‚ cuDSS sum β”‚ cuDSS %total β”‚
β”‚ 15 β”‚ 29,412 β”‚ 1.70 β”‚ 4,138 β”‚ 1,072 β”‚ 5,212 β”‚ 17.7% β”‚
β”‚ 16 β”‚ 222,155 β”‚ 51.02 β”‚ 125,114 β”‚ 74,543 β”‚ 199,708 β”‚ 89.9% β”‚

The final curve (only plotting the total time) looks also really surprising:

It is quite like there are 2 modes in cudss. The really fast mode, taking 5.2 s for the 686 batches of 15 grids each and the really slow mode taking 200s (40x more roughly) for the 643 batches of 16 grids each.

This seems to be independant of the size of the underlying batched matrices.

We need roughly a batch of 200 grids to achieve the same performance as the 15 grids: for this experiment, 15 grids is way to small to saturate the GPU hence the performance benefit to batch more data.

Is this expected ?

Can this be improved in some ways ?

Best

Benjamin

Hi @benjamin.donnot

Thanks for the report!

This is a known issue with a sub-optimal kernel dispatch for uniform batches, already fixed and the fix will be available in the next release (the one after cudss 0.8.0).

Best,
Kirill