Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
# -- Options for {MyST}NB ----------------------------------------------------

nb_execution_mode = "cache"
nb_execution_raise_on_error = True


class CDAStyle(UnsrtStyle):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -235,6 +235,7 @@ def generate_data(
)
except Exception:
logger.exception(f"Error processing circuit {qc.name}.")
raise

# Collect results
specific_data = OrderedDict(counts)
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions tests/resource_estimation/test_error_budget_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading