Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def _serialize_gate_op(
out=msg.phasedxpowgate.exponent,
arg_function_language=arg_function_language,
)
elif isinstance(gate, cirq.PhasedXZGate):
elif isinstance(gate, (cirq.PhasedXZGate, cirq.ops.SingleQubitCliffordGate)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be done explicitly, e.g. with optimize_for_target_gateset rather than implicitly during serialization? IIRC, we prefer to make transformations like this explicit to the user.

if isinstance(gate, cirq.ops.SingleQubitCliffordGate):
gate = gate.to_phased_xz_gate()
arg_func_langs.float_arg_to_proto(
gate.x_exponent,
out=msg.phasedxzgate.x_exponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,16 @@ def test_measurement_gate_deserialize() -> None:
msg = cg.CIRCUIT_SERIALIZER.serialize(circuit)

assert cg.CIRCUIT_SERIALIZER.deserialize(msg) == circuit


def test_circuit_with_cliffords():
q = cirq.NamedQubit('q')
circuit = cirq.Circuit(
g(q) for g in cirq.ops.SingleQubitCliffordGate.all_single_qubit_cliffords
)
want = cirq.Circuit(
g.to_phased_xz_gate()(q)
for g in cirq.ops.SingleQubitCliffordGate.all_single_qubit_cliffords
)
msg = cg.CIRCUIT_SERIALIZER.serialize(circuit)
assert cg.CIRCUIT_SERIALIZER.deserialize(msg) == want