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 CholeskySolver64. 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-0.1.4.tar.gz (59.2 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

cholespy-0.1.4-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-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (986.8 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.14+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

cholespy-0.1.4-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-0.1.4-cp39-cp39-macosx_11_0_arm64.whl (986.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.14+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

cholespy-0.1.4-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-0.1.4-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-0.1.4.tar.gz.

File metadata

  • Download URL: cholespy-0.1.4.tar.gz
  • Upload date:
  • Size: 59.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cholespy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 11d079fc20ac389d5c04b19ddbb212ac06bc1a9ee48f69b3d1e51cc8930c257b
MD5 7fb543500418c7d3944b3f6a0967d3e7
BLAKE2b-256 e65c7085912e0782697adcfda2d9170e02e0f24687b495a91caec71c0cae7018

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 571a26cad925ece14e3416e86ff1c1cb1769ae2bf831ccfc8b3f3f8fb3ad5e57
MD5 41c931f8876ca2a756e2a85fe39c86ee
BLAKE2b-256 557128c666d2072cb3d38ee0a8951b81bf9208d28cc08b58e84970580b76d930

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a971f572aa4d8136951fd394d0781edcfc1239493c8849c4e2c7526bdd866ff5
MD5 f3b4b232c7b5cdfd82ad65c0608984c5
BLAKE2b-256 1a8e7a0faa3c5dd6f9816deeb44449b4960134e0a2917fc4512800a4d6835ead

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14ff5a3478f3d6bdf43a37d1511810c273d341ddd990c35030af47195037e239
MD5 27c60e76b69d64767b1a64e2c2358655
BLAKE2b-256 9789181d80d06a215b8b79c7c7ad7ed1634262fff2d446e04b7af07789b43d13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1721900b2121cd4acb9b1dbd6c459fa131a54e8016849351d98a74eaca842a5b
MD5 034f8779d04b54638e9ff746ceba8a8e
BLAKE2b-256 9d6548f98c3c0ceea8fc64c6e369d98bc3ca312fe3bce5d5398de31383a1150f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.4-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/4.0.1 CPython/3.9.13

File hashes

Hashes for cholespy-0.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d447b675e821afe37a7088b7fd7ac21c6afc25cd4bda9af169cbd98f90220686
MD5 5681001498cce406f413c55fc34614c1
BLAKE2b-256 5115e9c04085e584bd48b1b003138320837b787a1288f0b0a9690274c9ca3ba6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 229407f0d5f52e09db91d85eb591ac65be7eb92d9cf74dac8f60387e74c11ea7
MD5 94903ca73ed2c2bf0053b42eaa5e24de
BLAKE2b-256 3fd46545e6c435a0f56ba050955682d26efe16dfea3a1f4efb7ab99b7224c131

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9e1a14ab829222a405005d899c9eff1ddd2164a64ec2fe1f7fcc6341f330312
MD5 070844247d05a26948eb452d3f7b3d51
BLAKE2b-256 5f444a5e0c8d9c0722c06b0217f1876844f081e1e1475197f14df875873366dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a01138019ffd0a77ebaa3551fee9ea7d6ca81d7a673d45aabef8c5fc2918b40b
MD5 453e2f28703f579c2d0966d9eb5a2621
BLAKE2b-256 3754cb0c82f0800205b78dba236a0ddff5786d92bf12b837e1ced52f22071f9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.4-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/4.0.1 CPython/3.9.13

File hashes

Hashes for cholespy-0.1.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 72cef74d940109580b32c86862cdf1baa718dea14b52a24e98e125c903fbe1d2
MD5 73f0067ee4a6b70b081bb7f2ea5cf3f4
BLAKE2b-256 2d92d74cca3d5ed70e2757240217a22bf97b4b3b2478d7793d2432012c3fe8e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63abb76e966d9b3da2a658c2627875b9aa52f96c7a337e052798d755f6f45dbf
MD5 70e674960debb9878022461301b1d65c
BLAKE2b-256 7fad228ccc91170ea7cc9c42fab9d65ba1dbf7ce824da50a97dbb01a451ace97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 02b3c09b8d6b5848fdb72e6ae767469f5d94305b307ed52ffc811aaf4505be63
MD5 d3dee7b0f0f9939b2837620899404e4a
BLAKE2b-256 5e958578387b953c1943cbbd6080e007ba0cde6bedea80028368a04cbf21ab22

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