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.

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 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.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:

  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 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

File details

Details for the file cuquantum_python_cu11-23.3.0-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 543495c1827f271278851db7ba1f256188838451a8e9c1ba7e462fad89a9df19
MD5 0e327af24618af3ff78e0b8d2a172d42
BLAKE2b-256 a478343581559fa4407ec9a105a6c8d32b7c287edd1afdafee45892c98086546

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3ee853a67487df325b716ec8709d17515480a17f33d9db94f13159100b18d68e
MD5 8dad1b8fb5db9d8b065c05e6f0897528
BLAKE2b-256 f90d77a4291452d43e102d6fceeda8d30ed8a1b3937ccdd084eb349215b9bdc5

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2948bd84db62ded56789217ca1509b87d1fff9dfa78561658b310b176cde0791
MD5 34c444b1c3afa01322cdf5ccd5004b68
BLAKE2b-256 601ef5cc6d1e9a4a8aa9fd9d0353aa1a52dcaef8e57d16fea69170fdbb9b5660

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7d7e216dd9fa9d156b3ba0e67ebeb52112481246f803ca21534fae33f370f104
MD5 00a8d99c44e0cbc5b3b0176e12282e41
BLAKE2b-256 5e476b57d37b3205519434ada08af1a1993b7d03a44e969116d6388dcd18418b

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c6355ea394712fd1e33f5a73767968bd4abc136faa7ce810f35fe5f101c591b
MD5 4b682bc67150f77dcdae23f310d0b430
BLAKE2b-256 264fd25af80385178ed44f8638f4c64ab1fca6d433706a8371afeaed88168d1d

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5908c2274dab8e17624046a6d8b48e1281dec3111ed6f3fb0f57c0e6bcc4c422
MD5 ce4a4e2678caea0efd987fd716ab9e2c
BLAKE2b-256 ab1890efa49baad68221f1b78568493b3fd54b29b0614fc70ce48f27e93edc4a

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa11b50619b218cd69857eda2fb45cfee59459117193b14bae3b7ce45b968c15
MD5 31e48a98d3050681bb204e1e6db4ae4e
BLAKE2b-256 23b4bcf30f58f026254571623ec5bc115d2eeff98b3ca04531c94379ff6e6ff9

See more details on using hashes here.

File details

Details for the file cuquantum_python_cu11-23.3.0-cp38-cp38-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cuquantum_python_cu11-23.3.0-cp38-cp38-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5ffb6ad9519efbfe1f85b50c90add7b73219fa77dc362ee9e072864a05400f0e
MD5 4c19ebba3a41265b87e08f2bf356b197
BLAKE2b-256 c16843ca17f00f8108785e27035a1c836ebc83ca75d82fc626eb35fbc4a7e705

See more details on using hashes here.

Supported by

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