-
Notifications
You must be signed in to change notification settings - Fork 1k
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
GridDevice serialization refactor #6094
GridDevice serialization refactor #6094
Conversation
3aa0c24
to
3cf2d1d
Compare
9910c79
to
4837660
Compare
"""GateFamilies which match all other valid gate representations.""" | ||
additional_forms: List[cirq.GateFamily] = field(default_factory=list) | ||
"""`primary_forms` (as GateFamilies) + `additional_forms`""" | ||
all_forms: List[cirq.GateFamily] = field(init=False) |
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.
Optional: Should this be a generated @Property instead? I guess, with init=False, they can't specify it, so maybe that's okay.
"""The name of gate type in `GateSpecification`.""" | ||
gate_spec_name: str | ||
"""Gate representations to be included in generated gatesets and gate durations.""" | ||
primary_forms: List[GateOrFamily] |
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.
The primary and additional forms definition is kind of confusing to me. This new terminology is not explained very clearly by these docstrings. Maybe the class docstring could give more context as to what's going on here?
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.
First pass at address comments.
In the latest push:
|
Gateset.gates is a collection of GateFamilies, so most branches in the check don't apply.
…factor/griddevice-serialization-by-serializing-gateset
This refactor adds the
to_proto()
method to serializeGridDevice
intoDeviceSpecification
. The convenience method to create aDeviceSpecification
from partial gateset information,_create_device_specification_proto()
, is also reimplemented asGridDevice.from_device_information()
and returns aGridDevice
instead. These features makes using server-side GridDevice viable - Server-side and client-side GridDevice instances should now be identical.In addition, gateset serialization and deserialization mappings are reorganized into a shared data structure.
cc @maffoo @pavoljuhas