Skip to main content

A self-contained sparse Cholesky solver, compatible with CPU and GPU tensor frameworks.

Project description

What is this repo?

This is a minimalistic, self-contained sparse Cholesky solver, supporting solving both on the CPU and on the GPU, easily integrable in your tensor pipeline.

When we were working on our "Large Steps in Inverse Rendering of Geometry" paper [1], we found it quite challenging to hook up an existing sparse linear solver to our pipeline, and we managed to do so by adding dependencies on large projects (i.e. cusparse and scikit-sparse), only to use a small part of its functionality. Therefore, we decided to implement our own library, that serves one purpose: efficiently solving sparse linear systems on the GPU or CPU, using a Cholesky factorization.

Under the hood, it relies on CHOLMOD for sparse matrix factorization. For the solving phase, it uses CHOLMOD for the CPU version, and uses the result of an analysis step run once when building the solver for fast solving on the GPU [2].

It achieves comparable performance as other frameworks, with the dependencies nicely shipped along.


Benchmark

Benchmark run on a Linux Ryzen 3990X workstation with a TITAN RTX.


The Python bindings are generated with nanobind, which makes it easily interoperable with most tensor frameworks (Numpy, PyTorch, JAX...)

Installing

With PyPI (recommended)

pip install cholespy

From source

git clone --recursive https://github.com/rgl-epfl/cholespy
pip install ./cholespy

Documentation

There is only one class in the module, with two variants: CholeskySolverF, CholeskySolverD. The only difference is that CholeskySolverF solves the system in single precision while CholeskySolverD uses double precision. This is mostly useful for solving on the GPU, as the CPU version relies on CHOLMOD, which only supports double precision anyway.

The most common tensor frameworks (PyTorch, NumPy, TensorFlow...) are supported out of the box. You can pass them directly to the module without any need for manual conversion.

Since both variants have the same signature, we only detail CholeskySolverF below:

cholespy.CholeskySolverF(n_rows, ii, jj, x, type)

Parameters:

  • n_rows - The number of rows in the (sparse) matrix.
  • ii - The first array of indices in the sparse matrix representation. If type is COO, then this is the array of row indices. If it is CSC (resp. CSR), then it is the array of column (resp. row) indices, such that row (resp. column) indices for column (resp. row) k are stored in jj[ii[k]:ii[k+1]] and the corresponding entries are in x[ii[k]:ii[k+1]].
  • jj - The second array of indices in the sparse matrix representation. If type is COO, then this is the array of column indices. If it is CSC (resp. CSR), then it is the array of row (resp. column) indices.
  • x - The array of nonzero entries.
  • type - The matrix representation type, of type MatrixType. Available types are MatrixType.COO, MatrixType.CSC and MatrixType.CSR.

cholespy.CholeskySolverF.solve(b, x)

Parameters

  • b - Right-hand side of the equation to solve. Can be a vector or a matrix. If it is a matrix, it must be of shape (n_rows, n_rhs). It must be on the same device as the tensors passed to the solver constructor. If using CUDA arrays, then the maximum supported value for n_rhs is 128.
  • x - Placeholder for the solution. It must be on the same device and have the same shape as b.

x and b must have the same dtype as the solver used, i.e. float32 for CholeskySolverF or float64 for CholeskySolverD. Since x is modified in place, implicit type conversion is not supported.

Example usage

from cholespy import CholeskySolverF, MatrixType
import torch

# Identity matrix
n_rows = 20
rows = torch.arange(n_rows, device='cuda')
cols = torch.arange(n_rows, device='cuda')
data = torch.ones(n_rows, device='cuda')

solver = CholeskySolverF(n_rows, rows, cols, data, MatrixType.COO)

b = torch.ones(n_rows, device='cuda')
x = torch.zeros_like(b)

solver.solve(b, x)
# b = [1, ..., 1]

References

[1] Nicolet, B., Jacobson, A., & Jakob, W. (2021). Large steps in inverse rendering of geometry. ACM Transactions on Graphics (TOG), 40(6), 1-13.

[2] Naumov, M. (2011). Parallel solution of sparse triangular linear systems in the preconditioned iterative methods on the GPU. NVIDIA Corp., Westford, MA, USA, Tech. Rep. NVR-2011, 1.

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

cholespy-2.1.0.tar.gz (59.0 MB view details)

Uploaded Source

Built Distributions

cholespy-2.1.0-cp312-abi3-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.12+ Windows x86-64

cholespy-2.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.12+ manylinux: glibc 2.17+ x86-64

cholespy-2.1.0-cp312-abi3-macosx_11_0_arm64.whl (976.8 kB view details)

Uploaded CPython 3.12+ macOS 11.0+ ARM64

cholespy-2.1.0-cp312-abi3-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12+ macOS 10.14+ x86-64

cholespy-2.1.0-cp311-cp311-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.11 Windows x86-64

cholespy-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

cholespy-2.1.0-cp311-cp311-macosx_11_0_arm64.whl (977.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cholespy-2.1.0-cp311-cp311-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

cholespy-2.1.0-cp310-cp310-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.10 Windows x86-64

cholespy-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

cholespy-2.1.0-cp310-cp310-macosx_11_0_arm64.whl (977.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cholespy-2.1.0-cp310-cp310-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

cholespy-2.1.0-cp39-cp39-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

cholespy-2.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

cholespy-2.1.0-cp39-cp39-macosx_11_0_arm64.whl (977.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cholespy-2.1.0-cp39-cp39-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

cholespy-2.1.0-cp38-cp38-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.8 Windows x86-64

cholespy-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

cholespy-2.1.0-cp38-cp38-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

File details

Details for the file cholespy-2.1.0.tar.gz.

File metadata

  • Download URL: cholespy-2.1.0.tar.gz
  • Upload date:
  • Size: 59.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for cholespy-2.1.0.tar.gz
Algorithm Hash digest
SHA256 13d069270fcdbb364c1db8ebee877b7d5be0b4bac00296879ec5cef1317473fe
MD5 f46208be00f7f22efdf5628ba2343372
BLAKE2b-256 a9f99379a33e23e14eae7bc011b4aac83875f7201bb7afd29fc12fcfc21cd2a0

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: cholespy-2.1.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for cholespy-2.1.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d851e3d249506caf7d1e8af7942143c3eb0eb1721a26e558900df35415a1ef93
MD5 694b235483744a7cc9f84dc4806a2feb
BLAKE2b-256 db1e748e3a3725188bc28161ebd96695c2f383260f4696d6edad3b92349aa3dd

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b3394896e7bd27df73e95b321d80983cf02b9e7d7bc5b1113b22505383728bc
MD5 28dfb3c53c5ff5e775b0686765c317e0
BLAKE2b-256 f7f4957d9c22278281674ecdada12a1788cfa760f4548a655dd95eb181444b81

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a592dbd0cf46b1afb96187d65bb50a83b7b8c85e7f453379ec912cb1f86f5d1
MD5 11a351a2cb0b72b7eb71b4df9b92701b
BLAKE2b-256 458096ae0f967d79ae05f14781b26cb389c80b7b3b8646172c17362e097fa44e

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp312-abi3-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d8eed87977dddd1ee8bbfb4a34772ad34d173536ae77bf1532964659b78a4dbe
MD5 9649b3ba133d3ae9e74647933ea574e4
BLAKE2b-256 f693b7029ff7f05f3d353d0f8ab590012bb45b4678636e3d23ddf676aeb94a98

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2544f97928e4d8f2aaee51f253c7d55fb3f202bcf95b463d989838731a49c5d3
MD5 c1d1ae461fa58f0ed2a4bc32d7af29e5
BLAKE2b-256 1f886cb8517872f40a532c7e948433db5084d801ba7580e87f6c3642ce351b71

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e197b4db52ce68e4290db7269160ac29fa0967ed6e2f455751251f378783f6d
MD5 b923bc653d53397eed0ef2ebee9c37f5
BLAKE2b-256 f3907c4c5b68fbbb4683c75971a52c2630cb8058460d49c6dad8a15104274b7d

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a762eb52259ad5a38eb22bf72a0e311afcffcaf599da1169ef04e42d9b28b4e
MD5 2d037125c2d812bc4a1a2cdb4da29b8b
BLAKE2b-256 e3a69d3c92111bbb333bb81a28205095ade1f746a25772ab8e02ecdbf2665865

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ca3e921e0525c01e990761a5372f4a434c319c9ceb0bf53ddbf5d744236a4604
MD5 bc85ea99b3371c7cb858add7a868d33b
BLAKE2b-256 483f916b56cf5440736a23695cd8fdd2cd3589e2ce9a472f8b715f90868968ba

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 983617a4b5b225a605276253303a524d4c1443f507bea296c10aa2840d6d7f3b
MD5 ac8e2ef28471939d1bf9f4468fa08e28
BLAKE2b-256 a52673a2550a5feb616bc49a11d7d13e5d38beeaa8708d13d226fd6610f5d2c4

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d04c5830c037e3604d16b48f8c2bd793671d2bcee5b1e3da4755b3d5a4078e1
MD5 1d0a922331c455410604b15649104025
BLAKE2b-256 0fe9889fc88147736716febcab23c7ff41fced1fec90d922eaad42b749772689

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 315a5d3361a89ea6b4154379c015bf45005f47acefd239257ee49e7e0fba5a6d
MD5 78c6c69985941a8e874859321eb5cd51
BLAKE2b-256 8ade9f0c4d06251a65482b1c04f5988c6e156811d1cffbd59d36faa12222e1f4

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d6128f1c1fede81b054cb2ba09cb0b45ba72619cf0c8ec4dab2a1a522b695314
MD5 29f69ef2a1d9394ee5b6d3ac60a17b0f
BLAKE2b-256 6404a7623b76c611957076adf21503f196257d8c4953abe49c7e8f34114b616c

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: cholespy-2.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for cholespy-2.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1664da55c499e65d90ed075f10ce604936783d8e73f1bc2c8a47be3b6e2ecd06
MD5 d3093ba2c0107987e9a6d4108f895393
BLAKE2b-256 07126cdcdb1923ba9230fded44508692ddf1ae91ab2244b78d5c270b3e73d49a

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e26a87cf2f9d4e4b5eb405db0ccb455740a46ef77c63a29e3b0d25a82e98825c
MD5 fd0c64542e6e9141566209fa1cf09ae4
BLAKE2b-256 7f870c199eb7582a89bd720d6e788ef771cf1028e33dfb7872c1d9d0d30b1100

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca91a83766d4e206365c2732a66d7f072f10c22b6a74f92c121d3a3fb4ea1062
MD5 37df1656a5a2424cce6eb9a0bd80965b
BLAKE2b-256 0e3c3edf4387ed4f749ed432152b7be8490ad2524582b93de714348bdc9055d3

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0a9a268af93f804083f2450d2f7ec28a9299db82332ca6d1948077bd4811a223
MD5 49c620c6b71e37b8b46609a7bd6b9682
BLAKE2b-256 583841aeb9298a13b3fa9978976541c38cf3603f0a107c16832b631b5e31a02a

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: cholespy-2.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for cholespy-2.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dab5f76bb0f23d378a510920120e8e14834d690a5a25d14a30f6b4511736b7cb
MD5 09994f1cd27d9688d81a2576084170a0
BLAKE2b-256 565e09c8d9493609fb952637686a9d7ecb079f62144d30337b844d4f039443cc

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f069c30a64f20e73ff07e67f798ac6c6e56efb34b80ad30f1ed87272393340f
MD5 838e725c8ccff388694d1c78812a25dd
BLAKE2b-256 85387ed718d2e42edcf8a59dbc6f07052feea9d81fec1f11f1fa8231c4682f65

See more details on using hashes here.

File details

Details for the file cholespy-2.1.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.1.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ad8f23e6a0d381eb1bb5561ba336ab4830f4a51ac1245253103512b3773f767c
MD5 5ac726cebd1e367a927341c73d451a7e
BLAKE2b-256 026fedb4147340830e9f44f5c1106f5a9150693e9fd48c9eaf9067e5bf6f7790

See more details on using hashes here.

Supported by

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