From 0b0097906ccc8509ddc7ff7d9a59e319c5918e09 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 19:09:46 -0500 Subject: [PATCH 1/6] [major] removed deprecated IBMQ dependency and restricted to qiskit<1.0.0 --- torchquantum/util/utils.py | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/torchquantum/util/utils.py b/torchquantum/util/utils.py index 58ef4e03..caeee471 100644 --- a/torchquantum/util/utils.py +++ b/torchquantum/util/utils.py @@ -30,7 +30,7 @@ import torch.nn as nn import torch.nn.functional as F from opt_einsum import contract -from qiskit import IBMQ +from qiskit_ibm_runtime import QiskitRuntimeService from qiskit.exceptions import QiskitError from qiskit.providers.aer.noise.device.parameters import gate_error_values from torchpack.utils.config import Config @@ -738,7 +738,6 @@ def get_success_rate(properties, transpiled_circ): return success_rate - def get_provider(backend_name, hub=None): """ Get the provider object for a specific backend from IBM Quantum. @@ -753,13 +752,9 @@ def get_provider(backend_name, hub=None): # mass-inst-tech-1 or MIT-1 if backend_name in ["ibmq_casablanca", "ibmq_rome", "ibmq_bogota", "ibmq_jakarta"]: if hub == "mass" or hub is None: - provider = IBMQ.get_provider( - hub="ibm-q-research", group="mass-inst-tech-1", project="main" - ) + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q-research/mass-inst-tech-1/main") elif hub == "mit": - provider = IBMQ.get_provider( - hub="ibm-q-research", group="MIT-1", project="main" - ) + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q-research/MIT-1/main") else: raise ValueError(f"not supported backend {backend_name} in hub " f"{hub}") elif backend_name in [ @@ -769,33 +764,25 @@ def get_provider(backend_name, hub=None): "ibmq_guadalupe", "ibmq_montreal", ]: - provider = IBMQ.get_provider(hub="ibm-q-ornl", group="anl", project="csc428") + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q-ornl/anl/csc428") else: if hub == "mass" or hub is None: try: - provider = IBMQ.get_provider( - hub="ibm-q-research", group="mass-inst-tech-1", project="main" - ) + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q-research/mass-inst-tech-1/main") except QiskitError: # logger.warning(f"Cannot use MIT backend, roll back to open") logger.warning(f"Use the open backend") - provider = IBMQ.get_provider(hub="ibm-q", group="open", project="main") + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q/open/main") elif hub == "mit": - provider = IBMQ.get_provider( - hub="ibm-q-research", group="MIT-1", project="main" - ) + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q-research/MIT-1/main") else: - provider = IBMQ.get_provider(hub="ibm-q", group="open", project="main") + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = "ibm-q/open/main") return provider def get_provider_hub_group_project(hub="ibm-q", group="open", project="main"): - provider = IBMQ.get_provider( - hub=hub, - group=group, - project=project, - ) + provider = QiskitRuntimeService(channel = "ibm_quantum", instance = f"{hub}/{group}/{project}") return provider @@ -1085,4 +1072,4 @@ def clone_model(model_to_clone):#i have to note:this clone_model function was ma state_dict_minus_shift[key] += shift_rate gradient_of_par[idx-2] = (expectation_plus_shift - expectation_minus_shift) * 0.5 - return gradient_of_par \ No newline at end of file + return gradient_of_par From b9851929743fab7272a7ec037d949f26c3e75923 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 19:28:09 -0500 Subject: [PATCH 2/6] [minor] added missing dependency --- .github/workflows/functional_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional_tests.yaml b/.github/workflows/functional_tests.yaml index fb8a7ea1..f1d2770e 100644 --- a/.github/workflows/functional_tests.yaml +++ b/.github/workflows/functional_tests.yaml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest qiskit-aer qiskit-ibmq-provider + python -m pip install flake8 pytest qiskit-aer qiskit_ibm_runtime if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | From 1f7bcf0866ff830dab93f27aa26f24f6c445f7a0 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 19:37:47 -0500 Subject: [PATCH 3/6] [minor] flipping order of imports --- .github/workflows/functional_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/functional_tests.yaml b/.github/workflows/functional_tests.yaml index f1d2770e..4be0f73d 100644 --- a/.github/workflows/functional_tests.yaml +++ b/.github/workflows/functional_tests.yaml @@ -25,8 +25,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest qiskit-aer qiskit_ibm_runtime if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install flake8 pytest qiskit-aer qiskit_ibm_runtime - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From d6fffa184ec8a3c1f1cf299ca5814c3e392c7926 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 19:42:34 -0500 Subject: [PATCH 4/6] [minor] updating the requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 88a06d50..a43fc839 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ opt_einsum pathos>=0.2.7 pylatexenc>=2.10 pyscf>=2.0.1 -qiskit>=0.39.0 +qiskit>=0.39.0,<1.0.0 recommonmark scipy>=1.5.2 From 529436663cac49eb40a08f340c72999b5df00e16 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 20:22:46 -0500 Subject: [PATCH 5/6] [major] update documentation deployment --- docs/requirements.txt | 6 ++++++ docs/source/conf.py | 3 +-- readthedocs.yaml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 docs/requirements.txt create mode 100644 readthedocs.yaml diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..597c0496 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,6 @@ +furo @ git+https://github.com/frogcjn/torchquantum-doc-furo-theme.git +nbsphinx +recommonmark + +torchquantum>=0.1 +opt_einsum diff --git a/docs/source/conf.py b/docs/source/conf.py index 86fbdc7a..537edece 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -29,7 +29,6 @@ import sys import os sys.path.insert(0, os.path.abspath('../..')) -import furo #import pathlib #sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix()) @@ -160,4 +159,4 @@ display_gitlab = False show_source = True # -- Options for EPUB output -epub_show_urls = 'footnote' \ No newline at end of file +epub_show_urls = 'footnote' diff --git a/readthedocs.yaml b/readthedocs.yaml new file mode 100644 index 00000000..b664f319 --- /dev/null +++ b/readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.10" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/source/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: docs/requirements.txt From 8f3421b3af518e0d035ed90b96e9a2d615c8d589 Mon Sep 17 00:00:00 2001 From: GenericP3rson Date: Tue, 20 Feb 2024 20:37:16 -0500 Subject: [PATCH 6/6] [minor] adding the missing dependency --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index 597c0496..063be65a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,3 +4,4 @@ recommonmark torchquantum>=0.1 opt_einsum +qiskit_ibm_runtime