Skip to content

Commit

Permalink
Merge branch 'main' into ignore_zero_coefficient_terms
Browse files Browse the repository at this point in the history
  • Loading branch information
sacpis authored Nov 8, 2024
2 parents e8652c6 + aef4036 commit 4598261
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/python_metapackages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
# autoremove is in an odd location that isn't found unless we search for it...
autoremove="$python $($python -m pip show pip3-autoremove | grep -e 'Location: .*$' | cut -d ' ' -f2)/pip_autoremove.py"
$python -m pip install pypiserver
server="$python $($python -m pip show pypiserver | grep -e 'Location: .*$' | cut -d ' ' -f2)/pypiserver_main__.py"
server="$python $($python -m pip show pypiserver | grep -e 'Location: .*$' | cut -d ' ' -f2)/pypiserver/__main__.py"
$server run -p 8080 /tmp/packages &
package_dep=`echo cuda-quantum${cuda_version_suffix:+-cu$cuda_version_suffix} | cut -d '-' -f1-2`
Expand Down Expand Up @@ -195,14 +195,12 @@ jobs:
fi
- name: Test installation error
# FIXME: We actually don't give a proper install error if there are conflicting packages on the system...
if: matrix.cuda_version == ''
run: |
#dnf install -y --nobest --setopt=install_weak_deps=False curl jq
#PACKAGE_JSON_URL="https://pypi.org/pypi/cuda-quantum/json"
#curl -L -s "$PACKAGE_JSON_URL" | jq -r '.releases | keys | .[]'
python=python${{ matrix.python_version }}
$python -m pip install pypiserver
server="$python $($python -m pip show pypiserver | grep -e 'Location: .*$' | cut -d ' ' -f2)/pypiserver_main__.py"
server="$python $($python -m pip show pypiserver | grep -e 'Location: .*$' | cut -d ' ' -f2)/pypiserver/__main__.py"
$server run -p 8080 /tmp/packages &
case "${{ matrix.cuda_version }}" in
Expand All @@ -216,7 +214,7 @@ jobs:
$python -m pip install cuda-quantum-cu11==${{ inputs.cudaq_version }} \
--extra-index-url http://localhost:8080
set +e # continue on error
$python -m pip install cudaq==${{ inputs.cudaq_version }} \
$python -m pip install cudaq==${{ inputs.cudaq_version }} -v \
--extra-index-url http://localhost:8080
set -e && check_package=cudaq
;;
Expand All @@ -231,7 +229,7 @@ jobs:
--extra-index-url http://localhost:8080
fi
set +e # continue on error
$python -m pip install cudaq==${{ inputs.cudaq_version }} \
$python -m pip install cudaq==${{ inputs.cudaq_version }} -v \
--extra-index-url http://localhost:8080
set -e && check_package=cudaq
;;
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/applications/python/hybrid_qnns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Install the relevant packages.\n",
"\n",
"!pip install matplotlib==3.8.4 torch==2.2.0 torchvision==0.17.0 scikit-learn==1.4.2 -q"
"!pip install matplotlib==3.8.4 torch==2.0.1+cu118 torchvision==0.15.2+cu118 scikit-learn==1.4.2 -q --extra-index-url https://download.pytorch.org/whl/cu118"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion python/cudaq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
os.environ["CUDAQ_DYNLIBS"] += f":{cudart_path}"
except:
import importlib.util
package_spec = importlib.util.find_spec("cuda-quantum")
package_spec = importlib.util.find_spec(f"cuda-quantum-cu{cuda_major}")
if not package_spec is None and not package_spec.loader is None:
print("Could not find a suitable cuQuantum Python package.")
pass
Expand Down
18 changes: 14 additions & 4 deletions python/metapackages/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

import ctypes, pkg_resources, os, sys
import ctypes, os, sys
import importlib.util
from setuptools import setup
from typing import Optional

Expand Down Expand Up @@ -105,10 +106,16 @@ def _infer_best_package() -> str:
# Find the existing wheel installation
installed = []
for pkg_suffix in ['', '-cu11', '-cu12']:
_log(f"Looking for existing installation of cuda-quantum{pkg_suffix}.")
try:
pkg_resources.get_distribution(f"cuda-quantum{pkg_suffix}")
installed.append(f"cuda-quantum{pkg_suffix}")
except pkg_resources.DistributionNotFound:
package_spec = importlib.util.find_spec(f"cuda-quantum{pkg_suffix}")
if package_spec is None:
_log("No installation found.")
else:
installed.append(f"cuda-quantum{pkg_suffix}")
_log("Installation found.")
except:
_log("No installation found.")
pass

cuda_version = _get_cuda_version()
Expand All @@ -122,10 +129,13 @@ def _infer_best_package() -> str:
cudaq_bdist = 'cuda-quantum-cu12'
else:
raise Exception(f'Your CUDA version ({cuda_version}) is too new.')
_log(f"Identified {cudaq_bdist} as the best package.")

# Disallow -cu11 & -cu12 wheels from coexisting
conflicting = ", ".join((pkg for pkg in installed if pkg != cudaq_bdist))
_log(f"Conflicting packages: {conflicting}")
if conflicting != '':
_log("Abort.")
raise Exception(
f'You have a conflicting CUDA-Q version installed.'
f'Please remove the following package(s): {conflicting}')
Expand Down

0 comments on commit 4598261

Please sign in to comment.