From 0ae273bec6cbe52f27ad9d27006e52227ecf45e7 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Fri, 4 Oct 2024 18:32:43 +0200 Subject: [PATCH] * Fixed tests and added comment. --- qopt_best_practices/transpilation/__init__.py | 3 +++ qopt_best_practices/transpilation/qaoa_construction_pass.py | 1 + test/test_qubit_selection.py | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qopt_best_practices/transpilation/__init__.py b/qopt_best_practices/transpilation/__init__.py index e69de29..552a23d 100644 --- a/qopt_best_practices/transpilation/__init__.py +++ b/qopt_best_practices/transpilation/__init__.py @@ -0,0 +1,3 @@ +"""Module with transpiler methods for QAOA like circuits.""" + +from .preset_qaoa_passmanager import qaoa_swap_strategy_pm diff --git a/qopt_best_practices/transpilation/qaoa_construction_pass.py b/qopt_best_practices/transpilation/qaoa_construction_pass.py index ae73fc2..f9d0630 100644 --- a/qopt_best_practices/transpilation/qaoa_construction_pass.py +++ b/qopt_best_practices/transpilation/qaoa_construction_pass.py @@ -76,6 +76,7 @@ def run(self, cost_layer_dag: DAGCircuit): f"{init_state.num_qubits} != {num_qubits}" ) + # Note: converting to circuit is iniefficent. This should be update to DAG only work. cost_layer = dag_to_circuit(cost_layer_dag) qaoa_circuit = QuantumCircuit(num_qubits, num_qubits) diff --git a/test/test_qubit_selection.py b/test/test_qubit_selection.py index 347b98e..80c5503 100644 --- a/test/test_qubit_selection.py +++ b/test/test_qubit_selection.py @@ -49,7 +49,7 @@ def test_qubit_selection(self): path_finder = BackendEvaluator(self.backend) path, _, _ = path_finder.evaluate(len(self.mapped_graph)) - expected_path = [45, 46, 47, 48, 49, 55, 68, 69, 70, 74] + expected_path = [33, 39, 40, 72, 41, 81, 53, 60, 61, 62] self.assertEqual(set(path), set(expected_path)) def test_qubit_selection_v1_v2(self): @@ -59,5 +59,5 @@ def test_qubit_selection_v1_v2(self): for backend in backends: path_finder = BackendEvaluator(backend) path, _, _ = path_finder.evaluate(len(self.mapped_graph)) - expected_path = [1, 2, 4, 7, 8, 10, 11, 12, 13, 14] + expected_path = [8, 9, 11, 12, 13, 14, 15, 18, 21, 23] self.assertEqual(set(path), set(expected_path))