Skip to main content

splineax

Sparse linear operators and direct solvers for Lineax.

splineax lets you keep a linear system in its native sparse storage (jax.experimental.sparse.BCOO / BCSR) and solve it with a sparse direct solver that plugs straight into lineax.linear_solve. It also interfaces with asdex for calculating sparse Jacobians and using them as operators.

  • Operators: BCOOLinearOperator and BCSRLinearOperator to hold sparse matrices, and tags for lineax.JacobianLinearOperator and lineax.FunctionLinearOperator that allow solvers to materialize them as sparse matrices via asdex.
  • Stateful solver protocols: StatefulSolver and SparseLinearSolver for writing solver-agnostic code that reuses factorizations over many solves and operators.
  • Solver library bindings: Spsolve (any backend), KLU (CPU-only, SuiteSparse KLU), Pardiso (CPU-only, Intel oneMKL Pardiso, installed as extra), and CuDSS (CUDA GPU-only, NVIDIA cuDSS, installed as extra). KLU, Pardiso, and CuDSS reuse their factorization across solves.
  • Higher-level solvers: AutoSparseLinearSolver, which picks an appropriate solver based on platform and settings, and HybridDirectIterative, which combines a direct solver with an iterative solver that uses the factorization as its preconditioner. For example, IterativeRefinement applies a Richardson iteration to the direct solver result in order to recover a high-precision solution using a limited-precision solver.
  • Lineax code interop: stateful_solve_transform rewrites a function that calls lineax.linear_solve so its solves thread a solver state and reuse a factorization.

Installation

pip install splineax

Example

Solve a 10000 x 10000 system. As a dense matrix it would need 10^8 entries, but kept sparse it has only ~3 x 10^4 nonzeros, and the solver never materialises the dense form.

import jax.numpy as jnp
import lineax as lx
import numpy as np
from jax.experimental.sparse import BCOO

import splineax as splx

n = 10000
np.random.seed(0)

# A large, randomly sparse matrix with a heavy diagonal (so it is invertible).
diagonal_indices = np.stack([np.arange(n), np.arange(n)], axis=1)
off_diagonal_indices = np.unique(np.random.randint(0, n, size=(2 * n, 2)), axis=0)
indices = jnp.concatenate([diagonal_indices, off_diagonal_indices])
values = jnp.concatenate(
    [
        np.full(n, float(n)),
        np.random.uniform(low=-1, high=1, size=off_diagonal_indices.shape[0]),
    ]
)
matrix = BCOO((values, indices), shape=(n, n)).sum_duplicates()

operator = splx.BCOOLinearOperator(matrix)
vectors = [jnp.ones(n), jnp.arange(n) % 2]
solver = splx.AutoSparseLinearSolver()

# Solve once, then thread the returned state back in to reuse the factorization.
solution, state = splx.linear_solve(operator, vectors[0], solver)
assert jnp.allclose(matrix @ solution.value, vectors[0], atol=1e-4)

solution, state = splx.linear_solve(operator, vectors[1], solver, state=state)
assert jnp.allclose(matrix @ solution.value, vectors[1], atol=1e-4)

# Free the factorization when you are done with it.
state.release()

Testing on a GPU

CuDSS wraps NVIDIA's cuDSS library, which is CUDA-only, so its tests skip on ordinary (CPU) CI. The easiest way to run them for real is notebooks/colab_gpu_tests.ipynb:

Open In Colab

Open it, pick a GPU runtime, and choose Run all. It clones a branch, installs the locked environment with the cudss extra, and runs the test suite. On any other machine with a CUDA 13 GPU, the same run is uv run --python 3.12 --extra cudss pytest tests. On a GPU, the tests marked cpu_only skip, since they solve through KLU or Pardiso.

Documentation

Build the docs locally with uv run mkdocs serve, or view the user guide and API reference here.

Metadata

Release files for splineax 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splineax 0.4.1
File Size Uploaded Provenance Actions
splineax-0.4.1.tar.gz 86.3 kB With provenance Details for splineax-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for splineax 0.4.1
File Interpreter ABI Platform Actions
splineax-0.4.1-py3-none-any.whl Python 3 none any Details for splineax-0.4.1-py3-none-any.whl

Total release size: 185.2 kB

Release files / splineax-0.4.1.tar.gz

Download URL splineax-0.4.1.tar.gz
Size 86.3 kB
Tags Source
SHA-256 checksum
How to use checksums
19c3c3fdc6d63911c4eeb5ac77c8a4c7379184ae08a76597584e61095d2f6e9a
BLAKE2b-256 checksum
How to use checksums
6b225f21b60997b570d452e4a2d1231844845853f8348af1ae23fe38da09e269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / splineax-0.4.1-py3-none-any.whl

Download URL splineax-0.4.1-py3-none-any.whl
Size 98.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee89456b6d9ce8682979082d18b3528951dc5c867a9e9ccad62fc11eb35c0d6c
BLAKE2b-256 checksum
How to use checksums
71f9c23e4026b949de2847bdd98e4c738e1134be8c09c4c259b48ce2ef02b9b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for splineax 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for splineax-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page