Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
121 changes: 30 additions & 91 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down
112 changes: 33 additions & 79 deletions source/qdk_package/tests-integration/interop_qiskit/test_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Loading