Skip to main content

Differentiable structured linear solvers, preconditioners and matrix-free methods in JAX

Project description

SOLVAX

tests codecov PyPI docs license

Differentiable structured linear solvers, preconditioners and matrix-free methods in JAX.

solvax provides the solver infrastructure that kinetic and PDE codes keep re-implementing: structured direct solves (batched dense LU, block-tridiagonal Schur elimination with truncated storage), preconditioned and recycled Krylov methods, physics-agnostic preconditioners (coarse-operator LU, p-multigrid, Kronecker approximations, line smoothers), mixed-precision iterative refinement, and implicit differentiation of every solve — all jit/vmap/grad-transparent, on CPU and GPU.

It fills a gap in the JAX ecosystem: lineax offers general linear-operator abstractions and standard solvers, but not block-structured direct elimination, coarse-operator/multigrid preconditioning, or Krylov subspace recycling for parameter continuation. solvax builds on lineax's operator interface and adds exactly that layer.

Install

pip install solvax

Quickstart

import jax.numpy as jnp
import solvax as sx

# Solve a block-tridiagonal system L_k x_{k-1} + D_k x_k + U_k x_{k+1} = b_k
x = sx.block_thomas(lower, diag, upper, rhs)

# Reuse one elimination across many right-hand sides
factors = sx.block_thomas_factor(lower, diag, upper)
x1 = sx.block_thomas_solve(factors, rhs1)
x2 = sx.block_thomas_solve(factors, rhs2)

# Memory-truncated mode: rhs nonzero only in the lowest K blocks and only the
# lowest K solution blocks needed -> O(K m^2) memory, independent of N.
x_low = sx.block_thomas_truncated(lower, diag, upper, rhs[:3], keep_lowest=3)

Everything is differentiable (jax.grad through the solve) and batchable (jax.vmap over stacked systems).

What's in the box

Module Contents
solvax.operators Matrix-free, sum, Kronecker, block-tridiagonal and bordered (constraint-row) operator containers with closed-form transposes
solvax.precond Jacobi/block-Jacobi, coarse-operator LU, alternating-direction line smoothers, p-multigrid V-cycles, nearest-Kronecker, mixed-precision wrappers
solvax.direct Block-tridiagonal Schur elimination (block Thomas): full, factor/solve split, truncated-storage mode
solvax.banded Non-pivoted banded LU with row equilibration + static pivoting; periodic variant via the Woodbury capacitance trick
solvax.krylov Flexible restarted GMRES (CGS2 + Givens) and GCROT-style Krylov subspace recycling for parameter continuation
solvax.implicit Implicit-function-theorem linear_solve and root_solve — gradients cost one extra (transposed) solve
solvax.refine Mixed-precision iterative refinement (float32 factor, float64 residuals)
solvax.native Host-side SuperLU bridge (non-differentiable, import-guarded)

Roadmap to v0.2: harmonic-Ritz recycle selection, pytree operands, complex dtypes, GPU batched-LU benchmarks.

# Preconditioned, recycled Krylov across a parameter scan:
sol = sx.gcrot(matvec, b, precond=coarse_inverse, m=50, k=10)
sol2 = sx.gcrot(matvec2, b2, precond=coarse_inverse, recycle=sol.recycle)

# Differentiable solve wrapping any solver:
x = sx.linear_solve(matvec, b, solver=lambda mv, rhs: sx.gmres(mv, rhs).x)

License

MIT. Developed by the UW Plasma group.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solvax-0.1.0.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solvax-0.1.0-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

Details for the file solvax-0.1.0.tar.gz.

File metadata

  • Download URL: solvax-0.1.0.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for solvax-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ddf7bd8f27f723e368116b662dbcc1981b4584ed6a80db74eb0160d8d4b68a40
MD5 5d3fad1b8dbe442767a8ae3d0715eed8
BLAKE2b-256 85280547fe7a344d1c3d2148830bec801ab31ef27de6dea575d0babfa8c92e55

See more details on using hashes here.

Provenance

The following attestation bundles were made for solvax-0.1.0.tar.gz:

Publisher: publish.yml on uwplasma/SOLVAX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file solvax-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: solvax-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for solvax-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5074d7ffcb9b24bc66dd5d9ed70b7dbd5a798207ca46e59ad958915bc979bee9
MD5 a820c5d9607c1f8c28e6014ce212c868
BLAKE2b-256 ade508f743b2caeb0d6d2ebdedb2d186bbfaa4468f50ddac81d36bcf1cca5dfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for solvax-0.1.0-py3-none-any.whl:

Publisher: publish.yml on uwplasma/SOLVAX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page