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 metadata property for cirq_google devices. #4869

Merged
merged 8 commits into from
Jan 26, 2022

Conversation

MichaelBroughton
Copy link
Collaborator

Adds metadata properties to cirq_google devices. Part of #4743 .

Note for @dstrain115 and @verult : I don't expect these metadata properties to take this exact form forever and that we may end up changing things once we have a more firmed up plan for how DeviceSpec protos and serialization might change.

@CirqBot CirqBot added the size: M 50< lines changed <250 label Jan 21, 2022
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.

Do we want to make a note that this may change in the future so as not to lock ourselves into a backward incompatibility problem?

if len(pair) == 2 and pair[0] < pair[1]
],
cirq.Gateset(
*[g for g in gate_definitions.keys() if isinstance(g, (cirq.Gate, type(cirq.Gate)))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this (cirq.Gate, type(cirq.Gate))? This seems redundant but I assume there's a good reason for it?

Copy link
Collaborator Author

@MichaelBroughton MichaelBroughton Jan 21, 2022

Choose a reason for hiding this comment

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

Full disclosure: Things in this module are in pretty rough shape. In tests, the type contracts are somehow getting violated in this constructor and other "non Type[_Gate]" things are making it into this function. I'm working on deprecating qid_pairs in cirq-core and there are a few hangups in cirq_google that this PR will help unblock.

High level is I want to make sure we keep cirq-core pristine and cirq-google devices limping along in whatever weird state it is in so that we can finish the items here #4744 and then make a more focused effort on cleaning this up knowing that cirq-core now gives a solid foundation.

This weirdness keeps cirq-google behaving, albeit weirdly.

RE: backwards compatibility and changing in the future we should make a more focused effort on SerializableDevice before we cut our next release, I just don't think in this PR as things are bound to keep changing a lot here before that next release.

cirq.Gateset(
*[g for g in gate_definitions.keys() if isinstance(g, (cirq.Gate, type(cirq.Gate)))]
),
None,
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 the gate durations exist currently, so I think we could populate this if we wanted to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but I think it's best left for when we can turn 100% of our attention to cleaning up things for SerializableDevice this PR is a means to an end for getting cleaner deprecations happening in cirq-core for qid_pairs.

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.

Behavior looks good, but I have some concerns about typing.

Copy link
Collaborator

@verult verult left a comment

Choose a reason for hiding this comment

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

Please feel free to ignore nits

(pair[0], pair[1])
for gate_defs in gate_definitions.values()
for gate_def in gate_defs
if gate_def.number_of_qubits == 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering: this is just a defensive check right? It should never be false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, I just copied this from lower down in the module qid_pairs function.

@95-martin-orion
Copy link
Collaborator

My concerns are resolved - leaving further review to other reviewers.

@verult
Copy link
Collaborator

verult commented Jan 22, 2022

LGTM, and changing the minimum to unblock cirq-core changes and revisiting in my project sgtm.

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

CirqBot commented Jan 25, 2022

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 Jan 25, 2022
@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jan 26, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jan 26, 2022
@CirqBot CirqBot merged commit 12ebe83 into quantumlib:master Jan 26, 2022
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jan 26, 2022
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jan 26, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Adds metadata properties to cirq_google devices. Part of  quantumlib#4743 .


Note for @dstrain115 and @verult : I don't expect these metadata properties to take this exact form forever and that we may end up changing things once we have a more firmed up plan for how DeviceSpec protos and serialization might change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants