-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add decomposition for CCZ gate and IonQTargetGateset when qubits are all-to-all connected #6095
Changes from 14 commits
aa8077f
d5f8c98
9555f31
219c710
e31bc96
1d85158
a89bf4c
397b9a7
e12eda1
79f9c3a
cf3c640
eea47ce
b4ca8d7
f3bf72d
8c5afe7
4d835d7
6a1f140
02c49a0
d31fc77
210f720
ca5b113
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,6 +201,7 @@ | |
CCXPowGate, | ||
CCZ, | ||
CCZPowGate, | ||
decompose_all_to_all_connect_ccz_gate, | ||
CSWAP, | ||
CSwapGate, | ||
FREDKIN, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,55 @@ def controlled( | |
) | ||
|
||
|
||
def decompose_all_to_all_connect_ccz_gate( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this decomposition and corresponding test to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
ccz_gate: 'CCZPowGate', qubits: Tuple['cirq.Qid', ...] | ||
) -> 'cirq.OP_TREE': | ||
"""If qubits are all-to-all connected, e.g. qubits in the same ion trap, | ||
the decomposition will be: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary line in the docstring should be a single line with <= 100 characters followed by an empty newline and then a detailed description if needed. Please update here and elsewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks for the guide. |
||
|
||
0: ──────────────@──────────────────@───@───p──────@─── | ||
│ │ │ │ | ||
1: ───@──────────┼───────@───p──────┼───X───p^-1───X─── | ||
│ │ │ │ | ||
2: ───X───p^-1───X───p───X───p^-1───X───p────────────── | ||
|
||
where p = T**ccz_gate._exponent | ||
""" | ||
if len(qubits) != 3: | ||
raise ValueError(f'Expect 3 qubits for CCZ gate, got {len(qubits)} qubits.') | ||
|
||
a, b, c = qubits | ||
|
||
p = common_gates.T**ccz_gate._exponent | ||
global_phase = 1j ** (2 * ccz_gate.global_shift * ccz_gate._exponent) | ||
global_phase = ( | ||
complex(global_phase) | ||
if protocols.is_parameterized(global_phase) and global_phase.is_complex # type: ignore | ||
else global_phase | ||
) | ||
global_phase_operation = ( | ||
[global_phase_op.global_phase_operation(global_phase)] | ||
if protocols.is_parameterized(global_phase) or abs(global_phase - 1.0) > 0 | ||
else [] | ||
) | ||
|
||
return global_phase_operation + [ | ||
common_gates.CNOT(b, c), | ||
p(c) ** -1, | ||
common_gates.CNOT(a, c), | ||
p(c), | ||
common_gates.CNOT(b, c), | ||
p(c) ** -1, | ||
common_gates.CNOT(a, c), | ||
p(b), | ||
p(c), | ||
common_gates.CNOT(a, b), | ||
p(a), | ||
p(b) ** -1, | ||
common_gates.CNOT(a, b), | ||
] | ||
|
||
|
||
@value.value_equality() | ||
class ThreeQubitDiagonalGate(raw_types.Gate): | ||
r"""A three qubit gate whose unitary is given by a diagonal $8 \times 8$ matrix. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove from
cirq/ops/__init__.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done