Performance Tips¶
Practical guidance for picking a backend, method, and precision once you are past the quick start. The reasoning behind the direct-vs-iterative trade-off is in Backends and Capability Matrix; the measured numbers are in Benchmarks.
Choosing a backend and method¶
float64 converges more reliably with the iterative solvers; float32 can stall on ill-conditioned PDE matrices.
For SPD matrices,
choleskyis roughly twice as fast aslu– letmatrix_type="auto"detect symmetry / positive-definiteness and pick it.On CPU,
scipy+luis the default and gives machine precision.On NVIDIA for problems under ~2M DOF,
cudss+choleskyis the fastest direct solver.For larger problems,
pytorch+cgis the memory-efficient choice and the one that reached 169M DOF on a single GPU.Beyond a single GPU,
DSparseTensorpartitions the matrix across devices.For a portable GPU direct solve – including AMD ROCm, where cuDSS is not available – use
strumpack(multifrontal LU on CPU/CUDA/ROCm).
Reusing work across solves¶
For repeated solves with the same matrix, factor once with
A.lu()and reuse theLUFactorizationfor each right-hand side.To apply one set of defaults across many solves, wrap them in a
SolverConfigscope (see the Configuring solves section of Introduction) rather than repeating kwargs.An iterative solve refines toward a tolerance, so a good
x0(e.g. the previous step’s solution in a time loop) cuts the iteration count.
Accuracy vs. speed¶
The iterative default
atol ~ 1e-6is a stopping point, not a ceiling – tightenatoltoward1e-12when you need more digits, at the cost of iterations. See Direct vs iterative.A good preconditioner (
"amg"for PDE problems) can cut the iteration count 10-100x on ill-conditioned systems.