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 cirq.eject_z transformer to replace cirq.EjectZ #4955

Merged
merged 7 commits into from
Feb 7, 2022

Conversation

tanujkhattar
Copy link
Collaborator

@tanujkhattar tanujkhattar requested review from cduck, vtomole and a team as code owners February 4, 2022 12:12
@tanujkhattar tanujkhattar requested a review from maffoo February 4, 2022 12:12
@CirqBot CirqBot added the size: L 250< lines changed <1000 label Feb 4, 2022
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

One docs nit and one question for my own understanding. Looking good!

@@ -664,7 +664,7 @@
"id": "oKcnKYTE-ms3"
},
"source": [
"You can also use the `cirq.EjectZ` optimizer to attempt to push `cirq.Z` gates towards the end of the circuit."
"You can also use the `cirq.eject_z` optimizer to attempt to push `cirq.Z` gates towards the end of the circuit."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should optimzer here be transformer?

Similarly in other docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, but updating the docs correctly would require a larger change. (for example: transformers are now moment preserving, support no compile tags and automated logging - none of this is already covered).

I've created a separate issue to track that docs are updated correctly once the migration is complete -- #4960 and would prefer to make this change (s/optimizer/transformer) there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM.

qubit_phase[q] = 0
if not (key or single_qubit_decompositions.is_negligible_turn(p, atol)):
yield ops.Z(q) ** (p * 2)
elif key:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this key-checking block replaces the if moment_index is not None block in the old code, handling PhasedXZ tracking. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's correct.

The idea here is that if the previous operation acting on the qubit q is a PhasedXZGate then instead of dumping a new Z ** (2 * p) gate on q, we simply modify the previous z exponent of the previous PhasedXZGate.

@tanujkhattar tanujkhattar merged commit 41312e8 into quantumlib:master Feb 7, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
)

* Add eject_z transformer to replace EjectZ

* Replaces usages of EjectZ with eject_z

* Reorder cleanup transformers
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
)

* Add eject_z transformer to replace EjectZ

* Replaces usages of EjectZ with eject_z

* Reorder cleanup transformers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants