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

GoogleCZTargetGateset #5744

Conversation

verult
Copy link
Collaborator

@verult verult commented Jul 13, 2022

  • Added GoogleCZTargetGateset to include postprocess transformers which are previously supported by optimize_for_sycamore, and to allow for future customizations of the CZ target gateset.
    • At this time, SycamoreTargetGateset and SqrtIswapTargetGateset will stay as is because they are no longer necessary for current Google devices. While they are still useful for simulated devices, they don't have to be perfect.

@tanujkhattar
cc @dstrain115

@verult verult requested a review from tanujkhattar July 13, 2022 00:19
@verult verult requested review from wcourtney, a team, vtomole and cduck as code owners July 13, 2022 00:19
@CirqBot CirqBot added the size: L 250< lines changed <1000 label Jul 13, 2022
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

As discussed offline: One minor comment on the GoogleCZTargetGateset implementation; and a request to break up the PRs into 2 smaller PRs. Thanks!

@verult verult force-pushed the cg-device-refactor/google-cz-target-gateset branch from 7d3d2dd to a7669b9 Compare July 14, 2022 01:29
Comment on lines 37 to 38
cirq.GateFamily(cirq.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()]),
cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[cirq_google.PhysicalZTag()]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't including both of these gate families is equivalent to including the type gate family for cirq.ZPowGate ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's true. My preference is to keep it the way it is, to mimic the GateFamily entries in GridDevice, but either way works.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think including both in a test is confusing. It would be better to have different tests; by including one of each (maybe controlled by a flag)?

Also; do you think we should have a default value for additional_gates in the Google target gateset? What's the default for a google device? Do we accept both virtual and physical zs by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Synced offline. Will stay with an empty default. Tests are now split.

Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

Looks fine to me modulo the docstring and Tanuj's comments



class GoogleCZTargetGateset(cirq.CZTargetGateset):
"""CZTargetGateset implementation tailored to Google devices."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer a more explanatory test. This is a fine one-line summary, but I would like to see a further description, such as why it is tailored to Google devices.

@verult verult force-pushed the cg-device-refactor/google-cz-target-gateset branch from a762004 to 17b4b59 Compare July 15, 2022 23:39
@verult
Copy link
Collaborator Author

verult commented Jul 15, 2022

Discovered an issue (#5783). Will investigate and address in a separate PR.

@verult verult requested a review from tanujkhattar July 16, 2022 00:26
@verult
Copy link
Collaborator Author

verult commented Jul 16, 2022

Issue is fixed

@dstrain115
Copy link
Collaborator

Looks like a flaky test due to floating precision, I re-ran tests to see if it fixes it.

(
# PhysicalZ tag is erased
cirq.Circuit(
cirq.Z(_qa).with_tags(cirq_google.PhysicalZTag()) ** 0.5, cirq.CZ(_qa, _qb)
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI: this needs to be (cirq.Z(_qa) ** 0.5).with_tags(cirq_google.PhysicalZTag()). Otherwise the exponentiation drops the tag.

I would also just tweak this test to get the weird floating point failure on macos to go away. Maybe just try 0.25 or 0.125 to see if it disappears. We can figure out a better way to test approximate equals after 1.0.

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

CirqBot commented Jul 16, 2022

Automerge cancelled: A required status check is not present.

Missing statuses: ['Build docs', 'Build protos', 'Coverage check', 'Misc check', 'Notebook formatting', 'Pytest MacOS (3.7)', 'Pytest MacOS (3.8)', 'Pytest MacOS (3.9)', 'Pytest Ubuntu (3.7)', 'Pytest Ubuntu (3.8)', 'Pytest Ubuntu (3.9)', 'Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@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 Jul 16, 2022
@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 17, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 17, 2022
@tanujkhattar tanujkhattar merged commit 7062846 into quantumlib:master Jul 17, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Jul 17, 2022

Automerge cancelled: Pull Request is not mergeable.

@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 Jul 17, 2022
CirqBot pushed a commit that referenced this pull request Jul 18, 2022
…target gatesets (#5765)

* GridDevice target gateset generation logic now matches all required gates for a particular gateset, rather than just the 2q gate.
* In target gatesets that support additional_gates, it's set to all gates in a device's gateset other than required gates in the target gateset, so that device gates are not decomposed during circuit transformation.

First commit is from #5744

@tanujkhattar 
cc @dstrain115
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Introducing GoogleCZTargetGateset

* Change constructor flag to control both eject_z and eject_phased_paulis transformers

* Updated testing for eject_paulis

* Fix constructor docstring

* Split tests to individual gate families

* Added more details in class docstring

* Raising an op to a power removes tags. Exponentiating the gate instead

* Exponentiate on gate instead of TaggedOperation; changed exp value to try to bypass precision error

Co-authored-by: Cirq Bot <craiggidney+github+cirqbot@google.com>
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…target gatesets (quantumlib#5765)

* GridDevice target gateset generation logic now matches all required gates for a particular gateset, rather than just the 2q gate.
* In target gatesets that support additional_gates, it's set to all gates in a device's gateset other than required gates in the target gateset, so that device gates are not decomposed during circuit transformation.

First commit is from quantumlib#5744

@tanujkhattar 
cc @dstrain115
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.

None yet

6 participants