CUDA Quantum for Python¶
What Is CUDA Quantum?¶
CUDA Quantum streamlines hybrid application development and promotes productivity and scalability in quantum computing. It offers a unified programming model designed for a hybrid setting—that is, CPUs, GPUs, and QPUs working together.
For more information, see the official documentation.
How to Install Version Without GPU Acceleration¶
Use (preferably in conda environment)
pip install cuda-quantum
How to Install Version With GPU Acceleration Using Conda¶
Run:
conda create -y -n cuda-quantum python=3.10 pip
conda install -y -n cuda-quantum -c "nvidia/label/cuda-11.8.0" cuda
conda install -y -n cuda-quantum -c conda-forge mpi4py openmpi cxx-compiler cuquantum
conda env config vars set -n cuda-quantum
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CONDA_PREFIX/envs/cuda-quantum/lib"
conda env config vars set -n cuda-quantum
MPI_PATH=$CONDA_PREFIX/envs/cuda-quantum
conda run -n cuda-quantum pip install cuda-quantum
conda activate cuda-quantum
source $CONDA_PREFIX/lib/python3.10/site-packages/distributed_interfaces/activate_custom_mpi.sh
Then configure the MPI:
export OMPI_MCA_opal_cuda_support=true OMPI_MCA_btl='^openib'
How to Test Your Installation?¶
You can test your installation by running the following script:
import cudaq
kernel = cudaq.make_kernel()
qubit = kernel.qalloc()
kernel.x(qubit)
kernel.mz(qubit)
result = cudaq.sample(kernel)
Further Questions Considering the Installation?¶
See the Cuda Quantum PyPI website at https://pypi.org/project/cuda-quantum/.
Example QNN¶
In the qnn_example.py you find a script that loads FashionMNIST dataset, chooses two data type (shirts and pants), then we create a Neural Network with quantum layer.This network is then trained on our data and later tested on the test dataset. You are free to try it on your own. Download the QNN example and rename it to qnn_example.py
.