From 7d14428fec83f0ccc19ca606a7dab9eb82db45ad Mon Sep 17 00:00:00 2001 From: joao-boechat Date: Tue, 29 Sep 2026 16:45:37 -0700 Subject: [PATCH] remove tests for qiskit 1.x --- build.py | 121 +++++------------- .../interop_qiskit/test_re.py | 112 +++++----------- .../tests-integration/test_requirements.txt | 2 +- 3 files changed, 64 insertions(+), 171 deletions(-) diff --git a/build.py b/build.py index ecaa542d8c7..bd0e2b1972c 100755 --- a/build.py +++ b/build.py @@ -189,17 +189,6 @@ def step_end(): qdk_src_dir, "vscode", "test", "course-notebooks" ) -QISKIT_VERSION_MATRIX = [ - { - "label": "qiskit>=1.3.0,<2.0.0", - "requirements": ["qiskit>=1.3.0,<2.0.0"], - }, - { - "label": "qiskit>=2.0.0,<3.0.0", - "requirements": ["qiskit>=2.0.0,<3.0.0"], - }, -] - def run(cmd, cwd, env=None): subprocess.run(cmd, check=True, text=True, cwd=cwd, env=env) @@ -444,7 +433,7 @@ def run_python_checks(): def install_python_test_requirements(cwd, interpreter, check: bool = True): requirements_file_path = os.path.join(cwd, "test_requirements.txt") with open(requirements_file_path, "r", encoding="utf-8") as f: - # Skip empty or commented lines so version-specific packages can be injected separately. + # Skip empty or commented lines requirements = [ line.strip() for line in f @@ -589,25 +578,9 @@ def run_ci_historic_benchmark(): install_from_wheels(python_bin, "qdk", cwd=test_dir) step_end() - for version in QISKIT_VERSION_MATRIX: - step_start( - f"Running integration tests for the qdk package ({version['label']})" - ) - - version_install_args = [ - python_bin, - "-m", - "pip", - "install", - "--upgrade", - "--upgrade-strategy", - "eager", - ] + version["requirements"] - subprocess.run(version_install_args, check=True, text=True, cwd=test_dir) - - run_python_integration_tests(test_dir, python_bin) - - step_end() + step_start("Running integration tests for the qdk package") + run_python_integration_tests(test_dir, python_bin) + step_end() if args.course_notebook_tests: @@ -794,72 +767,38 @@ def run_ci_historic_benchmark(): "pandas", "qutip", "pyqir", + "qiskit>=2.0.0,<3.0.0", cwd=root_dir, env=pip_env, ) - qiskit_notebooks = [ - notebook - for notebook in notebook_files - if ( - "qiskit" in os.path.basename(notebook).lower() - or "estimation-openqasm" in os.path.basename(notebook).lower() - ) - ] - other_notebooks = [ - notebook for notebook in notebook_files if notebook not in qiskit_notebooks - ] - - def _run_notebooks(files): - for notebook in files: - print(f"Running {notebook}") - # Run the notebook process, capturing stdout and only displaying it if there is an error - result = subprocess.run( - [ - python_bin, - "-m", - "nbconvert", - "--to", - "notebook", - "--stdout", - "--ExecutePreprocessor.timeout=90", - "--sanitize-html", - "--execute", - notebook, - ], - check=False, - text=True, - cwd=root_dir, - env=pip_env, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - encoding="utf-8", - ) - if result.returncode != 0: - print(result.stdout) - raise Exception(f"Error running {notebook}") - - if other_notebooks: - print("Executing notebooks") - _run_notebooks(other_notebooks) - - if qiskit_notebooks: - for version in QISKIT_VERSION_MATRIX: - print(f"Executing Qiskit notebooks with {version['label']}") - version_install_args = [ + for notebook in notebook_files: + print(f"Running {notebook}") + # Run the notebook process, capturing stdout and only displaying it if there is an error + result = subprocess.run( + [ python_bin, "-m", - "pip", - "install", - "--upgrade", - "--upgrade-strategy", - "eager", - ] + version["requirements"] - subprocess.run( - version_install_args, check=True, text=True, cwd=root_dir, env=pip_env - ) - - _run_notebooks(qiskit_notebooks) + "nbconvert", + "--to", + "notebook", + "--stdout", + "--ExecutePreprocessor.timeout=90", + "--sanitize-html", + "--execute", + notebook, + ], + check=False, + text=True, + cwd=root_dir, + env=pip_env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding="utf-8", + ) + if result.returncode != 0: + print(result.stdout) + raise Exception(f"Error running {notebook}") step_end() diff --git a/source/qdk_package/tests-integration/interop_qiskit/test_re.py b/source/qdk_package/tests-integration/interop_qiskit/test_re.py index 30501fbfaba..6f17913021d 100644 --- a/source/qdk_package/tests-integration/interop_qiskit/test_re.py +++ b/source/qdk_package/tests-integration/interop_qiskit/test_re.py @@ -21,7 +21,6 @@ from qiskit.circuit import QuantumCircuit, Parameter from qiskit.circuit.library import RGQFTMultiplier from qdk.qiskit import ResourceEstimatorBackend - from qiskit.version import __version__ as QISKIT_VERSION @pytest.mark.skipif(not QISKIT_AVAILABLE, reason=SKIP_REASON) @@ -65,32 +64,17 @@ def test_estimate_qiskit_rgqft_multiplier() -> None: res = job.result() assert res["status"] == "success" - if QISKIT_VERSION.startswith("1."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 90, - "rotationCount": 972, - "rotationDepth": 666, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - elif QISKIT_VERSION.startswith("2."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 154, - "rotationCount": 574, - "rotationDepth": 374, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - else: - assert False, f"Unsupported Qiskit version {QISKIT_VERSION}." + assert res.logical_counts == LogicalCounts( + { + "numQubits": 16, + "tCount": 154, + "rotationCount": 574, + "rotationDepth": 374, + "cczCount": 0, + "ccixCount": 0, + "measurementCount": 0, + } + ) @pytest.mark.skipif(not QISKIT_AVAILABLE, reason=SKIP_REASON) @@ -103,32 +87,17 @@ def test_estimate_qiskit_rgqft_multiplier_without_tranpspile() -> None: res = job.result() assert res["status"] == "success" - if QISKIT_VERSION.startswith("1."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 76, - "rotationCount": 936, - "rotationDepth": 665, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - elif QISKIT_VERSION.startswith("2."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 140, - "rotationCount": 532, - "rotationDepth": 369, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - else: - assert False, f"Unsupported Qiskit version {QISKIT_VERSION}." + assert res.logical_counts == LogicalCounts( + { + "numQubits": 16, + "tCount": 140, + "rotationCount": 532, + "rotationDepth": 369, + "cczCount": 0, + "ccixCount": 0, + "measurementCount": 0, + } + ) @pytest.mark.skipif(not QISKIT_AVAILABLE, reason=SKIP_REASON) @@ -142,32 +111,17 @@ def test_estimate_qiskit_rgqft_multiplier_in_threadpool() -> None: res = job.result() assert res["status"] == "success" - if QISKIT_VERSION.startswith("1."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 76, - "rotationCount": 936, - "rotationDepth": 665, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - elif QISKIT_VERSION.startswith("2."): - assert res.logical_counts == LogicalCounts( - { - "numQubits": 16, - "tCount": 140, - "rotationCount": 532, - "rotationDepth": 369, - "cczCount": 0, - "ccixCount": 0, - "measurementCount": 0, - } - ) - else: - assert False, f"Unsupported Qiskit version {QISKIT_VERSION}." + assert res.logical_counts == LogicalCounts( + { + "numQubits": 16, + "tCount": 140, + "rotationCount": 532, + "rotationDepth": 369, + "cczCount": 0, + "ccixCount": 0, + "measurementCount": 0, + } + ) @pytest.mark.skipif(not QISKIT_AVAILABLE, reason=SKIP_REASON) diff --git a/source/qdk_package/tests-integration/test_requirements.txt b/source/qdk_package/tests-integration/test_requirements.txt index 5bb625984b6..43abe8d2e5e 100644 --- a/source/qdk_package/tests-integration/test_requirements.txt +++ b/source/qdk_package/tests-integration/test_requirements.txt @@ -1,9 +1,9 @@ pytest==9.0.3 qirrunner==0.9.0 pyqir>=0.12.6,<0.13 +qiskit>=2.0.0,<3.0.0 qiskit-aer==0.17.2 qiskit_qasm3_import==0.6.0 expecttest==0.3.0 numpy>=1.26.4 cirq-core>=1.6.1,<1.7 -# Qiskit distributions are installed per test run by build.py.