diff --git a/src/qibo/models/circuit.py b/src/qibo/models/circuit.py index e0a068965..f838ef26d 100644 --- a/src/qibo/models/circuit.py +++ b/src/qibo/models/circuit.py @@ -1110,8 +1110,19 @@ def execute(self, initial_state=None, nshots=1000): backend = _Global.backend() transpiler = _Global.transpiler() + + if backend.qubits is not None: + node_mapping = {q: i for i, q in enumerate(backend.qubits)} + self.wire_names = [node_mapping[q] for q in self.wire_names] + transpiled_circuit, _ = transpiler(self) # pylint: disable=E1102 + if backend.qubits is not None: + self.wire_names = [ + list(node_mapping)[list(node_mapping.values()).index(q)] + for q in self.wire_names + ] + if self.accelerators: # pragma: no cover return backend.execute_distributed_circuit( transpiled_circuit, initial_state, nshots