-
Notifications
You must be signed in to change notification settings - Fork 982
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 method to get a Clifford gate and phase global phase from unitary #5568
Conversation
# decomposition. | ||
self._state.apply_global_phase(u[k] / final_unitary[k]) | ||
# Apply global phase. | ||
self._state.apply_global_phase(global_phase) |
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.
This has become nice.
cirq.SingleQubitCliffordGate.X_nsqrt, | ||
cirq.SingleQubitCliffordGate.Y_nsqrt, | ||
cirq.SingleQubitCliffordGate.Z_nsqrt, | ||
), |
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.
No action needed: It just occurred to me how weird this selection of test inputs is (it's all over this file, not just in this PR). Single-qubit Clifford group has five conjugacy classes:
- identity,
- three Paulis,
- six square roots of Paulis,
- six "Hadamards",
- eight order-3 elements like (I+iX+iY+iZ)/2.
We're testing on all elements from the first three and a single element from the "Hadamards" and none of the order-3 elements. I'll do something about this later.
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.
Yes, I thought this as well. We should really have a member cirq.SingleQubitCliffordGate.ALL
which contains all 24 clifford gates. Then tests can be parametrized on that.
Fixes #2847
Various options were proposed in the linked issue to handle global phase in
SingleQubitCliffordGate
, but I think the cleanest is the one proposed by @viathor in the description, namely to return a tuple (Clifford, phase) rather than trying to add global phase to the gates themselves. I've added a new helper methodfrom_unitary_with_global_phase
which does this, and modified the stabilizer simulator to use this rather than doing its own global phase correction.