Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize two_qubit_decomposition for odd CNOTs to preserve determinant 1 #6999

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pennylane/ops/op_math/decompositions/two_qubit_unitary.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ def _decomposition_1_cnot(U, wires):
C_ops = one_qubit_decomposition(C, wires[0])
D_ops = one_qubit_decomposition(D, wires[1])

return C_ops + D_ops + [qml.CNOT(wires=wires)] + A_ops + B_ops
# GlobalPhase added to preserve the determinant 1
# (as CNOT has determinant -1, see paragraph below
# Lemma II.1 in https://arxiv.org/abs/quant-ph/0308033)
return C_ops + D_ops + [qml.CNOT(wires=wires)] + A_ops + B_ops + [qml.GlobalPhase(np.pi / 4)]


def _decomposition_2_cnots(U, wires):
Expand Down Expand Up @@ -532,7 +535,10 @@ def _decomposition_3_cnots(U, wires):
D_ops = one_qubit_decomposition(D, wires[1])

# Return the full decomposition
return C_ops + D_ops + interior_decomp + A_ops + B_ops
# GlobalPhase added to preserve the determinant 1
# (as CNOT has determinant -1, see paragraph below
# Lemma II.1 in https://arxiv.org/abs/quant-ph/0308033)
return C_ops + D_ops + interior_decomp + A_ops + B_ops + [qml.GlobalPhase(np.pi / 4)]


def two_qubit_decomposition(U, wires):
Expand Down
Loading