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

Uploaded Source

Built Distributions

cholespy-0.1.6-cp310-cp310-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

cholespy-0.1.6-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.6-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cholespy-0.1.6-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.6-cp39-cp39-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.9 Windows x86-64

cholespy-0.1.6-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.6-cp39-cp39-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cholespy-0.1.6-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.6-cp38-cp38-win_amd64.whl (5.0 MB view details)

Uploaded CPython 3.8 Windows x86-64

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

File metadata

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

File hashes

Hashes for cholespy-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c30e93466a4898d64357e2b36e030ec7f5f89dc074c62186ff23d0ae3027b060
MD5 75de6057c6d3394f5328a77adf50a100
BLAKE2b-256 c5b0c1972cf8abc747bd97f2e06d27dd5aa906f0964d2f8ac0f7de16859b2b58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6a48c88d9c7e47846badde143997e66d5dc8800070489514634feef5e16e38f6
MD5 4f782d161ae06970ce1a23c11329778a
BLAKE2b-256 38bf2b69ef8cec4f776a928d9a0f8164143b60aca04a66cde754ebd02435c4ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2efa6992d2cbc4adbd43b8fc75ad782c09143c24eae824592a34863f63e1dfe1
MD5 3f44b39b181c8a99116001f5871a3f0f
BLAKE2b-256 dd401daded8a65a0882daa1afec4f1cd6c08ff0d98f5a81759e18ec06788e805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f1465cb81828d1c349d624720ff53185bbe5b22335fc76cbea7ad5de65df662
MD5 b282a86c8534d487a5041b6c9b93d502
BLAKE2b-256 4366cc207335bd82d2435850ac30ecc1b1138f7eff45c7a4afa9ac706195a613

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2a1f25cbd636452c4f550b6d897be6a2e4600814ecf9a29f6f25d45d3dfc3bc9
MD5 825d8401fcda5b0ff5314b535c716176
BLAKE2b-256 57da935ee151886e04b0fc635c3df452d679291d2b6a1a11ecb570b94a1e7032

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for cholespy-0.1.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 dab68fb191303c9d0151976b72efe7c191e1092cf45aefc041186c303735a928
MD5 4fb81f2b793458250d72e638412d19f3
BLAKE2b-256 9f085c49fdab5e31b4e030a6df61411c93d18c89b6bbc5a84d8203032057e554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00a276ac7e0576375d156eb12d67336979061af73d51b2f550a153105cb851f7
MD5 213ebd75b87cd72e0f7e1cc0dadb2c57
BLAKE2b-256 26a1704efe93438dc436782a7fcfb461f71a3207a2bcbb36ef27585d5c240e77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e15d66e5ccd85fcaf6e78f33706e12fa100ded1113e2f7cfdc6a61fe7975ed1d
MD5 a5f83c7f6bb87255a385cdb19eef42e3
BLAKE2b-256 ff1768c30d87bb3b805200d0fa9c96835538c3ec414cf50d002cb50cd0848045

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 6beb6a1853bbb27f59764c74bbe866221beaae0b34d53030b57883929724f5d2
MD5 f9ef72bdfd1e835142e6217ef5ce90d7
BLAKE2b-256 922878e6707b9675d5357b9f813fae6ce80f0ef82749495980ad885758b6fa7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for cholespy-0.1.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cb04f73c10a8d7dc6840ddba13f5685e692e11180f59eadb9e7fc5a64c1634a7
MD5 fc9e412ccf9cbe47bbb3cad4f596c642
BLAKE2b-256 6c4d2f2613dd21dc13721050396d723ba764cdbfe6c21583a2b292f32cb9624a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 443a6f7eedd2d33594803c627441380a25834d9fefd442fd8b9f644f10d831c8
MD5 17ca558ab7c6cc897fba3821f4626558
BLAKE2b-256 c789f188232f8ad5a5806f42b85d204b1fa8a6121e2029c65d2052aaa989fc7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.6-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1f8749a847bb711899c4df67eb7265af3df197cf847feaed9af850cbbdc282a8
MD5 455df6ee23771dd70fc171ccde4baa71
BLAKE2b-256 4ce91063643654de60e62c9fa5f1079ad1f83b574cdd07699bdda2563a87df18

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