diff --git a/qiskit/transpiler/passes/basis/basis_translator.py b/qiskit/transpiler/passes/basis/basis_translator.py index df329165e61b..7dbea4dee2e0 100644 --- a/qiskit/transpiler/passes/basis/basis_translator.py +++ b/qiskit/transpiler/passes/basis/basis_translator.py @@ -269,6 +269,9 @@ def _basis_search(equiv_lib, source_basis, target_basis, heuristic): closed_set.add(current_basis) for gate_name, gate_num_qubits in current_basis: + if gate_name in target_basis: + continue + equivs = equiv_lib._get_equivalences((gate_name, gate_num_qubits)) basis_remain = current_basis - {(gate_name, gate_num_qubits)} diff --git a/releasenotes/notes/bugfix-skip-target-basis-translation-12a9fa02c9ceef25.yaml b/releasenotes/notes/bugfix-skip-target-basis-translation-12a9fa02c9ceef25.yaml new file mode 100644 index 000000000000..c139b7919036 --- /dev/null +++ b/releasenotes/notes/bugfix-skip-target-basis-translation-12a9fa02c9ceef25.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed an issue with :class:`~qiskit.transpiler.passes.BasisTranslator` where in some + cases it would translate gates already in the target basis.