Skip to content

Commit

Permalink
Merge branch '23.03' into 'main'
Browse files Browse the repository at this point in the history
Update for 23.03

See merge request cuda-hpc-libraries/cuquantum-sdk/cuquantum-public!20
  • Loading branch information
leofang committed Apr 5, 2023
2 parents ddd4806 + 06a401c commit 6b63393
Show file tree
Hide file tree
Showing 184 changed files with 7,493 additions and 756 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ repository-code: "https://github.com/nvidia/cuquantum"
type: software
url: "https://github.com/nvidia/cuquantum"
doi: 10.5281/zenodo.6385574
version: "v22.11.0.1"
version: "v23.03.0"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

BSD-3-Clause

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<div align="center"><img src="https://developer.nvidia.com/sites/default/files/akamai/nvidia-cuquantum-icon.svg" width="250"/></div>

# Welcome to the cuQuantum repository!

This public repository contains two sets of files related to the [NVIDIA cuQuantum SDK](https://developer.nvidia.com/cuquantum-sdk):
<img align="right" width="200"
src="https://developer.nvidia.com/sites/default/files/akamai/nvidia-cuquantum-icon.svg"
/>

- `samples`: All C/C++ sample codes for the cuQuantum SDK.
This public repository contains a few sets of files related to the [NVIDIA cuQuantum SDK](https://developer.nvidia.com/cuquantum-sdk):

- `benchmarks`: NVIDIA cuQuantum Performance Benchmark Suite (v0.2.0), see [README](./benchmarks/README.md) for detail.
- `extra`: Files to help utilize the cuQuantum SDK and the cuQuantum Appliance container.
- `python`: The open-sourced cuQuantum Python project.
- Available for download on
- conda-forge:
Expand All @@ -17,10 +20,13 @@ This public repository contains two sets of files related to the [NVIDIA cuQuant
- `cuquantum-cu11` [![pypi](https://img.shields.io/pypi/v/cuquantum-cu11.svg)](https://pypi.python.org/pypi/cuquantum-cu11)
- `custatevec-cu11` [![pypi](https://img.shields.io/pypi/v/custatevec-cu11.svg)](https://pypi.python.org/pypi/custatevec-cu11)
- `cutensornet-cu11` [![pypi](https://img.shields.io/pypi/v/cutensornet-cu11.svg)](https://pypi.python.org/pypi/cutensornet-cu11)
- `cuquantum-cu12` [![pypi](https://img.shields.io/pypi/v/cuquantum-cu12.svg)](https://pypi.python.org/pypi/cuquantum-cu12)
- `custatevec-cu12` [![pypi](https://img.shields.io/pypi/v/custatevec-cu12.svg)](https://pypi.python.org/pypi/custatevec-cu12)
- `cutensornet-cu12` [![pypi](https://img.shields.io/pypi/v/cutensornet-cu12.svg)](https://pypi.python.org/pypi/cutensornet-cu12)
- `cuquantum-python` [![pypi](https://img.shields.io/pypi/v/cuquantum-python.svg)](https://pypi.python.org/pypi/cuquantum-python)
- `cuquantum-python-cu11` [![pypi](https://img.shields.io/pypi/v/cuquantum-python-cu11.svg)](https://pypi.python.org/pypi/cuquantum-python-cu11)
- `benchmarks`: NVIDIA cuQuantum Performance Benchmark Suite (v0.2.0), see [README](./benchmarks/README.md) for detail.
- `extra`: Files to help utilize the cuQuantum SDK and the cuQuantum Appliance container.
- `cuquantum-python-cu12` [![pypi](https://img.shields.io/pypi/v/cuquantum-python-cu12.svg)](https://pypi.python.org/pypi/cuquantum-python-cu12)
- `samples`: All C/C++ sample codes for the cuQuantum SDK.

## Installation

Expand Down
24 changes: 24 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Security

NVIDIA is dedicated to the security and trust of our software products and services, including all source code repositories managed through our organization.

If you need to report a security issue, please use the appropriate contact points outlined below. **Please do not report security vulnerabilities through GitHub/GitLab.**

## Reporting Potential Security Vulnerability in cuQuantum

To report a potential security vulnerability in cuQuantum:
- Web: [Security Vulnerability Submission Form](https://www.nvidia.com/object/submit-security-vulnerability.html)
- E-Mail: [email protected]
- We encourage you to use the following PGP key for secure email communication: [NVIDIA public PGP Key for communication](https://www.nvidia.com/en-us/security/pgp-key)
- Please include the following information:
- Product/Driver name and version/branch that contains the vulnerability
- Type of vulnerability (code execution, denial of service, buffer overflow, etc.)
- Instructions to reproduce the vulnerability
- Proof-of-concept or exploit code
- Potential impact of the vulnerability, including how an attacker could exploit the vulnerability

While NVIDIA currently does not have a bug bounty program, we do offer acknowledgement when an externally reported security issue is addressed under our coordinated vulnerability disclosure policy. Please visit our [Product Security Incident Response Team (PSIRT)](https://www.nvidia.com/en-us/security/psirt-policies/) policies page for more information.

## NVIDIA Product Security

For all security-related concerns, please visit NVIDIA's Product Security portal at https://www.nvidia.com/en-us/security.
2 changes: 1 addition & 1 deletion extra/custatevec/mpiCommPlugin.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES.
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
Expand Down
2 changes: 1 addition & 1 deletion python/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

BSD-3-Clause

Expand Down
38 changes: 22 additions & 16 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ 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](https://github.com/conda-forge/staged-recipes/issues/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-cu11
pip install cuquantum-python-cuXX
```
The `pip` solver will also install all dependencies for you (including both cuTENSOR and cuQuantum wheels).
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](https://docs.cupy.dev/en/stable/install.html).

Notes:

- User can still install cuQuantum Python using `pip install cuquantum-python`, which currently points to the `cuquantum-python-cu11` wheel that is subject to change in the future. Installing wheels with the `-cuXX` suffix is encouraged.
- 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
Expand All @@ -36,10 +40,10 @@ Notes:

The build-time dependencies of the cuQuantum Python package include:

* CUDA Toolkit 11.x
* cuStateVec 1.1.0+
* cuTensorNet 2.0.0+
* cuTENSOR 1.5.0+
* 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+
Expand Down Expand Up @@ -68,6 +72,7 @@ Notes:
* `--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
Expand All @@ -77,10 +82,10 @@ Notes:
Runtime dependencies of the cuQuantum Python package include:

* An NVIDIA GPU with compute capability 7.0+
* Driver: Linux (450.80.02+)
* CUDA Toolkit 11.x
* cuStateVec 1.1.0+
* cuTensorNet 2.0.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+
Expand All @@ -90,17 +95,18 @@ Runtime dependencies of the cuQuantum Python package include:
* Cirq v0.6.0+ (optional, see [installation guide](https://quantumai.google/cirq/install))
* mpi4py v3.1.0+ (optional, see [installation guide](https://mpi4py.readthedocs.io/en/stable/install.html))

If you install everything from conda-forge, the dependencies are taken care for you (except for the driver).
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, cuTENSOR and cuQuantum (but not CUDA Toolkit or the driver,
please make sure the CUDA libraries are discoverable through your `LD_LIBRARY_PATH`) are installed for you.
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 cuQuantum and cuTENSOR libraries are added
to your `LD_LIBRARY_PATH` environment variable.
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

Expand Down
2 changes: 1 addition & 1 deletion python/builder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

Expand Down
6 changes: 3 additions & 3 deletions python/builder/pep517.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

Expand Down Expand Up @@ -30,8 +30,8 @@ def get_requires_for_build_wheel(config_settings=None):
# set up version constraints: note that CalVer like 22.03 is normalized to
# 22.3 by setuptools, so we must follow the same practice in the constraints;
# also, we don't need the patch number here
cuqnt_require = [f'custatevec-cu{utils.cuda_major_ver}~=1.1', # ">=1.1.0,<2"
f'cutensornet-cu{utils.cuda_major_ver}~=2.0', # ">=2.0.0,<3"
cuqnt_require = [f'custatevec-cu{utils.cuda_major_ver}~=1.3', # ">=1.3.0,<2"
f'cutensornet-cu{utils.cuda_major_ver}~=2.1', # ">=2.1.0,<3"
]

return _build_meta.get_requires_for_build_wheel(config_settings) + cuqnt_require
Expand Down
23 changes: 21 additions & 2 deletions python/builder/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

import os
import platform
import re
import site
import sys
Expand Down Expand Up @@ -53,14 +54,17 @@ def check_cuda_version():
return str(ver // 1000) + '.' + str((ver % 100) // 10)


# We only support CUDA 11 in v22.11
# We support CUDA 11/12 starting 23.03
cuda_ver = check_cuda_version()
if cuda_ver == '11.0':
cutensor_ver = cuda_ver
cuda_major_ver = '11'
elif '11.0' < cuda_ver < '12.0':
cutensor_ver = '11'
cuda_major_ver = '11'
elif '12.0' <= cuda_ver < '13.0':
cutensor_ver = '12'
cuda_major_ver = '12'
else:
raise RuntimeError(f"Unsupported CUDA version: {cuda_ver}")

Expand All @@ -75,6 +79,20 @@ def run(self):
building_wheel = True
super().run()

def finalize_options(self):
super().finalize_options()
self.root_is_pure = False

def get_tag(self):
# hack: passing --build-options in cmdline no longer works with PEP 517 backend,
# so we need to overwrite --plat-name here
# refs:
# - https://github.com/pypa/build/issues/480
# - https://github.com/scikit-build/ninja-python-distributions/pull/85
impl_tag, abi_tag, _ = super().get_tag()
plat_tag = f"manylinux2014_{platform.machine()}"
return impl_tag, abi_tag, plat_tag


class build_ext(_build_ext):

Expand Down Expand Up @@ -202,4 +220,5 @@ def build_extension(self, ext):

def build_extensions(self):
self._prep_includes_libs_rpaths()
self.parallel = 4 # use 4 threads
super().build_extensions()
2 changes: 1 addition & 1 deletion python/cuquantum/__init__.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause
4 changes: 2 additions & 2 deletions python/cuquantum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

from cuquantum import custatevec
from cuquantum import cutensornet
from cuquantum.cutensornet import (
contract, contract_path, einsum, einsum_path, tensor_qualifiers_dtype, Network, BaseCUDAMemoryManager, MemoryPointer,
contract, contract_path, einsum, einsum_path, tensor, tensor_qualifiers_dtype, Network, BaseCUDAMemoryManager, MemoryPointer,
NetworkOptions, OptimizerInfo, OptimizerOptions, PathFinderOptions, ReconfigOptions, SlicerOptions, CircuitToEinsum)
from cuquantum.utils import ComputeType, cudaDataType, libraryPropertyType
from cuquantum._version import __version__
Expand Down
2 changes: 1 addition & 1 deletion python/cuquantum/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

Expand Down
4 changes: 2 additions & 2 deletions python/cuquantum/_version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

# Note: cuQuantum Python follows the cuQuantum SDK version, which is now
# switched to YY.MM and is different from individual libraries' (semantic)
# versioning scheme.
__version__ = '22.11.0.1'
__version__ = '23.03.0'
2 changes: 1 addition & 1 deletion python/cuquantum/custatevec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

Expand Down
33 changes: 31 additions & 2 deletions python/cuquantum/custatevec/custatevec.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES
#
# SPDX-License-Identifier: BSD-3-Clause

Expand All @@ -10,7 +10,7 @@
from libc.stdint cimport intptr_t, int32_t, uint32_t, int64_t

from cuquantum.utils cimport (DataType, DeviceAllocType, DeviceFreeType, int2,
LibPropType, Stream)
LibPropType, Stream, Event)


cdef extern from '<custatevec.h>' nogil:
Expand All @@ -33,6 +33,22 @@ cdef extern from '<custatevec.h>' nogil:
const char* functionName,
const char* message,
void* userData)
ctypedef void* _CommunicatorDescriptor 'custatevecCommunicatorDescriptor_t'
ctypedef struct _SVSwapParameters 'custatevecSVSwapParameters_t':
int32_t swapBatchIndex
int32_t orgSubSVIndex
int32_t dstSubSVIndex
# Same Cython limitation as above
int32_t orgSegmentMaskString[48]
int32_t dstSegmentMaskString[48]
int32_t segmentMaskOrdering[48]
uint32_t segmentMaskLen
uint32_t nSegmentBits
_DataTransferType dataTransferType
_Index transferSize
ctypedef void* _DistIndexBitSwapSchedulerDescriptor 'custatevecDistIndexBitSwapSchedulerDescriptor_t'
ctypedef void* _SVSwapWorkerDescriptor 'custatevecSVSwapWorkerDescriptor_t'


# cuStateVec enums
ctypedef enum _ComputeType 'custatevecComputeType_t':
Expand Down Expand Up @@ -65,9 +81,22 @@ cdef extern from '<custatevec.h>' nogil:
CUSTATEVEC_DEVICE_NETWORK_TYPE_SWITCH
CUSTATEVEC_DEVICE_NETWORK_TYPE_FULLMESH

ctypedef enum _CommunicatorType 'custatevecCommunicatorType_t':
CUSTATEVEC_COMMUNICATOR_TYPE_EXTERNAL
CUSTATEVEC_COMMUNICATOR_TYPE_OPENMPI
CUSTATEVEC_COMMUNICATOR_TYPE_MPICH

ctypedef enum _DataTransferType 'custatevecDataTransferType_t':
CUSTATEVEC_DATA_TRANSFER_TYPE_NONE
CUSTATEVEC_DATA_TRANSFER_TYPE_SEND
CUSTATEVEC_DATA_TRANSFER_TYPE_RECV
CUSTATEVEC_DATA_TRANSFER_TYPE_SEND_RECV


# cuStateVec consts
int CUSTATEVEC_VER_MAJOR
int CUSTATEVEC_VER_MINOR
int CUSTATEVEC_VER_PATCH
int CUSTATEVEC_VERSION
int CUSTATEVEC_ALLOCATOR_NAME_LEN
int CUSTATEVEC_MAX_SEGMENT_MASK_SIZE
Loading

0 comments on commit 6b63393

Please sign in to comment.