From 6145cc98335a88ee97484680d8c29765aa7832e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Abad=20L=C3=B3pez?= <109400222+GuillermoAbadLopez@users.noreply.github.com> Date: Thu, 23 Jan 2025 11:57:41 +0100 Subject: [PATCH] Change logical-physical by {logical: physical}, for a more explicit keys and value statement. And reversed logica-physical in the `Circuitmap.final_layout()` --- src/qibo/transpiler/abstract.py | 2 +- src/qibo/transpiler/asserts.py | 4 ++-- src/qibo/transpiler/pipeline.py | 2 +- src/qibo/transpiler/router.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qibo/transpiler/abstract.py b/src/qibo/transpiler/abstract.py index 58ec054153..aef72ab43b 100644 --- a/src/qibo/transpiler/abstract.py +++ b/src/qibo/transpiler/abstract.py @@ -47,7 +47,7 @@ def __call__(self, circuit: Circuit, *args) -> Tuple[Circuit, dict]: circuit (:class:`qibo.models.circuit.Circuit`): Circuit to be routed. Returns: - (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final logical-physical qubit mapping. + (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final {logical: physical} qubit mapping. """ diff --git a/src/qibo/transpiler/asserts.py b/src/qibo/transpiler/asserts.py index d47168b586..3e684d264c 100644 --- a/src/qibo/transpiler/asserts.py +++ b/src/qibo/transpiler/asserts.py @@ -32,7 +32,7 @@ def assert_transpiling( original_circuit (:class:`qibo.models.circuit.Circuit`): Circuit before transpiling. transpiled_circuit (:class:`qibo.models.circuit.Circuit`): Circuit after transpiling. connectivity (:class:`networkx.Graph`): Hardware connectivity. - final_layout (dict): Final logical-physical qubit mapping. + final_layout (dict): Final {logical: physical} qubit mapping. native_gates (:class:`qibo.transpiler.unroller.NativeGates`, optional): Native gates supported by the hardware. Defaults to :class:`qibo.transpiler.unroller.NativeGates.default()`. check_circuit_equivalence (bool, optional): Check if the transpiled circuit is equivalent to the original one. @@ -68,7 +68,7 @@ def assert_circuit_equivalence( Args: original_circuit (:class:`qibo.models.circuit.Circuit`): Circuit before transpiling. transpiled_circuit (:class:`qibo.models.circuit.Circuit`): Circuit after transpiling. - final_layout (dict): Final logical-physical qubit mapping. + final_layout (dict): Final {logical: physical} qubit mapping. test_states (list, optional): List of states to test the equivalence. If ``None``, ``ntests`` random states will be tested. Defauts to ``None``. ntests (int, optional): Number of random states to test the equivalence. Defaults to :math: `3`. diff --git a/src/qibo/transpiler/pipeline.py b/src/qibo/transpiler/pipeline.py index 689d026aef..0d63138aa3 100644 --- a/src/qibo/transpiler/pipeline.py +++ b/src/qibo/transpiler/pipeline.py @@ -77,7 +77,7 @@ def __call__(self, circuit): circuit (:class:`qibo.models.circuit.Circuit`): Circuit to be transpiled. Returns: - (:class:`qibo.models.circuit.Circuit`, dict): Transpiled circuit and final logical-physical qubit mapping. + (:class:`qibo.models.circuit.Circuit`, dict): Transpiled circuit and final {logical: physical} qubit mapping. """ final_layout = None diff --git a/src/qibo/transpiler/router.py b/src/qibo/transpiler/router.py index 1798381bf2..8d785f53d5 100644 --- a/src/qibo/transpiler/router.py +++ b/src/qibo/transpiler/router.py @@ -245,7 +245,7 @@ def routed_circuit(self, circuit_kwargs: Optional[dict] = None): return self._routed_blocks.circuit(circuit_kwargs=circuit_kwargs) def final_layout(self): - """Returns the final physical-logical qubits mapping.""" + """Returns the final {logical: physical} qubits mapping.""" return {self.wire_names[i]: self._l2p[i] for i in range(self.nqubits)} @@ -338,7 +338,7 @@ def __call__(self, circuit: Circuit): circuit (:class:`qibo.models.circuit.Circuit`): Circuit to be matched to hardware connectivity. Returns: - (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final logical-physical qubit mapping. + (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final {logical: physical} qubit mapping. """ assert_placement(circuit, self.connectivity) self._preprocessing(circuit=circuit) @@ -519,7 +519,7 @@ def _update_front_layer(self): def _preprocessing(self, circuit: Circuit): """The following objects will be initialised: - - circuit: class to represent circuit and to perform logical-physical qubit mapping. + - circuit: class to represent circuit and to perform {logical: physical} qubit mapping. - _final_measurements: measurement gates at the end of the circuit. - _front_layer: list containing the blocks to be executed. @@ -629,7 +629,7 @@ def __call__(self, circuit: Circuit): circuit (:class:`qibo.models.circuit.Circuit`): Circuit to be routed. Returns: - (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final logical-physical qubit mapping. + (:class:`qibo.models.circuit.Circuit`, dict): Routed circuit and final {logical: physical} qubit mapping. """ assert_placement(circuit, self.connectivity) self._preprocessing(circuit=circuit) @@ -669,7 +669,7 @@ def added_swaps(self): def _preprocessing(self, circuit: Circuit): """The following objects will be initialised: - - circuit: class to represent circuit and to perform logical-physical qubit mapping. + - circuit: class to represent circuit and to perform {logical: physical} qubit mapping. - _final_measurements: measurement gates at the end of the circuit. - _dist_matrix: matrix reporting the shortest path lengh between all node pairs. - _dag: direct acyclic graph of the circuit based on commutativity.