Skip to content

Commit 7e67d66

Browse files
authored
Serializers deprecation (#5589)
This PR deprecates all serializers we plan to deprecate * Deprecated GateOpSerializer, GateOpDeserializer, DeserializingArg, and SerializingArg using the class wrapper technique. * CircuitSerializer and serializer classes it depends on (`CircuitOp[De]Serializer`, `Serializer`) are left in place. * Skipping deprecation of common serializers in `common_serializers.py` for now and remove them directly after the 0.15 release as it's very unlikely for users to access them directly. Most users interact with them via global gatesets, e.g. https://github.com/quantumlib/Cirq/blob/abfc619bfe31e93573993c76cecfddc5689dea9b/cirq-google/cirq_google/serialization/gate_sets.py#L43-L64 But if time allows, I'll try to deprecate common serializers as well. * Added mentions of serializer deprecations in global gateset deprecation warnings. @dstrain115
1 parent 4798874 commit 7e67d66

File tree

10 files changed

+862
-443
lines changed

10 files changed

+862
-443
lines changed

cirq-google/cirq_google/__init__.py

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -160,53 +160,25 @@
160160

161161
_register_resolver(_class_resolver_dictionary)
162162

163+
164+
_SERIALIZABLE_GATESET_DEPRECATION_MESSAGE = (
165+
'SerializableGateSet and associated classes (GateOpSerializer, GateOpDeserializer,'
166+
' SerializingArgs, DeserializingArgs) will no longer be supported.'
167+
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of a device'
168+
' is represented as a cirq.Gateset and is available as'
169+
' GridDevice.metadata.gateset.'
170+
' Engine methods no longer require gate sets to be passed in.'
171+
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.'
172+
)
173+
174+
163175
_compat.deprecate_attributes(
164176
__name__,
165177
{
166-
'XMON': (
167-
'v0.16',
168-
'SerializableGateSet will no longer be supported.'
169-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
170-
' a device is represented as a cirq.Gateset and is available as'
171-
' GridDevice.metadata.gateset.'
172-
' Engine methods no longer require gate sets to be passed in.'
173-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
174-
),
175-
'FSIM_GATESET': (
176-
'v0.16',
177-
'SerializableGateSet will no longer be supported.'
178-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
179-
' a device is represented as a cirq.Gateset and is available as'
180-
' GridDevice.metadata.gateset.'
181-
' Engine methods no longer require gate sets to be passed in.'
182-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
183-
),
184-
'SQRT_ISWAP_GATESET': (
185-
'v0.16',
186-
'SerializableGateSet will no longer be supported.'
187-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
188-
' a device is represented as a cirq.Gateset and is available as'
189-
' GridDevice.metadata.gateset.'
190-
' Engine methods no longer require gate sets to be passed in.'
191-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
192-
),
193-
'SYC_GATESET': (
194-
'v0.16',
195-
'SerializableGateSet will no longer be supported.'
196-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
197-
' a device is represented as a cirq.Gateset and is available as'
198-
' GridDevice.metadata.gateset.'
199-
' Engine methods no longer require gate sets to be passed in.'
200-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
201-
),
202-
'NAMED_GATESETS': (
203-
'v0.16',
204-
'SerializableGateSet will no longer be supported.'
205-
' In cirq_google.GridDevice, the new representation of Google devices, the gateset of '
206-
' a device is represented as a cirq.Gateset and is available as'
207-
' GridDevice.metadata.gateset.'
208-
' Engine methods no longer require gate sets to be passed in.'
209-
' In addition, circuit serialization is replaced by cirq_google.CircuitSerializer.',
210-
),
178+
'XMON': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
179+
'FSIM_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
180+
'SQRT_ISWAP_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
181+
'SYC_GATESET': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
182+
'NAMED_GATESETS': ('v0.16', _SERIALIZABLE_GATESET_DEPRECATION_MESSAGE),
211183
},
212184
)

cirq-google/cirq_google/devices/known_devices.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def create_device_proto_for_qubits(
182182
gate = gs_proto.valid_gates.add()
183183
gate.id = gate_id
184184

185-
if not isinstance(serializer, op_serializer.GateOpSerializer):
185+
if not isinstance(serializer, op_serializer._GateOpSerializer):
186186
# This implies that 'serializer' handles non-gate ops,
187187
# such as CircuitOperations. No other properties apply.
188188
continue

cirq-google/cirq_google/devices/serializable_device_test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727

2828

2929
def _just_cz():
30-
with cirq.testing.assert_deprecated('SerializableGateSet', deadline='v0.16', count=None):
30+
# Deprecations: cirq_google.SerializableGateSet, cirq_google.GateOpSerializer, and
31+
# cirq_google.GateOpDeserializer
32+
with cirq.testing.assert_deprecated(
33+
'SerializableGateSet', 'CircuitSerializer', deadline='v0.16', count=None
34+
):
3135
return cg.SerializableGateSet(
3236
gate_set_name='cz_gate_set',
3337
serializers=[
@@ -42,7 +46,11 @@ def _just_cz():
4246

4347

4448
def _just_meas():
45-
with cirq.testing.assert_deprecated('SerializableGateSet', deadline='v0.16', count=None):
49+
# Deprecations: cirq_google.SerializableGateSet, cirq_google.GateOpSerializer, and
50+
# cirq_google.GateOpDeserializer
51+
with cirq.testing.assert_deprecated(
52+
'SerializableGateSet', 'CircuitSerializer', deadline='v0.16', count=None
53+
):
4654
return cg.SerializableGateSet(
4755
gate_set_name='meas_gate_set',
4856
serializers=[

0 commit comments

Comments
 (0)