Large sparse problems¶
system(x) may return H as a sparse COO or CSR tensor, as in bundle adjustment, where JᵀJ has millions of entries but is 99.7 % zeros. gauss_newton() then needs only the diagonal of H and products with it. The linear_solver argument chooses how the damped system (H + diag(damping)) d = -g is solved:
Linear solver |
Notes |
|---|---|
Direct |
|
Preconditioned conjugate gradients from torchsparsegradutils. This is the default for a sparse |
|
any |
See |
damping="marquardt" (see Solvers) is usually needed on these problems, whose parameters have very different scales.
The bundle adjustment notebook builds per-observation Jacobians with vmap(jacfwd) through the camera poses’ manifold, assembles a sparse JᵀJ, and compares the CG solver with a Schur complement written as a custom linear_solver, on the CPU and on a GPU.