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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

cholespy-2.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

cholespy-2.0.0-cp312-cp312-macosx_11_0_arm64.whl (976.9 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

cholespy-2.0.0-cp312-cp312-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12 macOS 10.14+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

cholespy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

cholespy-2.0.0-cp311-cp311-macosx_11_0_arm64.whl (977.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cholespy-2.0.0-cp311-cp311-macosx_10_14_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.14+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.14+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

File metadata

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

File hashes

Hashes for cholespy-2.0.0.tar.gz
Algorithm Hash digest
SHA256 eab218ff7f231e48a37f221f5d9e9d2d82eb0823141f72438bacdaaf6988c4d0
MD5 f0c56a79cc7bcebbbd79596cb4d4950d
BLAKE2b-256 6747a186f747484fd46ed3e448a3a25526b8958d8f2280490413c99d31a15253

See more details on using hashes here.

File details

Details for the file cholespy-2.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cholespy-2.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d9cd6da270548db3b797bf5a856abf7342ba0b5e95b07eeebd1d63ad01e993ad
MD5 55be0135cb0adc8854cc0b5c3572de40
BLAKE2b-256 14fe106c9d37eb4df42eaade1fa70f5f92a942ed309c778f98e22fcc78b9e693

See more details on using hashes here.

File details

Details for the file cholespy-2.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40b058cb8829ef02b0b40f777aba7d9ace958ad695a767fbff9a4551bf856d99
MD5 dc7fdb96bf4c1e01947b4c98e85ee524
BLAKE2b-256 799c597dfe922c3b73b224f1ae43a5de755d871201348285c60bdaeca2cb8dc8

See more details on using hashes here.

File details

Details for the file cholespy-2.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholespy-2.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d8910d8acd3f69427861b855694aa7cd8066b675e700f98b78cd0e1d8d6c4fa
MD5 16d40b0ae0e9d7868119d60404e82e58
BLAKE2b-256 7f2fc185961608715a7d22580aeeaf8513ab9d8f2357b2c752080fb5e86a33a4

See more details on using hashes here.

File details

Details for the file cholespy-2.0.0-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.0.0-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 17c953641c7ab36bfd1a9dbedaf122a6273872bd8659a6676cdc29bbdd7db6d8
MD5 5898d5faedbcdedf4ce1e98204553649
BLAKE2b-256 fa5b1d80417d5181aa62326313c5560e151733db3f343a311579c4bb7ce6cb3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 90affc0689dd3c74bf4723b4eaefd7f071f497853ec92dd8956d87a210b3dfd1
MD5 c56096b514269e9795458849f458181b
BLAKE2b-256 d8d2aef42f93ee64da1da3441226cc904fff0ce7f7defce643b15fe6f16392e8

See more details on using hashes here.

File details

Details for the file cholespy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cholespy-2.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00d62ad01a2767c75c76174a8cbf363837c817d38a69537eace3c7c18185f3db
MD5 d15ea0d3f3dea8cf9a56db76172dbbed
BLAKE2b-256 a5c43bee8fdd6f83e06b92822d2e28d944ed1f508746a84e495f7c6bbcb8bfc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3672ad21c86f27802aa52a8f53c0a8a00e65cd0ba948d837eab8029c75513232
MD5 c55ee8ca522f68958da36604f7ae3673
BLAKE2b-256 5f1e4f07c385fa88c1059299d44eb484f7655ea60ac8fdf50a3cb8d0769807a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d0f0c88b05b1dd199990812e97b0e8c610b4f7f3fffad95ebd4e37b430dd2695
MD5 7d78b7bf04d4bd1c02216687bb1d3d88
BLAKE2b-256 4ceff3e75d7536837576f1ff90a7ed888d228997c4fe9d38bdfe155cf8b071e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 060fe06bb0fc7424290beb9c5126438a6270bdff8922bb4563923397d4bf7b03
MD5 4d299613f44e7d27879bb5c9e83daceb
BLAKE2b-256 efe43bb6a9dd7fb86763ae409e4127e10da5405aea7105659ebeb38c70364873

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f35fa8eded6be6d328e0242d5807f2a6fdd91a27fabb6607870305a2dd0ca1a4
MD5 d0464d5899ddc55ecf5e8f7dc502cd27
BLAKE2b-256 ae10ee5a666b1cb76fb8cff0b31ffe4dfd1d7d622a0329c60de96399e11842a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d392d9bef73b374c43a4b83565e68c59e4f224e86eec181b616d66c71c9b616d
MD5 0f6922374840078322ed20a9f4169539
BLAKE2b-256 ae8e53d73e928308d3e8b15f5d68d1f190e898483436c98682b6d0ec665a0357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 76690de4d05e5800d2243f117c4464f3eb34d1ae8eebba033c37ad8a05b33286
MD5 eff2da61019dce1001109f505c5bff44
BLAKE2b-256 58fee902ce3d427d4aa070ed494fd19c3027082d45c4b90751c98a75f053ca58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.0.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/5.1.0 CPython/3.12.4

File hashes

Hashes for cholespy-2.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3fdc01fc87e97b0e71c191921249fe5a63a536d9fbc32f6b8e8dadfeee57f627
MD5 40f3f8051d222fb64e5fb95b181dfd1f
BLAKE2b-256 fd1e2733d027999b3256f5727a704a0dc1466866eb4cb5e8fcbaaa72d250689d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d30188ab59061ed8ab38351c219dbcc5336d4fecccca41204c20fb99062704cb
MD5 144b77fcd02cf581fc2816422dc65169
BLAKE2b-256 a918b0f50da582b32ccdafaf8112ad3a235c1ff805a5da8314f2ded8de2aaef3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d03f2480d1db30999757679b273fbb0fb4ac3b7a09976561d9dc91fc6e29d9c8
MD5 5786d95480898aa1bfed1c218c852e29
BLAKE2b-256 c7fbb272428f8e68cf2e0b6a87ea1c082fe5da3928f58c556b1ee641825ee301

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d89dee0dcb5f50afcbf7ed52b8e6bec2097d4c3b658b8523603e4ac925b97cd6
MD5 c810c8f57421c381682051a3f64921c8
BLAKE2b-256 4eb78aecb4c52297916a5e4a0c6549940913a84ba6b5562843f0c4f1245c24b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cholespy-2.0.0-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/5.1.0 CPython/3.12.4

File hashes

Hashes for cholespy-2.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 473447b77f606a2babdb9cfeb41197fdcc9e7f593ee59d90a89be2fa49bba6ce
MD5 47f82c2206f28fbc9bbcbe33b48684a9
BLAKE2b-256 14d1d85502376649f265a0442b31fb1185c0f40275deaed65f5da543a2f3ad6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1582f5f9cda29e0bcccdeab3567260b8596feadf6c503ee8bce8fe373b5c0f4a
MD5 1279c3a96047d3c80374cf4e04c41fdd
BLAKE2b-256 03957dbda66e3a5c6d25f607f59452477d2eb5a93945b5d20434d09ad679fec0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cholespy-2.0.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 62f3bf6ca2033ced5c3ebc308f39dad7148ab80743dfa9c5dc58c13ce5e47913
MD5 ba99f39862ac22033568ca1b21e5d9e7
BLAKE2b-256 10d0772bf5a3a4d5996f8f5752d573aabc2a5b3bea33b50a5c7a40ba257adeee

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