Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python wheel installation issues (multiple subtlety linked items) #1493

Merged
merged 41 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9c2d2a2
Fix Python wheel instructions
bmhowe23 Apr 10, 2024
3c76c45
Another fix but in a new way
bmhowe23 Apr 10, 2024
a931da3
Revert "Another fix but in a new way"
bmhowe23 Apr 10, 2024
d9c0b15
Add wheel instruction validation test to publishing tests
bmhowe23 Apr 10, 2024
6ba23b6
Link 0.7.0 release to nightly org instead of stale page
bmhowe23 Apr 10, 2024
91c9cbf
Fix ordering bug in __init__.py
bmhowe23 Apr 10, 2024
e1e84ae
Update README.md now that bug is fixed
bmhowe23 Apr 10, 2024
444da99
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 10, 2024
0171f1e
Try this silly thing
bmhowe23 Apr 11, 2024
93d7e7b
Slight correction - not that it matters though
bmhowe23 Apr 11, 2024
37d026f
Even sillier
bmhowe23 Apr 12, 2024
246b132
Capture qubit id by value
bmhowe23 Apr 12, 2024
10c989c
Do set +e for new tests (allow for skipped)
bmhowe23 Apr 12, 2024
62caa09
TEST: add MPI env var
bmhowe23 Apr 12, 2024
6679c68
Run shortened tests
bmhowe23 Apr 12, 2024
20505d5
Force a failure to make sure the test fails correctly
bmhowe23 Apr 12, 2024
a858237
Enhance error detection in publishing script
bmhowe23 Apr 12, 2024
8441d52
Revert "Force a failure to make sure the test fails correctly"
bmhowe23 Apr 12, 2024
6ef367e
Add cuquantum back to readme file
bmhowe23 Apr 12, 2024
d823029
Remove cuquantum conda package again and search for libs from pip
bmhowe23 Apr 12, 2024
7fb1dff
Tensornet: Capture qubit id by value
bmhowe23 Apr 12, 2024
67be3c0
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 12, 2024
1a59a72
Add cudaq-qpud.py wrapper script
bmhowe23 Apr 15, 2024
2cd4f29
Update docs
bmhowe23 Apr 15, 2024
610613e
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 15, 2024
d4aef34
Fix pre-existing issue with example - it was incorrectly auto-launching
bmhowe23 Apr 16, 2024
609c386
Update cudaq-qpud.py wrapper script
bmhowe23 Apr 16, 2024
fedef83
Build workaround for lack of h5py 3.11 aarch64 wheel
bmhowe23 Apr 16, 2024
e5dfcbb
Add link to upstream GitHub issue
bmhowe23 Apr 16, 2024
a18113d
Ignore empty parameter values in Python kwargs for set_target
bmhowe23 Apr 16, 2024
e0e0d8c
Revert "Fix pre-existing issue with example - it was incorrectly auto…
bmhowe23 Apr 16, 2024
4e67f37
Add sleep before remote test
bmhowe23 Apr 17, 2024
4db9180
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 17, 2024
715fe96
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 17, 2024
e20c6b1
Change some double quotes to single quotes in the integration tests
bmhowe23 Apr 17, 2024
7f7a7f2
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 18, 2024
1951627
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 24, 2024
7b8c77f
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 25, 2024
7dac582
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 29, 2024
6c85cb3
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 Apr 30, 2024
8b54704
Merge branch 'main' into pr-fix-Python-readme
bmhowe23 May 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,46 @@ jobs:
echo "Missing tests for nvidia-mgpu backend." && exit 1
fi

wheel_validation:
name: Python wheel instructions validation
needs: cudaq_wheels

runs-on: linux-amd64-gpu-v100-latest-1

container:
image: ubuntu:22.04
options: --user root
env:
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
TERM: xterm

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.github_commit || needs.assets.outputs.github_commit }}

- name: Load wheel
uses: actions/download-artifact@v4
with:
name: x86_64-py3.10-wheels
path: /tmp/install

- name: Run simple validation
shell: bash
run: |
apt-get update && apt-get install -y --no-install-recommends ca-certificates vim wget openssh-client
cd /tmp
# Setup links for validate_wheel.sh script
ln -s $GITHUB_WORKSPACE/scripts/validate_wheel.sh .
ln -s $GITHUB_WORKSPACE/docs/sphinx/examples/python /tmp/examples
ln -s $GITHUB_WORKSPACE/docs/sphinx/snippets/python /tmp/snippets
ln -s $GITHUB_WORKSPACE/python/tests /tmp/tests
ln -s $GITHUB_WORKSPACE/python/README.md .
# Run the script
# FIXME - should we pass in "-q" to make it a quick test?
bmhowe23 marked this conversation as resolved.
Show resolved Hide resolved
source validate_wheel.sh -w /tmp/install/cuda_quantum-*.whl -f /tmp -p 3.10

image_validation:
name: Docker image validation
needs: [assets, config]
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Check out our `documentation <https://nvidia.github.io/cuda-quantum/latest/using
to get started with the new Python syntax support we have added, and `follow our blog <https://developer.nvidia.com/cuda-q>`__
to learn more about the new setup and its performance benefits.

- `Docker image <https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda-quantum>`__
- `Docker image <https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nightly/containers/cuda-quantum/tags>`__ (use tag 0.7.0)
bmhowe23 marked this conversation as resolved.
Show resolved Hide resolved
- `Python wheel <https://pypi.org/project/cuda-quantum/>`__
- `C++ installer <https://github.com/NVIDIA/cuda-quantum/releases>`__
- `Documentation <https://nvidia.github.io/cuda-quantum/0.7.0>`__
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Quantum with all its dependencies:
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
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 LD_LIBRARY_PATH="$CONDA_PREFIX/envs/cuda-quantum/lib:$LD_LIBRARY_PATH"
bmhowe23 marked this conversation as resolved.
Show resolved Hide resolved
bettinaheim marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
33 changes: 18 additions & 15 deletions python/cudaq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@

import sys, os
from ._packages import *

# CUDAQ_DYNLIBS must be set before any other imports that would initialize
# LinkedLibraryHolder.
if not "CUDAQ_DYNLIBS" in os.environ:
try:
custatevec_libs = get_library_path("custatevec-cu11")
custatevec_path = os.path.join(custatevec_libs, "libcustatevec.so.1")

cutensornet_libs = get_library_path("cutensornet-cu11")
cutensornet_path = os.path.join(cutensornet_libs, "libcutensornet.so.2")

os.environ["CUDAQ_DYNLIBS"] = f"{custatevec_path}:{cutensornet_path}"
except:
import importlib.util
if not importlib.util.find_spec("cuda-quantum") is None:
print("Could not find a suitable cuQuantum Python package.")
pass

from .kernel.kernel_decorator import kernel, PyKernelDecorator
from .kernel.kernel_builder import make_kernel, QuakeValue, PyKernel
from .kernel.ast_bridge import globalAstRegistry, globalKernelRegistry
Expand Down Expand Up @@ -98,21 +116,6 @@ def __clearKernelRegistries():
from .kernels import uccsd
from .dbg import ast

if not "CUDAQ_DYNLIBS" in os.environ:
try:
custatevec_libs = get_library_path("custatevec-cu11")
custatevec_path = os.path.join(custatevec_libs, "libcustatevec.so.1")

cutensornet_libs = get_library_path("cutensornet-cu11")
cutensornet_path = os.path.join(cutensornet_libs, "libcutensornet.so.2")

os.environ["CUDAQ_DYNLIBS"] = f"{custatevec_path}:{cutensornet_path}"
except:
import importlib.util
if not importlib.util.find_spec("cuda-quantum") is None:
print("Could not find a suitable cuQuantum Python package.")
pass

initKwargs = {}

if '-target' in sys.argv:
Expand Down
26 changes: 23 additions & 3 deletions scripts/validate_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# Check the output for any tests that were skipped.

# E.g. run the command
# source validate.sh -w /tmp/cuda_quantum-*.whl -f /tmp -p 3.10
# source validate_wheel.sh -w /tmp/cuda_quantum-*.whl -f /tmp -p 3.10
# in a container (with GPU support) defined by:
#
# ARG base_image=ubuntu:22.04
# FROM ${base_image}
# ARG cuda_quantum_wheel=cuda_quantum-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
# COPY $cuda_quantum_wheel /tmp/$cuda_quantum_wheel
# COPY scripts/validate_wheel.sh validate.sh
# COPY scripts/validate_wheel.sh validate_wheel.sh
# COPY docs/sphinx/examples/python /tmp/examples/
# COPY docs/sphinx/snippets/python /tmp/snippets/
# COPY python/tests /tmp/tests/
Expand All @@ -32,12 +32,15 @@
__optind__=$OPTIND
OPTIND=1
python_version=3.11
while getopts ":f:p:w:" opt; do
quick_test=false
while getopts ":f:p:qw:" opt; do
case $opt in
f) root_folder="$OPTARG"
;;
p) python_version="$OPTARG"
;;
q) quick_test=true
;;
w) cudaq_wheel="$OPTARG"
;;
\?) echo "Invalid command line option -$OPTARG" >&2
Expand Down Expand Up @@ -85,6 +88,23 @@ while IFS= read -r line; do
done <<< "$ompi_script"
status_sum=0

# Verify that the necessary GPU targets are installed and usable
for tgt in nvidia nvidia-fp64 nvidia-mgpu tensornet; do
python3 -c "import cudaq; cudaq.set_target('${tgt}')"
if [ $? -ne 0 ]; then
echo -e "\e[01;31mPython trivial test for target ${tgt} failed.\e[0m" >&2
status_sum=$((status_sum+1))
fi
done

# If this is a quick test, we return here.
if $quick_test; then
if [ ! $status_sum -eq 0 ]; then
echo -e "\e[01;31mValidation produced errors.\e[0m" >&2
fi
(return 0 2>/dev/null) && return $status_sum || exit $status_sum
fi

# Run core tests
echo "Running core tests."
python3 -m pip install pytest numpy
Expand Down
Loading