Skip to content

Commit da6ec5d

Browse files
authored
Fix serialization error in cirq_google. (#7260)
* Fix serialization error in cirq_google. - If empty, invert_mask is converted to an empty tuple object. - This is not yet supported server-side. * Fix typo.
1 parent 65a4105 commit da6ec5d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cirq-google/cirq_google/serialization/circuit_serializer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ def _serialize_gate_op(
260260
msg.fsimgate.translate_via_model = True
261261
elif isinstance(gate, cirq.MeasurementGate):
262262
arg_func_langs.arg_to_proto(gate.key, out=msg.measurementgate.key)
263-
arg_func_langs.arg_to_proto(gate.invert_mask, out=msg.measurementgate.invert_mask)
263+
if len(gate.invert_mask):
264+
# Do not serialize empty invert mask until servers support empty tuples
265+
arg_func_langs.arg_to_proto(gate.invert_mask, out=msg.measurementgate.invert_mask)
264266
elif isinstance(gate, cirq.WaitGate):
265267
arg_func_langs.float_arg_to_proto(
266268
gate.duration.total_nanos(), out=msg.waitgate.duration_nanos

0 commit comments

Comments
 (0)