diff --git a/pyproject.toml b/pyproject.toml index 754920f..1bb09f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "README.md" authors = [{ name = "Haiqu Inc.", email = "info@haiqu.ai" }] license = { file = "LICENSE" } - version = "1.0.10" + version = "1.0.11" requires-python = ">= 3.10" dependencies = [ "qiskit <= 1.0.2", @@ -46,7 +46,7 @@ [project.optional-dependencies] - bqskit = ["bqskit >= 1.1.1"] + bqskit = ["bqskit <= 1.1.2"] pytket = ["pytket >= 1.31.0", "pytket-qiskit >= 0.51.0", diff --git a/rivet_transpiler/transpiler.py b/rivet_transpiler/transpiler.py index e6e4e49..81bd47e 100644 --- a/rivet_transpiler/transpiler.py +++ b/rivet_transpiler/transpiler.py @@ -150,11 +150,9 @@ def transpile_right(central_circuit, right_circuit, # Transpile and Compose - if backend is not None and backend.coupling_map is not None: + full_map = get_full_map(central_circuit) - full_map = get_full_map(central_circuit) - - key_arguments['initial_layout'] = full_map[:right_circuit.num_qubits] + key_arguments['initial_layout'] = full_map[:right_circuit.num_qubits] transpiled_right_circuit = transpile( right_circuit, @@ -189,7 +187,10 @@ def transpile_right(central_circuit, right_circuit, if transpiled_right_circuit.layout.final_layout is None: - right_routing = list(range(transpiled_right_circuit.num_qubits)) + resulting_qubits_count = max(central_circuit.num_qubits, + transpiled_right_circuit.num_qubits) + + right_routing = list(range(resulting_qubits_count)) else: right_routing = [transpiled_right_circuit.layout.final_layout[qubit] @@ -211,13 +212,6 @@ def transpile_right(central_circuit, right_circuit, resulting_circuit._layout = transpile_layout - # Printouts - - # print("central_routing:", central_routing) - # print("right_routing:", right_routing) - # print("final_routing:", final_routing) - # print("final_layout:", final_layout) - return resulting_circuit diff --git a/tests/test_transpiler.py b/tests/test_transpiler.py index 2c46414..ecbb7ac 100644 --- a/tests/test_transpiler.py +++ b/tests/test_transpiler.py @@ -12,6 +12,7 @@ from rivet_transpiler import get_full_map from rivet_transpiler import get_litmus_circuit +from rivet_transpiler import get_used_qubit_indices # Test Transpile Functions @@ -65,6 +66,32 @@ def test_transpile_right(litmus_circuit, backend): assert transpiled_right_circuit +def test_transpile_right_target(litmus_circuit, backend): + + target = backend.target if backend else None + + transpiled_litmus_circuit = qiskit.transpile( + litmus_circuit, + target=target, + seed_transpiler=1234) + + transpiled_right_circuit = transpile_right( + central_circuit=transpiled_litmus_circuit, + right_circuit=litmus_circuit, + target=target, + seed_transpiler=1234) + + litmus_qubits_count = len( + get_used_qubit_indices( + litmus_circuit)) + + transpiled_right_qubits_count = len( + get_used_qubit_indices( + transpiled_right_circuit)) + + assert litmus_qubits_count == transpiled_right_qubits_count + + def test_transpile_left(litmus_circuit, backend): transpiled_litmus_circuit = qiskit.transpile(