Skip to main content

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. If you need to select a particular CUDA version, say CUDA 12.0, please issue the following command:

conda install -c conda-forge cuquantum-python cuda-version=12.0

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 required dependencies for you (including both cuTENSOR and cuQuantum wheels).

Notes:

  • Users can install cuQuantum Python using pip install --no-cache-dir 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. --no-cache-dir is required when using pip 23.1+.
  • CuPy also uses a similar auto-detection mechanism to determine the correct wheel to install. If in doubt, or if installing cuquantum-python-cu11, please follow CuPy's installation guide and install it manually.
  • To manually manage all Python dependencies, append --no-deps to pip install to bypass the pip 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.4.0+
  • cuTensorNet 2.2.0+
  • cuTENSOR 1.6.1+
  • Python 3.9+
  • 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:

  1. Clone the NVIDIA/cuQuantum repository: git clone https://github.com/NVIDIA/cuQuantum
  2. Set CUDA_PATH to point to your CUDA installation
  3. [optional] Set CUQUANTUM_ROOT to point to your cuQuantum installation
  4. [optional] Set CUTENSOR_ROOT to point to your cuTENSOR installation
  5. [optional] Make sure cuQuantum and cuTENSOR are visible in your LD_LIBRARY_PATH
  6. Switch to the directory containing the Python implementation: cd cuQuantum/python
  7. Build and install:
    • Run pip install . if you skip Step 3-5 above
    • Run pip install -v --no-deps --no-build-isolation . otherwise (advanced)

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 (so pip ... . becomes pip ... -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 and CUTENSORNET_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:

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 that 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 import torch before importing cuquantum.
  • 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

Pleae click this Zenodo badge to see the citation format: DOI

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb995cd83f883db3747938da21ca28a1cbdfa792d2d7b5ffb6831f1ed9fc32ee
MD5 47fdb7cdf70cc355af4533716780f160
BLAKE2b-256 5a310cf2a0e75aba2af7a898a656a4663a67b0c0f6979496457fb97c8d392c28

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 441149c6819e4ab68c443262f5a2d6f476051e7204f9d91aca70372120667842
MD5 0c8ae0a4103a64c88b145d7f8f3f83ea
BLAKE2b-256 37c3769c70b331c4dbb57e035f8f2edd0fa3f5a5814fadaa7511a6e4aa36a901

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28dbe4d9abf9450e3ff16195451c333d29828fa74be90e5a7b92e53f0f337dd1
MD5 29114b1c9b560dcd9aebc4eaffcf26ac
BLAKE2b-256 6ac6d02d6d6409ef529eb5816e0cddc34b4fb0b1a62565b595c2d2fea1f60cdc

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 91ea52186e32b837ad0225ff58780b892ea8de3c71dbcb9119d256f1c05c0e5e
MD5 842cd59387696d16dcac4bbfd58e3dfe
BLAKE2b-256 ce3a8b55d49328ad94917d568c26e03d42aeb73f3e50b800a3bb57bcdf8e806b

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c7724bb866a1c2a93a6bc806b42d1f4be449bab3d4e1d912d05ee003300c59b
MD5 1b4f475e61345c2d8aa968d6e60fe3f6
BLAKE2b-256 33634597b1af4f247ccd0b221e705ab0a3d00d8dfcb8d3e923f81e3b255eded9

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu12-23.6.0-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu12-23.6.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 af2aa664f9fa5bb893edd2885c058fd88d702fe8553294a485278461c578840f
MD5 03d8687499a94f6d12b22a047aea09c8
BLAKE2b-256 fe5a49ea960923880312e8a40db61c166f23a32a8118a2a9952135e1028d6123

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page