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

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

cholespy-0.1.3-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.3-cp310-cp310-macosx_11_0_arm64.whl (986.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cholespy-0.1.3-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.3-cp39-cp39-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

cholespy-0.1.3-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.3-cp39-cp39-macosx_11_0_arm64.whl (986.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cholespy-0.1.3-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.3-cp38-cp38-win_amd64.whl (4.9 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

File metadata

  • Download URL: cholespy-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 204051c36a19363862bd400bcabe93e2a04f97ad70208a6c187d2b2af2909d2f
MD5 de1501844870a684ce46f2ce4e4fda2a
BLAKE2b-256 589ca4cb35d842874799202d489d083d43d89726910c4a140075e6a414cb4afa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 83a43c89f22e6502bc325d99f1f0ab6e097aca52b2a9a638d0dad2e70a7fac49
MD5 9ae558bcbfaf67d40a31f9bb5a131494
BLAKE2b-256 e849fd6b677158285f5bc22c39f9c4922beb0d7d96f69176b90947359a7c0d3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cdfbbf0e73d5f05baf895fb7072451beffdb0ff7f1f2d917ed0489fe6909f096
MD5 08ec6c65f47b4b9d2bb7c46241d89b80
BLAKE2b-256 36b79f3d9dd38537fe9dbdd2ab32c5d1f06d18fcdaf43bae5ad92ba795ee1adb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69fb9df2beb520eb8a56e2e8cdf50be68f2ec02a1f93ae5d0273d9ec1c6c9618
MD5 8004ce8d33fff23df18a3d8abe34340b
BLAKE2b-256 a73455e909beb48abc7b46b3155caf0980f22fbb1cc5b1e2202e7e79c7e4f306

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 39ea9c69d50e7ab694a119cf2ec6576ac120468407d838869b916f30d0690e14
MD5 3279898a3bf3f77bbe12a85e3761d035
BLAKE2b-256 b496013398da2b45a92783cdd5b444853e55d468deb01ec64ca54032e0e05b03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.3-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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3f56f01172ca5b0ca49d6836a333a340075d8c13db76ba8d2a523a02aa15ea9e
MD5 818e6e92b9d5e379bbeafec8891a99ca
BLAKE2b-256 b2ee5d3c3a47768f754c47d9e27383f1d0e690b54733d1d95e12b751ec4a9031

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b31d1ee538fbafb18182eb3396e33fac555a0e2647df4c67c3db3caa3a7cccc7
MD5 e00cfbc0ae2ac9de723156dd7d5144ef
BLAKE2b-256 c86a6274dbe88d9a99fe2faed4b37da00233b26d7f61ba8f5beef19361adf5d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3fa996ef0514df6de5ea307145cb7289eacef8e0a7b91d7b1d51c08126773d64
MD5 a496f23f7680e9519f9a534906f44219
BLAKE2b-256 05f978cd22e3667b5d8c0a36d9d3637f05bf19d7c08503f80dbfd27cc4353263

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 eb44de9a3ad4d30721feacccdb5e230689a35bf9e3c07f25de08abb297d3c892
MD5 ca9db6e2a89f92872bf36e52faa8acb6
BLAKE2b-256 28e8fc626dab7c5566de63f42d5e3de085774bf835343c7f8b4ee254707ffe6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.3-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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f306e9623fb9295266407b470708c0a57e328b582a0098a0bd25769410a5b284
MD5 3fc21b9bcedbde4996c51846b5ca07c6
BLAKE2b-256 24e65e3fd15e1aea768ebe6373ba53344a69494776468bce5e3c90b2475324fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c544fbc547e573e8253abc50f76532cb717a030329e6b1a6242d2f96ea20d91c
MD5 9cad4c810e3eed4f61e2bdb260272da6
BLAKE2b-256 70bd591933e08405c8e387478df167302756e553d702e0fbe1cbe12ec89f1c75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 6f406bf0b9e9e2dc25470ca8c2d24e29b200f1f2a416c2ca022514e915739916
MD5 9d4a920096661dd6fbe00fc37e980e69
BLAKE2b-256 966134778f2edd0601fed48fe0f57967d2f2fdb7a875440c75090e093e0febe8

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