Skip to content

Serializers deprecation #5589

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 17 additions & 45 deletions cirq-google/cirq_google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,53 +160,25 @@

_register_resolver(_class_resolver_dictionary)


_SERIALIZABLE_GATESET_DEPRECATION_MESSAGE = (
'SerializableGateSet and associated classes (GateOpSerializer, GateOpDeserializer,'
' SerializingArgs, DeserializingArgs) will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of a device'
' is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.'
)


_compat.deprecate_attributes(
__name__,
{
'XMON': (
'v0.16',
'SerializableGateSet will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
' a device is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
),
'FSIM_GATESET': (
'v0.16',
'SerializableGateSet will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
' a device is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
),
'SQRT_ISWAP_GATESET': (
'v0.16',
'SerializableGateSet will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
' a device is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
),
'SYC_GATESET': (
'v0.16',
'SerializableGateSet will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
' a device is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
),
'NAMED_GATESETS': (
'v0.16',
'SerializableGateSet will no longer be supported.'
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
' a device is represented as a cirq.Gateset and is available as'
' GridDevice.metadata.gateset.'
' Engine methods no longer require gate sets to be passed in.'
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
),
'XMON': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
'FSIM_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
'SQRT_ISWAP_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
'SYC_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
'NAMED_GATESETS': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
},
)
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/devices/known_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def create_device_proto_for_qubits(
gate = gs_proto.valid_gates.add()
gate.id = gate_id

if not isinstance(serializer, op_serializer.GateOpSerializer):
if not isinstance(serializer, op_serializer._GateOpSerializer):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to handle both GateOpSerializer and _GateOpSerilalzer, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

_GateOpSerializer is a superclass of GateOpSerializer so both are handled

# This implies that 'serializer' handles non-gate ops,
# such as CircuitOperations. No other properties apply.
continue
Expand Down
12 changes: 10 additions & 2 deletions cirq-google/cirq_google/devices/serializable_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@


def _just_cz():
with cirq.testing.assert_deprecated('SerializableGateSet', deadline='v0.16', count=None):
# Deprecations: cirq_google.SerializableGateSet, cirq_google.GateOpSerializer, and
# cirq_google.GateOpDeserializer
with cirq.testing.assert_deprecated(
'SerializableGateSet', 'CircuitSerializer', deadline='v0.16', count=None
):
return cg.SerializableGateSet(
gate_set_name='cz_gate_set',
serializers=[
Expand All @@ -42,7 +46,11 @@ def _just_cz():


def _just_meas():
with cirq.testing.assert_deprecated('SerializableGateSet', deadline='v0.16', count=None):
# Deprecations: cirq_google.SerializableGateSet, cirq_google.GateOpSerializer, and
# cirq_google.GateOpDeserializer
with cirq.testing.assert_deprecated(
'SerializableGateSet', 'CircuitSerializer', deadline='v0.16', count=None
):
return cg.SerializableGateSet(
gate_set_name='meas_gate_set',
serializers=[
Expand Down
Loading