diff --git a/docs/conf.py b/docs/conf.py index 3650f7ec..83a12c5d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -98,6 +98,7 @@ # -- Options for {MyST}NB ---------------------------------------------------- nb_execution_mode = "cache" +nb_execution_raise_on_error = True class CDAStyle(UnsrtStyle): diff --git a/src/mqt/problemsolver/resource_estimation/error_budget_optimization/generate_data.py b/src/mqt/problemsolver/resource_estimation/error_budget_optimization/generate_data.py index c908a43a..b7bb9699 100644 --- a/src/mqt/problemsolver/resource_estimation/error_budget_optimization/generate_data.py +++ b/src/mqt/problemsolver/resource_estimation/error_budget_optimization/generate_data.py @@ -225,7 +225,7 @@ def generate_data( transpiled_qc = transpile(qc, basis_gates=QISKIT_STD_GATES, optimization_level=1) try: # Estimate logical counts - counts = estimate(transpiled_qc)["logicalCounts"] + counts = estimate(transpiled_qc, skip_transpilation=True)["logicalCounts"] if counts["rotationCount"] == 0: continue # Skip circuits without rotations, as we want to ensure distributing error budgets among all three types. # Optimize error budgets @@ -235,6 +235,7 @@ def generate_data( ) except Exception: logger.exception(f"Error processing circuit {qc.name}.") + raise # Collect results specific_data = OrderedDict(counts) @@ -259,6 +260,7 @@ def generate_data( ) except Exception: logger.exception(f"Error processing logical counts entry {c}.") + raise # Collect results specific_data = OrderedDict(counts) diff --git a/tests/resource_estimation/test_error_budget_optimization.py b/tests/resource_estimation/test_error_budget_optimization.py index 695ab92a..0cb6ec0d 100644 --- a/tests/resource_estimation/test_error_budget_optimization.py +++ b/tests/resource_estimation/test_error_budget_optimization.py @@ -8,17 +8,24 @@ from __future__ import annotations +import pytest + from mqt.problemsolver.resource_estimation.error_budget_optimization import evaluate, generate_data, train -def test_error_budget_optimization() -> None: +@pytest.mark.parametrize("benchmark", ["qft", "ae"]) +def test_error_budget_optimization(benchmark: str) -> None: total_error_budget = 0.1 - benchmarks_and_sizes = [("qft", [3, 4, 5])] + benchmarks_and_sizes = [(benchmark, [3, 4, 5])] data = generate_data( total_error_budget=total_error_budget, number_of_randomly_generated_distributions=10, benchmarks_and_sizes=benchmarks_and_sizes, ) + assert len(data) == 3 + assert [row["numQubits"] for row in data] == [3, 4, 5] + for row in data: + assert row["logical"] + row["t_states"] + row["rotations"] == pytest.approx(total_error_budget) model, x_test, y_test = train(data) y_pred = model.predict(x_test) evaluate(x_test, y_pred, total_error_budget)