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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cholespy-2.2.0-cp314-cp314t-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.14tWindows x86-64

cholespy-2.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cholespy-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl (971.2 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

cholespy-2.2.0-cp314-cp314t-macosx_10_15_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmacOS 10.15+ x86-64

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

Uploaded CPython 3.12+Windows x86-64

cholespy-2.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cholespy-2.2.0-cp312-abi3-macosx_11_0_arm64.whl (967.7 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

cholespy-2.2.0-cp312-abi3-macosx_10_14_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12+macOS 10.14+ x86-64

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

Uploaded CPython 3.11Windows x86-64

cholespy-2.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cholespy-2.2.0-cp311-cp311-macosx_11_0_arm64.whl (969.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

cholespy-2.2.0-cp311-cp311-macosx_10_14_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

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

Uploaded CPython 3.10Windows x86-64

cholespy-2.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cholespy-2.2.0-cp310-cp310-macosx_11_0_arm64.whl (968.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

cholespy-2.2.0-cp310-cp310-macosx_10_14_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

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

Uploaded CPython 3.9Windows x86-64

cholespy-2.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

cholespy-2.2.0-cp39-cp39-macosx_11_0_arm64.whl (968.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

cholespy-2.2.0-cp39-cp39-macosx_10_14_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cholespy-2.2.0.tar.gz
Algorithm Hash digest
SHA256 4f12da345d318013f386b0a1e6e0f5e63893ab30ff9ecf8ca50e121b85a58125
MD5 8c2f636cdf80ea1f63979c44a1394707
BLAKE2b-256 9d786900f46f4a8627dcbb0406cde5a4e00159f034a6c6a8811770145a36a2db

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: cholespy-2.2.0-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cholespy-2.2.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 d2a1acdf8165d75009216eed18b36d361b9933ff2f24b38935e24244ec34e85c
MD5 4a33c221beacbf08880a6e92fbba877b
BLAKE2b-256 07dddea75e2c94707a90aa1cc48485c5c3ea1336ffc778a181313e7603ba8373

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1db1e21db352fe116cd318a135f823a0e63c1c83f38104c3567dd03f92edad0e
MD5 9610ab5179ab92e22b27bfd0534e1fc6
BLAKE2b-256 983f70f37fd6141ec7c836834556f1fb7a7f549f284d18638fb6425499723deb

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 960950b4cc8dfdf0dab580452240f6d98d3f27b95aa0e2f638360d12b9c9ea10
MD5 e136ce03c77d4c1a2679a2455dcaa755
BLAKE2b-256 96a0a1ea4db30ff9545a5a922110ec95d945501c8029ecfaa78fd08b8a11e1d5

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp314-cp314t-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp314-cp314t-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 18bf86cb04533901b114d407aed2e44a517f21429ee5c9b47746b5fd0f624e0a
MD5 e8c65299b2d59e13c7498520dd268e93
BLAKE2b-256 26b80c78ce56976c46b23ac7e65d6f0186ba70b391cb538561bf642133da9998

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.2.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/6.1.0 CPython/3.13.7

File hashes

Hashes for cholespy-2.2.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 deecc02df678e51e7741667b1b47158663496ca893cf2f75daa34b2520ebbe65
MD5 c3095ca1f64e02dfd0e362bc38fad323
BLAKE2b-256 5b466e073f0247841e62f2d4643ba7eec61365295e4ff632ebc283c5946f3063

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e32e9760380a3804ac6da150ac4eb7e5b4554cfd3b36d437fd819c17e1e9317
MD5 c7f58a4cfd5da22d63fe74ae6afffca5
BLAKE2b-256 8494b2a491bbd74386b2301ff8c3a33957261404f866846645e699b7611c65d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d32daeb91a40025c92a8ce51c12044fa616749ed37b177935b62e761c8fbe53
MD5 59b760de46eddc9597d3b8a0f996970b
BLAKE2b-256 d340a300878fcf6cccb667228f1b45dd4ecd1d04d1ee01daa76f2c9ab79ce2ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp312-abi3-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 90af005b75147b0119838c24e7c36b70af7a9643644a3f3e62780b0b50b55978
MD5 54b9f33313c03f82d9d2d00a137d1010
BLAKE2b-256 bdb3f573bcd0a7d8cb8413d988c60d2dba754bcf47915cbeae0971c54966e9f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cholespy-2.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a4f13b70a03cb6e7929496d469ba409bdf672323f097641381a2c4092ad3204b
MD5 f6d0e2810c2528468a7974f3d338b03a
BLAKE2b-256 cdf605508ee258e9650ac650a86c27a94ca411207762054cf220c5be5b4a9fb1

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f19dc5fc30b053a4d0749371b161059eacf7a95496eecd33edc494a4d28113c
MD5 6f557adbba3b0155265d756058d8313d
BLAKE2b-256 35b5df31b615d58b75eb1007cff061a9c48f7a2eb37bdd1fdd15354823fcbafe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9980c19be21a2707e76ffb1a27db20cf6fa3af800115c534d8c3a83ae42afbb1
MD5 a1d313aabc5458bfec8b4f5ed4a5b05b
BLAKE2b-256 eb7ee411c09928839d6c755d7bcf53dbb856f18fd966ae12971aa6a4b61aa5e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 74d85d00fb2ba2d7fdb766defcc083071f1f377f9faf91a271a53c0716f0ef74
MD5 e57f7cd9117c631fc2de6407e190cba3
BLAKE2b-256 0c2b2c5f48e0005695aa0b99af8011c2ae035dfd8c14b6a836dd64d505a7f5c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cholespy-2.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8d0e6c0132bdaf7e20dae81e39ce7b20a1cf84b1f04e66d72974dac30e618a7d
MD5 b4429adac0f500aee42d46b1a1b70022
BLAKE2b-256 accc543d6bc039dd15278f796b07a1546b31733ef9ce4c6a9c9ba3ca6bf22846

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c041beedecd276772d13abd2a48f359b60956a5ac171f3beff3abacf9d21a64
MD5 52eb7b8d798e60587c78c67411d15b9e
BLAKE2b-256 bd3caa633135f367a106bef5d86ff697da6c6653ad8b6ae2f2010dbcd20ab84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 df5a3117dea5c027a3322b4337f7f3e76cbc47fd3ab8a5182c15f2290775f97e
MD5 df405d19a1390703361b0da477960c54
BLAKE2b-256 647c152b74db45d97ef0645ce783380c31129e8f9d0ea933031b4294677d4a05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ccc618bca1406671b43a7eff23bea63f69c720edb75f22831a8c4bcacc0f7e45
MD5 a0b227300c2802f365048217e9471864
BLAKE2b-256 b9c12c10d184041ae8521bdb7e79e2ef849978bca5c26a0c6a37ca1c421d3035

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.2.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/6.1.0 CPython/3.13.7

File hashes

Hashes for cholespy-2.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c0ea1eb98a19bcffba2d184390c4d6665d0b69910c9de9268a0651332cc29e5c
MD5 3d9dd64de279a0ac7351a6e4ddc9c6ee
BLAKE2b-256 02e166c3957e816a542f07fa8449b10676f465f1c1f03100cf30d43b1223e849

See more details on using hashes here.

File details

Details for the file cholespy-2.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.2.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28a2f43973bb8cce12f302dc2a4837b880301fe094fba7e8aa78a771b6a524b2
MD5 2a104a632e1c332eb539c83db88a4ce4
BLAKE2b-256 56f7c17e425a271871248ee25e2de440557db34b78cd7c76ce07c7cc039bb31a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0fa9f267a7645f2e31fad87022796a45e10e3cedb494ed1ed3eb8e8156814833
MD5 c72f30f27eb4d8a58859d21ddfaf6574
BLAKE2b-256 dc02279beaf8fc0c220fd9d34f5c59a5dae90d5c0fe1fcb2ff3de2ff5d7434fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.2.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0aa579245018c6c9545e738e252e05bad3f750e4b4d71ef721d43c12323e2e4d
MD5 b23dfa925bc8acd890b5c1a151b25ea5
BLAKE2b-256 a9f5c55169f07ca6246b18cb7511ab1d91d5ad2c40fc069590f45b3e87709ea7

See more details on using hashes here.

Supported by

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