Skip to content

Commit

Permalink
BasisTranslator skips translating gates already in target basis (#6350)…
Browse files Browse the repository at this point in the history
… (#6356)

* skip translating gates in target basis

* Update releasenotes/notes/bugfix-skip-target-basis-translation-12a9fa02c9ceef25.yaml

* fix lint issue

Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 8aceb73)

Co-authored-by: Abdullah Ash- Saki <[email protected]>
  • Loading branch information
mergify[bot] and ashsaki authored May 4, 2021
1 parent 2f74455 commit 497d5a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qiskit/transpiler/passes/basis/basis_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 497d5a4

Please sign in to comment.