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 to_phased_xz_gate function for SingleQubitCliffordGate #4050

Merged
merged 19 commits into from
May 19, 2021

Conversation

bichengying
Copy link
Collaborator

Allow transferring SingleQubitCliffordGate to Phased X and Z Gates.

@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Apr 25, 2021
@bichengying
Copy link
Collaborator Author

In case, it is not intuitive how clifford gates can be transferred to phased xz gates, take a look at following gif as example:
Example output animation

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with typo nits

cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
a = 0.0
x = -0.5 if x_to.flip ^ z_to.flip else 0.5
z = -0.5 if x_to.flip else 0.5
# It is impossible that there are other cases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe rephrase the last branch to:

else: 
 # the only possible case left
  assert (x_to.to, z_to.to) == (pauli_gates.Y, pauli_gates.X)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks beter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, face rotation may be ambiguous at first glance, I learn it called axis swapping rotation in some literatures.

cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
* {middle point of xyz in 4 Quadrant} * {120, 240} --- rotation in face
note 1 + 9 + 6 + 8 = 24 in total.

To associate with Clifford Tableau, it can also be grouped by 4:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this information here is useful at all...in the end we use the above axis/degree categorization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if branch is based on the second group while the gate name is based on the first group.
I particularly choose the second group is for preparing to switch to the Tableau-based approach.

For example, the condition (x_to.to, z_to.to) == (pauli_gates.X, pauli_gates.Z) can be directly convert into something like tableau.matrix() == np.array([[1, 0], [0, 1]]).
Each branch condition is corresponding one of the six symplectic matrices.

cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
cirq-core/cirq/ops/clifford_gate.py Outdated Show resolved Hide resolved
bichengying and others added 12 commits May 18, 2021 17:58
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>
Co-authored-by: Balint Pato <balopat@users.noreply.github.com>

To associate with Clifford Tableau, it can also be grouped by 4:
* {I,X,Y,Z} is [[1 0], [0, 1]]
* {+/- X_sqrt, 2 Hadamard-like gates acting on the XZ plane} is [[1, 0], [1, 1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {+/- X_sqrt, 2 Hadamard-like gates acting on the XZ plane} is [[1, 0], [1, 1]]
* {+/- X_sqrt, 2 Hadamard-like gates acting on the XY plane} is [[1, 0], [1, 1]]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I found both this one and the comment in the following Z_sqrt was wrong as well. Fixed now. (Comments under the if-else branches are correct).

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label May 19, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label May 19, 2021
@CirqBot
Copy link
Collaborator

CirqBot commented May 19, 2021

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels May 19, 2021
@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label May 19, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label May 19, 2021
@CirqBot CirqBot merged commit 3e06fdf into quantumlib:master May 19, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels May 19, 2021
NoureldinYosri pushed a commit to NoureldinYosri/Cirq that referenced this pull request May 25, 2021
…b#4050)

Allow transferring SingleQubitCliffordGate to Phased X and Z Gates.
@bichengying bichengying deleted the clifford branch August 13, 2021 06:19
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…b#4050)

Allow transferring SingleQubitCliffordGate to Phased X and Z Gates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants