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

Uploaded Source

Built Distributions

cholespy-0.1.2-cp310-cp310-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

cholespy-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

cholespy-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (183.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cholespy-0.1.2-cp310-cp310-macosx_10_14_x86_64.whl (220.5 kB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

cholespy-0.1.2-cp39-cp39-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

cholespy-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

cholespy-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (183.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cholespy-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl (220.5 kB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

cholespy-0.1.2-cp38-cp38-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.8 Windows x86-64

cholespy-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

cholespy-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl (220.5 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cholespy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 db67c70ffc1167c8744f8634a0a6fcca9242e62cb8734ec7a7bcca8a98dbd88e
MD5 76be3a909e19281380db4211143bc141
BLAKE2b-256 a0db3065d30f1a88c1f3925b69a7357fdc719915b90d3221a8035b1e5cdf7347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 88ee18ddeafe3c497c9639c4ace1b147ed2364f93b9f9fb7aaf8c14ea0085d71
MD5 d1f1c374c23128667829c17636e9d6dd
BLAKE2b-256 5119d8eb1c535d3b29c1cc36d24c4138a014e28fdd46f9fe85beb57022464229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1632565779f3232e9529fbee17246283687bc27754d2433dd4656d66ab7d7477
MD5 47f6d53c6e0d9cca05a02767b2f2db44
BLAKE2b-256 dfc80437fd32bbc520c657a7c34fe3fac33d077e1664ad01f6dbb43734ae4dba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf18a61e936c52d3d7430f8c0207713dc8bb3a91924a782b7a155651ade0687d
MD5 0c1060b06ada9b40d73def627561e85b
BLAKE2b-256 d0f38a1a56b055ebf664996cfca66eb58cd0b88d800c0a4aa58deee6a611f01a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b7dc7555850d47c819c358c944e323e9a9fa873aa69ef84e435af8ba1269b8ac
MD5 8cbd5a9283c17ad2896386883b562709
BLAKE2b-256 4061b3fa882347a65171f20e4ecd6bd6a89bfb7689df60939f489696bc1f605e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for cholespy-0.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e096d49a247dc77a09e8d82d480bba6b284edb5864242861bfbae4ae8b60090b
MD5 54fed46a38935cecadecbf9b16e665aa
BLAKE2b-256 a56450950c9d728cfe634926d3d6f56109fc7b3161a3adefc01ab38b831891bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 400c092aa47a0f710aed0bc15f43efa446410a74ba539ad9af3dd1ecf1f2891a
MD5 268a7580f1af16949da6572896ba1600
BLAKE2b-256 2140dc526e96aae25431592b3ed9808ad6e89192162627cfcef09e8979cb0c26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dfd971756061f844d71eba543d8e65ef45f659822ea138d8a09b76a427355109
MD5 75f63eb39a9fa83b508e37174f7b1219
BLAKE2b-256 9099dd052120e21990cdfb72c4cfa6722d6ec8cbbb33760d7d0db07aff0fb5c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 949e7c868d8103fb53f383576f525df48f317e098f7d063613e4227a90181d50
MD5 c011d46dc590469a80c90959181eaafb
BLAKE2b-256 51b3fed719f7515ca9e7a5c3b79db50aaace98e18511e4627a4c995c6217baec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-0.1.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for cholespy-0.1.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 60ad3568318c01c778316e24958a45ee977048e1f3a456ba50421567f371be9b
MD5 2929cdd9cb2e9cee978fe99ee2311b85
BLAKE2b-256 e8c3b698df4e5899eb8509ee392118cee4b965dd1e6ffc5135018733feecde89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 85c7ad8a97f6f351108c134dc97e0f77e491086ba0d31c58ee22372909547072
MD5 6d651070e2db766120c8917a0f67ec0a
BLAKE2b-256 ed5854654217c04657d3175f05b8bbfaced6cae69d1a1c567ae7b831b5a05ca5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-0.1.2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 177fc1baed3f381078e8583bb2bf5f1943d8f0ae464039d85626a6ff2d88f7c8
MD5 8ba53e298d682a5fafe498f7944c4be5
BLAKE2b-256 231b667dbc57b84cdcb1f45305225c3d74a378bdc9463143e3df62d7e7819569

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