Skip to main content

apxchol (Python, CPU)

Approximate-Cholesky preconditioner for graph-Laplacian / SDDM linear systems.

pip install apxchol

Prebuilt wheels: Linux x86_64 (manylinux), CPython 3.10–3.14. CPU only. The wheels are built with 32-bit indices: inputs (and factors) beyond ~2.1e9 nonzeros are unsupported — build from source with -DAPXCHOL_64BIT_EDGE_INDICES=ON for larger problems.

import apxchol

solver = apxchol.factorize(A)           # scipy sparse Laplacian or SDDM; factor once
res = solver.solve(b, rtol=1e-8, maxiter=500)
res.x, res.iters, res.residual, res.converged

z = solver.apply(r)                     # M^{-1} r
M = solver.aspreconditioner()           # use as M= in scipy.sparse.linalg.cg

res = apxchol.solve(A, b)               # one-shot convenience

Laplacian vs SDDM is auto-detected: singular Laplacians get a rank-(n−1) factor with native null-space handling; SDDM systems get the full-rank factor. The factor is built once per factorize(A) (alias: apxchol.solver(A)) and reused across right-hand sides; solve runs the library's OpenMP-parallel PCG (threads via OMP_NUM_THREADS).

Solving

res = solver.solve(b, rtol=1e-8, maxiter=500, x0=guess)

rtol is the relative-residual target (SciPy's name; tol is kept as an alias and rtol wins if both are given, default 1e-8). x0 is an optional initial guess — an already-converged x0 returns iters == 0.

out is an optional writable C-contiguous float64 array of length n: the solution is written into it in place (no per-solve allocation) and returned as SolveResult.x.

Options

solver = apxchol.factorize(A, seed=42, partitioner="block_greedy",
                           storage="vec_pool", keep_factor=True)
  • seed — RNG seed for the randomized clique sampling.
  • partitioner — independent-set selector: block_greedy (default), luby, baumann_kyng, rootset.
  • storage — graph backend: vec_pool (default), forward_star, vec, bstr.
  • keep_factor — keep the factor arrays alive for export (default True). Costs one extra factor-sized copy in memory (~8 bytes per factor nonzero in the default fp32 wheels); with keep_factor=False the chol()/L/D export raises, while P, factor_nnz and fill_ratio stay available. Pass keep_factor=False for the leanest factor-once / solve-many footprint (the 0.1.x behavior); apxchol.solve() (one-shot) uses False.

Advanced core knobs are passed through as extra keywords: degree_quantile, degree_multiplier, degree_tiebreak, exact_clique_max_degree, residual_peel (natural | min_degree | bk_serial), stagnation_window. Unknown keywords raise ValueError. Note: degree_multiplier only takes effect when degree_quantile=0 (the quantile cap, default 0.2, replaces it).

Factor export

P = solver.P            # int64: P[original_vertex] = position in elimination order
G = solver.chol()       # scipy.sparse.csc_matrix, lower-triangular incl. sqrt-diagonal
L, D = solver.L, solver.D          # unit-lower CSC and the diagonal of L·D·L^T
solver.factor_nnz, solver.fill_ratio

The factor lives in permuted space, ordered by elimination:

import numpy as np
import scipy.sparse as sp

p = np.argsort(solver.P)     # original index of the k-th eliminated vertex
A_perm = A[p][:, p]
# A_perm ~= G @ G.T ~= L @ sp.diags(D) @ L.T

G is an approximate, randomly sampled factor, so that identity is approximate by construction; L @ diags(D) @ L.T == G @ G.T is exact. For a pure Laplacian (solver.sddm == False) it holds on the rank-(n−k) subspace only, where k is the number of connected components — the last eliminated column of each component carries a placeholder diagonal.

fill_ratio is (2 * factor_nnz - n) / nnz(A): the factor G reflected to a full symmetric pattern (diagonal counted once) against the nonzeros of the full symmetric A.

Exported values are float64 numpy arrays, but default builds store factor values in fp32, so they carry fp32 precision (~7 digits).

Thread safety

A Solver is not safe for concurrent use: solve() and apply() write shared internal scratch buffers. Use one Solver per thread, or serialize calls (each call is itself OpenMP-parallel).

License

BSD 4-Clause (the original "BSD with advertising clause" license) — see LICENSE. Copyright (c) 2026 ETH Zürich and the apxchol contributors.

From source

The wheel build compiles the library's two core translation units directly; building from a repository checkout works the same way:

pip install -e python          # from the repository root
pytest python/tests -v

Source builds use -O3 -march=native (the distributed wheels are built portable). If your environment requires --no-build-isolation, first pip install pybind11 scikit-build-core.

Metadata

Release files for apxchol 0.2.2

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

Built distributions (wheels)

Table of built distributions (wheels) for apxchol 0.2.2
File
apxchol-0.2.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
apxchol-0.2.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
apxchol-0.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
apxchol-0.2.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
apxchol-0.2.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 4.0 MB

Release files / apxchol-0.2.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL apxchol-0.2.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 426.6 kB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6bb8a67d96f29d48884cdd4865ebfcba6ec51522ecd2dcd6ae19608a48dc665f
BLAKE2b-256 checksum
How to use checksums
6c0abfc3655d07e0962c93f6d61a0ac8b0dd46f55e03990e41ea26a9a6236927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / apxchol-0.2.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL apxchol-0.2.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 426.4 kB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b50a9ac83bef42ffb3265b15b423aedfacf685a50eb2d75ef847c90feabcbd89
BLAKE2b-256 checksum
How to use checksums
656e983243c057a39a3171e28c3556c486ad7c6dc4a5cf7e51c4aad48fc7aead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / apxchol-0.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL apxchol-0.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 426.4 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5d392e8bca7fecdc036318e4390f62c9d27b7118cf99bd2ef6816df1da09253e
BLAKE2b-256 checksum
How to use checksums
2e2cc020a2457e4cdcc65438ed2764011bc0368133dc23a996d10cc31c35a88c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / apxchol-0.2.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL apxchol-0.2.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 426.4 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c560d3fa9ae90d09f7bdd3c4d4778f1db3254bac6f6153aee024bf64bda5d9cb
BLAKE2b-256 checksum
How to use checksums
b9dcba33792bfac20aaf0c18da295837bc04053aa89d09fe5b6a04541f9d116e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / apxchol-0.2.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL apxchol-0.2.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
87188a2b17f049700d5a52de563cb2d1eea654039a28f791cb7f998e33d73fda
BLAKE2b-256 checksum
How to use checksums
d8a081593e92cae79044bbfc3bc3d0403696fd3041efca0ffd1c61c7f8fe5fcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Security for apxchol 0.2.2

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

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for apxchol-0.2.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

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 Jul 27, 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