JAXMg provides a C++ interface between JAX and cuSolverMg, NVIDIA's multi-GPU linear solver.
Project description
JAXMg: A multi-GPU linear solver in JAX
JAXMg
JAXMg provides a C++ interface between JAX and cuSolverMg, NVIDIA’s multi-GPU linear solver. We provide a jittable API for the following routines.
- cusolverMgPotrs: Solves the system of linear equations: $Ax=b$ where $A$ is an $N\times N$ symmetric (Hermitian) positive-definite matrix via a Cholesky decomposition
- cusolverMgPotri: Computes the inverse of an $N\times N$ symmetric (Hermitian) positive-definite matrix via a Cholesky decomposition.
- cusolverMgSyevd: Computes eigenvalues and eigenvectors of an $N\times N$ symmetric (Hermitian) matrix.
For more details, see the API.
Installation
The package is available on PyPi and can be installed with
pip install jaxmg[cuda12]
This will install a GPU compatible version of JAX.
-
pip install "jaxmg[cuda12]": Use CUDA 12 (only works forjax>=0.6.2). -
pip install "jaxmg[cuda12-local]": Use locally available CUDA 12 installation. -
pip install "jaxmg[cuda13]": Use CUDA 13 (only works forjax>=0.7.2). -
pip install "jaxmg[cuda13-local]": Use locally available CUDA 13 installation.
The provided binaries are compiled with
| JAXMg | CUDA | cuDNN |
|---|---|---|
cuda12,cuda12-local |
12.8.0 | 9.17.1.4 |
cuda13,cuda13-local |
13.0.0 | 9.17.1.4 |
Details for compiling the from source code can be found in CONTRIBUTING.md.
Note:
pip install jaxmgwill install a CPU-only version of JAX. Sincejaxmgis a GPU-only package you will receive a warning to install a GPU-compatible version of jax.
Example
A minimal example that runs the code is:
import jax
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from jax.sharding import PartitionSpec as P, NamedSharding
from jaxmg import potrs
print(f"Devices: {jax.devices()}")
# Assumes we have at least one GPU available
devices = jax.devices("gpu")
N = 12
T_A = 3
dtype = jnp.float64
# Create diagonal matrix and `b` all equal to one
A = jnp.diag(jnp.arange(N, dtype=dtype) + 1)
b = jnp.ones((N, 1), dtype=dtype)
ndev = len(devices)
# Make mesh and place data (rows sharded)
mesh = jax.make_mesh((ndev,), ("x",))
A = jax.device_put(A, NamedSharding(mesh, P("x", None)))
b = jax.device_put(b, NamedSharding(mesh, P(None, None)))
# Call potrs
out = potrs(A, b, T_A=T_A, mesh=mesh, in_specs=(P("x", None), ))
print(out)
expected_out = 1.0 / (jnp.arange(N, dtype=dtype) + 1)
print(jnp.allclose(out.flatten(), expected_out))
which gives
[[1. ]
[0.5 ]
[0.33333333]
[0.25 ]
[0.2 ]
[0.16666667]
[0.14285714]
[0.125 ]
[0.11111111]
[0.1 ]
[0.09090909]
[0.08333333]]
True
as expected.
Projects that use JAXMg
- JAXMg Benchmarks: Benchmarks for various Multi-GPUs setups.
- JAXMg + Netket: Implementation of the MinSR Netket driver that uses JAXMg for inverting the S-matrix. Tested on Multi-node settings.
- JAXMg for blurred sampling: Implementation of t-VMC that makes use JAXMg for inverting the QGT.
cuSolverMp
As of CUDA 13, there is a new distributed linear algebra library called cuSolverMp with similar capabilities as cuSolverMg, that does support multi-node computations as well as >16 devices. Given the similarities in syntax, it should be straightforward to eventually switch to this API. This will require sharding data into a cyclic 2D form and handling the solver orchestration with MPI.
Citations
@misc{2601.14466,
Author = {Roeland Wiersema},
Title = {JAXMg: A multi-GPU linear solver in JAX},
Year = {2026},
Eprint = {arXiv:2601.14466},
}
Acknowledgements
I acknowledge support from the Flatiron Institute. The Flatiron Institute is a division of the Simons Foundation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 jaxmg-0.0.9-cp314-cp314-manylinux_2_26_x86_64.whl.
File metadata
- Download URL: jaxmg-0.0.9-cp314-cp314-manylinux_2_26_x86_64.whl
- Upload date:
- Size: 12.1 MB
- Tags: CPython 3.14, manylinux: glibc 2.26+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77f29b08c68f109d166064375ef0443db4558722d9ccf3726ec81a6bba63c229
|
|
| MD5 |
c10f928e566b5fbeef202dc059891cbd
|
|
| BLAKE2b-256 |
e765f955e463b55289a9e730ea169bdc36c3ce53822a388cdc787b41ab190a56
|
File details
Details for the file jaxmg-0.0.9-cp313-cp313-manylinux_2_26_x86_64.whl.
File metadata
- Download URL: jaxmg-0.0.9-cp313-cp313-manylinux_2_26_x86_64.whl
- Upload date:
- Size: 12.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.26+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74790a4ee93841f3c858efaebaf81c8c32f8cb34e6bab7ac5d690df665773905
|
|
| MD5 |
11b077579a255f797059952dc9487ded
|
|
| BLAKE2b-256 |
487e8028ead5e749887dfa0f99d005db850c0d808c50f7d7ca364ab78a8dcd17
|
File details
Details for the file jaxmg-0.0.9-cp312-cp312-manylinux_2_26_x86_64.whl.
File metadata
- Download URL: jaxmg-0.0.9-cp312-cp312-manylinux_2_26_x86_64.whl
- Upload date:
- Size: 12.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.26+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2999a74990bbce78db60feabc89b97148b5117922ee0ac8e709c68bcf5b04153
|
|
| MD5 |
6e77096bfc4310fa7c41eedbf46be11e
|
|
| BLAKE2b-256 |
deac1af57bc47629359f31b1830e40dba15e427185c742f8a238371b3edecbb6
|
File details
Details for the file jaxmg-0.0.9-cp311-cp311-manylinux_2_26_x86_64.whl.
File metadata
- Download URL: jaxmg-0.0.9-cp311-cp311-manylinux_2_26_x86_64.whl
- Upload date:
- Size: 12.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.26+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab9792f62d4eafa0a81ea0c97629832d169014513421bd26920a858c4f58ea3c
|
|
| MD5 |
74a01417ca8df18018c8b0d8647b8ab7
|
|
| BLAKE2b-256 |
d861ddcf49e78dc33bd62c5072142a1b2b87d47f925fa4bc6b653576279305d3
|