-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GoogleCZTargetGateset #5744
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
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.
As discussed offline: One minor comment on the GoogleCZTargetGateset implementation; and a request to break up the PRs into 2 smaller PRs. Thanks!
cirq-google/cirq_google/transformers/target_gatesets/google_cz_gateset.py
Show resolved
Hide resolved
cirq-google/cirq_google/transformers/target_gatesets/google_cz_gateset.py
Show resolved
Hide resolved
7d3d2dd
to
a7669b9
Compare
cirq-google/cirq_google/transformers/target_gatesets/google_cz_gateset.py
Show resolved
Hide resolved
cirq-google/cirq_google/transformers/target_gatesets/google_cz_gateset.py
Outdated
Show resolved
Hide resolved
cirq.GateFamily(cirq.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()]), | ||
cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[cirq_google.PhysicalZTag()]), |
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.
Isn't including both of these gate families is equivalent to including the type gate family for cirq.ZPowGate
?
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.
That's true. My preference is to keep it the way it is, to mimic the GateFamily entries in GridDevice, but either way works.
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.
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?
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.
Synced offline. Will stay with an empty default. Tests are now split.
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.
Looks fine to me modulo the docstring and Tanuj's comments
|
||
|
||
class GoogleCZTargetGateset(cirq.CZTargetGateset): | ||
"""CZTargetGateset implementation tailored to Google devices.""" |
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.
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.
a762004
to
17b4b59
Compare
Discovered an issue (#5783). Will investigate and address in a separate PR. |
Issue is fixed |
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) |
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.
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.
… try to bypass precision error
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'] |
Automerge cancelled: Pull Request is not mergeable. |
…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
* 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 <[email protected]>
…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
…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
GoogleCZTargetGateset
to include postprocess transformers which are previously supported byoptimize_for_sycamore
, and to allow for future customizations of the CZ target gateset.SycamoreTargetGateset
andSqrtIswapTargetGateset
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