Skip to content

Commit

Permalink
Use a more efficient and actually correct circuit for ECR target
Browse files Browse the repository at this point in the history
The previous definition of a swap gate using ECR rz and sx was incorrect
and also not as efficient as possible. This was missed because the tests
were accidently broken since Qiskit#10314 which was fixed in the previous
commit. This commit updates the definition to use one that is actually
correct and also more efficient with fewer 1 qubit gates.

Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
  • Loading branch information
mtreinish and alexanderivrii committed May 1, 2024
1 parent 4e90c08 commit 1a0521e
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions qiskit/circuit/library/standard_gates/equivalence_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,29 +869,16 @@ def _cnot_rxx_decompose(plus_ry: bool = True, plus_rxx: bool = True):
# « └──────────┘ └──────┘└─────────┘ └────┘└──────────┘
#
q = QuantumRegister(2, "q")
def_swap_ecr = QuantumCircuit(q, global_phase=pi / 2)
def_swap_ecr.rz(pi / 2, 0)
def_swap_ecr.sx(0)
def_swap_ecr.rz(pi / 2, 1)
def_swap_ecr.sx(1)
def_swap_ecr.rz(-pi, 1)
def_swap_ecr.ecr(0, 1)
def_swap_ecr.rz(pi / 2, 1)
def_swap_ecr.sx(1)
def_swap_ecr.rz(pi / 2, 0)
def_swap_ecr.sx(0)
def_swap_ecr.rz(-pi, 0)
def_swap_ecr.ecr(0, 1)
def_swap_ecr.rz(pi / 2, 0)
def_swap_ecr.sx(0)
def_swap_ecr = QuantumCircuit(q)
def_swap_ecr.rz(-pi / 2, 0)
def_swap_ecr.sx(1)
def_swap_ecr.ecr(0, 1)
def_swap_ecr.rz(-pi / 2, 0)
def_swap_ecr.rz(-pi / 2, 1)
def_swap_ecr.sx(0)
def_swap_ecr.ecr(1, 0)
def_swap_ecr.rz(-pi / 2, 0)
def_swap_ecr.rz(pi / 2, 1)
def_swap_ecr.sx(1)
def_swap_ecr.rz(-pi / 2, 1)
def_swap_ecr.ecr(0, 1)
_sel.add_equivalence(SwapGate(), def_swap_ecr)

# SwapGate
Expand Down

0 comments on commit 1a0521e

Please sign in to comment.