Skip to content

Rename GridDevice to GoogleGridDevice #5476

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

Closed

Conversation

verult
Copy link
Collaborator

@verult verult commented Jun 9, 2022

To avoid confusion with the GridDeviceMetadata which is in cirq-core instead of cirq-google. Don't have a strong preference either way, though.

@verult verult requested a review from dstrain115 June 9, 2022 21:00
@verult verult requested review from wcourtney, a team, vtomole and cduck as code owners June 9, 2022 21:00
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 9, 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.

This is fine with me, though I do not have strong opinions.

@@ -0,0 +1 @@
cirq_google.GoogleGridDevice(cirq.GridDeviceMetadata(frozenset({(cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(0, 1), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), (cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 2), cirq.GridQubit(1, 2))}), cirq.Gateset(cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.ZPowGate, cirq.CZ, (cirq.ISWAP**0.5), unroll_circuit_op = True), {cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(nanos=1), cirq.GateFamily(gate=cirq.ops.common_gates.YPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.ops.common_gates.ZPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.CZ, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=500), cirq.GateFamily(gate=(cirq.ISWAP**0.5), ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=600)}, frozenset({cirq.GridQubit(9, 9), cirq.GridQubit(0, 1), cirq.GridQubit(1, 1), cirq.GridQubit(0, 0), cirq.GridQubit(1, 2), cirq.GridQubit(10, 10), cirq.GridQubit(1, 0), cirq.GridQubit(0, 2)}), (cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False), cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False))))
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional: Maybe this could be a git file rename rather than a delete and readd if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried resetting both files to their original state and then running git mv + make the necessary changes. The diff still shows up as a delete and a readd.

AFAIU git doesn't track renames explicitly; rather it detects it automatically based on the diff. Perhaps the reason for failed detection in this case is because all lines of this file have been changed.

@@ -33,7 +33,7 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]:
'GoogleNoiseProperties': cirq_google.GoogleNoiseProperties,
'SycamoreGate': cirq_google.SycamoreGate,
'GateTabulation': cirq_google.GateTabulation,
'GridDevice': cirq_google.GridDevice,
'GoogleGridDevice': cirq_google.GoogleGridDevice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This breaks old objects serialized with the GridDevice name. For backwards compatibility, the old mapping of 'GridDevice': GoogleGridDevice must also be preserved.

Copy link
Collaborator

@tanujkhattar tanujkhattar Jun 13, 2022

Choose a reason for hiding this comment

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

Does this mean we can never add a new serializable GridDevice in the future ? If that's the case, it looks like there might be little value in doing this renaming from GridDevice --> GoogleGridDevice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean we can never add a new serializable GridDevice in the future ?

That's how I understand it. For better or for worse, the change to using class names as the cirq_type locks us out of recycling names indefinitely.

Copy link
Collaborator

@tanujkhattar tanujkhattar Jun 13, 2022

Choose a reason for hiding this comment

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

@verult Do you still think there's value in doing this rename? I'm fine with leaving it as GridDevice since it's already part of the cirq_google namespace so the "Google" part of "GoogleGridDevice" is implied. I think the rename would be more valuable if and when we have a conflicting cirq.GridDevice and cirq_google.GridDevice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed offline with @95-martin-orion , unfortunately we don't include the module name in our JSON serialization, so if there is ever a cirq.GridDevice, it would be indistinguishable from the cirq_google one for JSON deserialization. So yes, I'll move forward with this after addressing Orion's serialization backward compatibility concerns.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Synced with Cheng - the rename is safe since this is all happening within a single release cycle (0.14-0.15).

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 with @95-martin-orion on the backward compatibility issue. Since GridDevice did not exist prior to the last release, it won't be necessary to keep an extra backward compatible mapping.

@verult
Copy link
Collaborator Author

verult commented Jun 14, 2022

Discussed with @95-martin-orion and @tanujkhattar offline. Ideally cirq-google JSON serializations should always be in the cirq.google JSON namespace, e.g. cirq.google.ExecutableResult.json, thereby relying on the module name to disambiguate rather than the class name. Closing this PR in favor of #5512.

@verult verult closed this Jun 14, 2022
CirqBot pushed a commit that referenced this pull request Jun 14, 2022
Preferred alternative over #5476 (renaming `GridDevice` to `GoogleGridDevice`). This resolves the issue of JSON name collisions between cirq_google and elsewhere by including the `cirq.google` namespace.

Furthermore, by staying with `GridDevice` as the class name, we require the caller to include the `cirq-google` module name in cases when multiple `GridDevice` classes are used (for example in the server side code today).

@95-martin-orion @mpharrigan 
cc @dstrain115 @tanujkhattar
augustehirth pushed a commit to augustehirth/Cirq that referenced this pull request Jun 15, 2022
…#5512)

Preferred alternative over quantumlib#5476 (renaming `GridDevice` to `GoogleGridDevice`). This resolves the issue of JSON name collisions between cirq_google and elsewhere by including the `cirq.google` namespace.

Furthermore, by staying with `GridDevice` as the class name, we require the caller to include the `cirq-google` module name in cases when multiple `GridDevice` classes are used (for example in the server side code today).

@95-martin-orion @mpharrigan 
cc @dstrain115 @tanujkhattar
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…#5512)

Preferred alternative over quantumlib#5476 (renaming `GridDevice` to `GoogleGridDevice`). This resolves the issue of JSON name collisions between cirq_google and elsewhere by including the `cirq.google` namespace.

Furthermore, by staying with `GridDevice` as the class name, we require the caller to include the `cirq-google` module name in cases when multiple `GridDevice` classes are used (for example in the server side code today).

@95-martin-orion @mpharrigan 
cc @dstrain115 @tanujkhattar
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