NVIDIA cuQuantum Python
Project description
cuQuantum Python
Documentation
Please visit the NVIDIA cuQuantum Python documentation.
Installation
Install cuQuantum Python from conda-forge
If you already have a Conda environment set up, it is the easiest to install cuQuantum Python from the conda-forge channel:
conda install -c conda-forge cuquantum-python
The Conda solver will install all required dependencies for you.
Note: Currently CUDA 12 support is pending the NVIDIA-led community effort (conda-forge/staged-recipes#21382). Once conda-forge supports CUDA 12 we will make compatible conda packages available.
Install cuQuantum Python from PyPI
Alternatively, assuming you already have a Python environment set up (it doesn't matter if it's a Conda env or not), you can also install cuQuantum Python this way:
pip install cuquantum-python-cuXX
with XX
being 11
(for CUDA 11) or 12
(for CUDA 12).
The pip
solver will also install all dependencies, with the exception of CuPy, for you (including both cuTENSOR and cuQuantum wheels). Please follow
CuPy's installation guide.
Notes:
- Users can install cuQuantum Python using
pip install cuquantum-python
, which will attempt to detect the current CUDA environment and choose the appropriate wheel to install. In the event of detection failure, CUDA 11 is assumed. This is subject to change in the future. Installing wheels with the-cuXX
suffix is encouraged. - To manually manage all Python dependencies, append
--no-deps
topip install
to bypass thepip
solver, see below.
Building and installing cuQuantum Python from source
Requirements
The build-time dependencies of the cuQuantum Python package include:
- CUDA Toolkit 11.x or 12.x
- cuStateVec 1.3.0+
- cuTensorNet 2.1.0+
- cuTENSOR 1.6.1+
- Python 3.8+
- Cython >=0.29.22,<3
- pip 21.3.1+
- packaging
- setuptools 61.0.0+
- wheel 0.34.0+
Except for CUDA and Python, the rest of the build-time dependencies are handled by the new PEP-517-based build system (see Step 7 below).
To compile and install cuQuantum Python from source, please follow the steps below:
- Clone the NVIDIA/cuQuantum repository:
git clone https://github.com/NVIDIA/cuQuantum
- Set
CUDA_PATH
to point to your CUDA installation - [optional] Set
CUQUANTUM_ROOT
to point to your cuQuantum installation - [optional] Set
CUTENSOR_ROOT
to point to your cuTENSOR installation - [optional] Make sure cuQuantum and cuTENSOR are visible in your
LD_LIBRARY_PATH
- Switch to the directory containing the Python implementation:
cd cuQuantum/python
- Build and install:
- Run
pip install .
if you skip Step 3-5 above - Run
pip install -v --no-deps --no-build-isolation .
otherwise (advanced)
- Run
Notes:
- For Step 7, if you are building from source for testing/developing purposes you'd likely want to insert a
-e
flag before the last period (sopip ... .
becomespip ... -e .
):-e
: use the "editable" (in-place) mode-v
: enable more verbose output--no-deps
: avoid installing the run-time dependencies--no-build-isolation
: reuse the current Python environment instead of creating a new one for building the package (this avoids installing any build-time dependencies)
- As an alternative to setting
CUQUANTUM_ROOT
,CUSTATEVEC_ROOT
andCUTENSORNET_ROOT
can be set to point to the cuStateVec and the cuTensorNet libraries, respectively. The latter two environment variables take precedence if defined. - Please ensure that you use consistent binaries and packages for either CUDA 11 or 12. Mixing-and-matching will result in undefined behavior.
Running
Requirements
Runtime dependencies of the cuQuantum Python package include:
- An NVIDIA GPU with compute capability 7.0+
- Driver: Linux (450.80.02+ for CUDA 11, 525.60.13+ for CUDA 12)
- CUDA Toolkit 11.x or 12.x
- cuStateVec 1.3.0+
- cuTensorNet 2.1.0+
- cuTENSOR 1.6.1+
- Python 3.8+
- NumPy v1.19+
- CuPy v9.5.0+ (see installation guide)
- PyTorch v1.10+ (optional, see installation guide)
- Qiskit v0.24.0+ (optional, see installation guide)
- Cirq v0.6.0+ (optional, see installation guide)
- mpi4py v3.1.0+ (optional, see installation guide)
If you install everything from conda-forge, all the required dependencies are taken care for you (except for the driver).
If you install the pip wheels, CuPy, cuTENSOR and cuQuantum (but not CUDA Toolkit or the driver,
please make sure the CUDA libraries are visible through your LD_LIBRARY_PATH
) are installed for you.
If you build cuQuantum Python from source, please make sure the paths to the CUDA, cuQuantum, and cuTENSOR libraries are added
to your LD_LIBRARY_PATH
environment variable, and that a compatible CuPy is installed.
Known issues:
- If a system has multiple copies of cuTENSOR, one of which is installed in a default system path, the Python runtime could pick it up despite cuQuantum Python is linked to another copy installed elsewhere, potentially causing a version-mismatch error. The proper fix is to remove cuTENSOR from the system paths to ensure the visibility of the proper copy. DO NOT ATTEMPT to use
LD_PRELOAD
to overwrite it --- it could cause hard to debug behaviors! - In certain environments, if PyTorch is installed
import cuquantum
could fail (with a segmentation fault). It is currently under investigation and a temporary workaround is to importtorch
before importingcuquantum
. - Please ensure that you use consistent binaries and packages for either CUDA 11 or 12. Mixing-and-matching will result in undefined behavior.
Samples
Samples for demonstrating the usage of both low-level and high-level Python APIs are
available in the samples
directory. The low-level API samples are 1:1 translations of the corresponding
samples written in C. The high-level API samples demonstrate pythonic usages of the cuTensorNet
library in Python.
Testing
If pytest is installed, typing pytest tests
at the command prompt in the Python source root directory will
run all tests. Some tests would be skipped if cffi
is not installed or if the environment
variable CUDA_PATH
is not set.
Citing cuQuantum
Project details
Release history Release notifications | RSS feed
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
Hashes for cuquantum_python_cu12-23.3.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d29fbd9eb47a833440725ebb9cd9a3c54ef8b49c129f28e238c55e88150fb22b |
|
MD5 | c6ff6fb5b7d04cf69417eff24d56f565 |
|
BLAKE2b-256 | 0672f43f8f888289e7c4e7c539a0a2731410c48ea674226e834ec4175a6fe7b0 |
Hashes for cuquantum_python_cu12-23.3.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 281f2f5b5b49d352dc2d7f792fc1570fa702b9dd27c00c7d20df201b661bae18 |
|
MD5 | ceb07974e65bd2a1463431f91ef08a65 |
|
BLAKE2b-256 | 93bb09ed08f299d00b078b84549bb3b8cd95a9daad58174de35d5296a303c141 |
Hashes for cuquantum_python_cu12-23.3.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2863a0e2e8f379f4d23460178b3b6f4b24eea420123d9870870ed36db0146002 |
|
MD5 | 4208797cd74b1f1978bd91fb191e0c17 |
|
BLAKE2b-256 | 68da50fb5399aef90e250c97d7530ff24849d8be9c1d7523e476f0a51d06ec8f |
Hashes for cuquantum_python_cu12-23.3.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed02c9b0dd1bf1941e2ebeec96b5a7fafaf70035034cc4acc44490edf56aa4bd |
|
MD5 | 9b2337d551edb5720a84a5ec050e9c40 |
|
BLAKE2b-256 | 65e2d10bae81cdebad3a72dd055a1bf8ef1ba0dd742ef8ee010d8c287661dc7d |
Hashes for cuquantum_python_cu12-23.3.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27f3e919f94f6ccce80ddf140e64e7a6c8f7509a8e0d17f8f99de2d4fea53360 |
|
MD5 | 34009d2e4f76e81b8b31981a3ca58712 |
|
BLAKE2b-256 | 0027c56cf5f373f476a841c9e925cbeb722309d74b5e25ed07bcd0ca198a90dd |
Hashes for cuquantum_python_cu12-23.3.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e47141fd6434f2eb5ef5c9b677f51ce30ce1084b749cfd8479bfedf7e2160bf4 |
|
MD5 | 2d7516accdea81684ed0ab3f11c65c69 |
|
BLAKE2b-256 | b2dec8293f6f5895830a8d1abd5bce9cbb50203bf4008edae3419920d762a6a9 |
Hashes for cuquantum_python_cu12-23.3.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d562c58a2265093da009c5c1aa7c414e52b421692c830d872b727bb47b9f8851 |
|
MD5 | ed6b2f8507a5176fb7acbe6e51c4be8f |
|
BLAKE2b-256 | d66ee3a831d041fdb706139a105c66ae1371deff319d161abcbbb7013da17079 |
Hashes for cuquantum_python_cu12-23.3.0-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91f2b4c827478d50f96fee4a406cdbc4127b95cbcf255250a4fb77f53f99590 |
|
MD5 | 70fca22c9aa0714e0536f829c259fa04 |
|
BLAKE2b-256 | 4568879d197984f9401ea65260b00850915eb3178e9e2b7723788c60a61aca5b |