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

Add method to get a Clifford gate and phase global phase from unitary #5568

Merged
merged 5 commits into from
Jun 22, 2022

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Jun 21, 2022

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 method from_unitary_with_global_phase which does this, and modified the stabilizer simulator to use this rather than doing its own global phase correction.

@maffoo maffoo requested review from a team, vtomole and cduck as code owners June 21, 2022 20:09
@maffoo maffoo requested a review from pavoljuhas June 21, 2022 20:09
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 21, 2022
# decomposition.
self._state.apply_global_phase(u[k] / final_unitary[k])
# Apply global phase.
self._state.apply_global_phase(global_phase)
Copy link
Collaborator

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,
),
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@maffoo maffoo merged commit 27488c6 into master Jun 22, 2022
@maffoo maffoo deleted the u/maffoo/clifford branch June 22, 2022 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global phase in SingleQubitCliffordGate
3 participants