Sparse linear solver¶
Sparse-direct linear solve with autograd support.
The SciPy SuperLU backend ships with the project’s existing dependencies and serves as the always-available baseline. Optional PETSc/MUMPS and cuDSS paths are selected only after runtime smoke tests, so broken optional installs fall back cleanly.
The autograd Function caches the LU factorisation across forward and backward
so the adjoint solve reuses the factor. Forward solves K x = b; backward
solves K^T λ = grad_x and emits
grad_K_values[k] = -λ[i_k] * x[j_k] for (i_k, j_k) in K’s COO pattern grad_b = λ
which is the standard implicit-derivative formula for a linear solve.