Generic conjugate gradient solver that works with your favorite backend
Project description
PyConGrad
A somewhat optimized generic batch conjugate gradient algorithm that works with PyTorch, NumPy, CuPy, and whatever other backend you like as long as you code it up.
Heavily inspired by sbarratt/torch_cg and uses similar function signatures.
Installation and Usage
$ pip install congrad # If you already have either NumPy, PyTorch, CuPy, or your backend of choice installed
$ pip install congrad[numpy] # To enforce NumPy dependency
$ pip install congrad[torch] # To enforce PyTorch dependency
$ pip install congrad[cupy] # To enforce CuPy dependency
from congrad.numpy import cg_batch # Or congrad.torch or congrad.cupy
X = np.random.rand(100, 100)
A = X @ X.T + 0.001 * np.eye(100)
b = np.random.rand(100, 10) # PyConGrad expects matrix equations, so the rightmost dimension is for batching.
def A_batch(x):
return np.matmul(A, x)
solution, solve_info = cg_batch(A_batch, b)
For more information, documentation, and detailed instructions, see the examples folder. In particular, notebook 2 shows you how to use a different batch dimension if you want to batch over vectors instead of matrices.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file congrad-0.0.5.tar.gz.
File metadata
- Download URL: congrad-0.0.5.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd56d6a361f320d4f81c99dbcaa418e419d2dd745ea89ebf3d8bf895ac60ecdc
|
|
| MD5 |
e826e7276785d95f082d9d50b8424066
|
|
| BLAKE2b-256 |
b065681db0467ba31e7e4d4ac7f53a812bd9b38d23a291b78359a1336f3899a9
|
Provenance
The following attestation bundles were made for congrad-0.0.5.tar.gz:
Publisher:
python-publish.yml on PMKielstra/PyConGrad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
congrad-0.0.5.tar.gz -
Subject digest:
dd56d6a361f320d4f81c99dbcaa418e419d2dd745ea89ebf3d8bf895ac60ecdc - Sigstore transparency entry: 192121933
- Sigstore integration time:
-
Permalink:
PMKielstra/PyConGrad@f6d42d10c5d0dfdb792b22427f1c134615adb3e1 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/PMKielstra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f6d42d10c5d0dfdb792b22427f1c134615adb3e1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file congrad-0.0.5-py3-none-any.whl.
File metadata
- Download URL: congrad-0.0.5-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac5e56564907f367e4b3c180312510cb1e7b801054a87b851d6750d7e3332df3
|
|
| MD5 |
a1b4b1bc64227dfcb81616a45e12ad9d
|
|
| BLAKE2b-256 |
5865257bfc0c08dcf59efbc9eac1396add8f94a6ef46846b484acad63252e100
|
Provenance
The following attestation bundles were made for congrad-0.0.5-py3-none-any.whl:
Publisher:
python-publish.yml on PMKielstra/PyConGrad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
congrad-0.0.5-py3-none-any.whl -
Subject digest:
ac5e56564907f367e4b3c180312510cb1e7b801054a87b851d6750d7e3332df3 - Sigstore transparency entry: 192121935
- Sigstore integration time:
-
Permalink:
PMKielstra/PyConGrad@f6d42d10c5d0dfdb792b22427f1c134615adb3e1 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/PMKielstra
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f6d42d10c5d0dfdb792b22427f1c134615adb3e1 -
Trigger Event:
release
-
Statement type: