From a4f2c96419d68f0aeb3d5ef85f353219c65d1dda Mon Sep 17 00:00:00 2001 From: Orion Martin <40585662+95-martin-orion@users.noreply.github.com> Date: Mon, 26 Jul 2021 11:33:53 -0700 Subject: [PATCH] Revert "Enable CircuitOp serialization." (#4355) Reverts #4344. Enabling CircuitOp serialization is causing errors in QCS. --- .../cirq_google/devices/known_devices_test.py | 6 --- cirq-google/cirq_google/gate_sets.py | 12 ----- cirq-google/cirq_google/gate_sets_test.py | 47 ------------------- 3 files changed, 65 deletions(-) diff --git a/cirq-google/cirq_google/devices/known_devices_test.py b/cirq-google/cirq_google/devices/known_devices_test.py index 2436bc8e112..58dd392a262 100644 --- a/cirq-google/cirq_google/devices/known_devices_test.py +++ b/cirq-google/cirq_google/devices/known_devices_test.py @@ -102,9 +102,6 @@ def test_foxtail_device_proto(): gate_duration_picos: 4000000 valid_targets: "meas_targets" } - valid_gates { - id: "circuit" - } } valid_qubits: "0_0" valid_qubits: "0_1" @@ -392,9 +389,6 @@ def test_multiple_gate_sets(): gate_duration_picos: 14141 valid_targets: "meas_targets" } - valid_gates { - id: "circuit" - } } valid_gate_sets { name: "half_pi_gateset" diff --git a/cirq-google/cirq_google/gate_sets.py b/cirq-google/cirq_google/gate_sets.py index df2a52787ed..9cba6726421 100644 --- a/cirq-google/cirq_google/gate_sets.py +++ b/cirq-google/cirq_google/gate_sets.py @@ -33,8 +33,6 @@ COUPLER_PULSE_DESERIALIZER, WAIT_GATE_SERIALIZER, WAIT_GATE_DESERIALIZER, - CIRCUIT_OP_SERIALIZER, - CIRCUIT_OP_DESERIALIZER, ) SYC_GATESET = serializable_gate_set.SerializableGateSet( @@ -45,7 +43,6 @@ *SINGLE_QUBIT_HALF_PI_SERIALIZERS, MEASUREMENT_SERIALIZER, WAIT_GATE_SERIALIZER, - CIRCUIT_OP_SERIALIZER, ], deserializers=[ SYC_DESERIALIZER, @@ -53,7 +50,6 @@ *SINGLE_QUBIT_HALF_PI_DESERIALIZERS, MEASUREMENT_DESERIALIZER, WAIT_GATE_DESERIALIZER, - CIRCUIT_OP_DESERIALIZER, ], ) document(SYC_GATESET, """Gate set with fsim(pi/2, pi/6) as the core 2 qubit interaction.""") @@ -65,14 +61,12 @@ *SINGLE_QUBIT_SERIALIZERS, MEASUREMENT_SERIALIZER, WAIT_GATE_SERIALIZER, - CIRCUIT_OP_SERIALIZER, ], deserializers=[ *SQRT_ISWAP_DESERIALIZERS, *SINGLE_QUBIT_DESERIALIZERS, MEASUREMENT_DESERIALIZER, WAIT_GATE_DESERIALIZER, - CIRCUIT_OP_DESERIALIZER, ], ) document(SQRT_ISWAP_GATESET, """Gate set with sqrt(iswap) as the core 2 qubit interaction.""") @@ -85,14 +79,12 @@ *SINGLE_QUBIT_SERIALIZERS, MEASUREMENT_SERIALIZER, WAIT_GATE_SERIALIZER, - CIRCUIT_OP_SERIALIZER, ], deserializers=[ LIMITED_FSIM_DESERIALIZER, *SINGLE_QUBIT_DESERIALIZERS, MEASUREMENT_DESERIALIZER, WAIT_GATE_DESERIALIZER, - CIRCUIT_OP_DESERIALIZER, ], ) document(FSIM_GATESET, """Gate set that combines sqrt(iswap) and syc as one fsim id.""") @@ -106,7 +98,6 @@ *SINGLE_QUBIT_SERIALIZERS, MEASUREMENT_SERIALIZER, WAIT_GATE_SERIALIZER, - CIRCUIT_OP_SERIALIZER, ], deserializers=[ COUPLER_PULSE_DESERIALIZER, @@ -114,7 +105,6 @@ *SINGLE_QUBIT_DESERIALIZERS, MEASUREMENT_DESERIALIZER, WAIT_GATE_DESERIALIZER, - CIRCUIT_OP_DESERIALIZER, ], ) document( @@ -130,13 +120,11 @@ *SINGLE_QUBIT_SERIALIZERS, CZ_POW_SERIALIZER, MEASUREMENT_SERIALIZER, - CIRCUIT_OP_SERIALIZER, ], deserializers=[ *SINGLE_QUBIT_DESERIALIZERS, CZ_POW_DESERIALIZER, MEASUREMENT_DESERIALIZER, - CIRCUIT_OP_DESERIALIZER, ], ) document(XMON, """Gate set for XMON devices.""") diff --git a/cirq-google/cirq_google/gate_sets_test.py b/cirq-google/cirq_google/gate_sets_test.py index f7d3b0f865c..029b6d6cc7f 100644 --- a/cirq-google/cirq_google/gate_sets_test.py +++ b/cirq-google/cirq_google/gate_sets_test.py @@ -527,50 +527,3 @@ def test_serialize_deserialize_wait_gate(): assert cg.SYC_GATESET.deserialize_op(proto) == op assert cg.SQRT_ISWAP_GATESET.serialize_op(op) == proto assert cg.SQRT_ISWAP_GATESET.deserialize_op(proto) == op - - -def default_circuit_proto(): - op1 = v2.program_pb2.Operation() - op1.gate.id = 'x_pow' - op1.args['half_turns'].arg_value.string_value = 'k' - op1.qubits.add().id = '1_1' - - return v2.program_pb2.Circuit( - scheduling_strategy=v2.program_pb2.Circuit.MOMENT_BY_MOMENT, - moments=[ - v2.program_pb2.Moment( - operations=[op1], - ), - ], - ) - - -def default_circuit(): - return cirq.FrozenCircuit( - cirq.X(cirq.GridQubit(1, 1)) ** sympy.Symbol('k'), - cirq.measure(cirq.GridQubit(1, 1), key='m'), - ) - - -@pytest.mark.parametrize('gateset', [cg.XMON, cg.SYC_GATESET, cg.SQRT_ISWAP_GATESET]) -def test_serialize_deserialize_circuit_op(gateset): - circuit_op = cirq.CircuitOperation(default_circuit()) - proto = v2.program_pb2.CircuitOperation() - proto.circuit_constant_index = 0 - proto.repetition_specification.repetition_count = 1 - - constants = [default_circuit_proto()] - raw_constants = {default_circuit(): 0} - assert ( - gateset.serialize_op(circuit_op, constants=constants, raw_constants=raw_constants) == proto - ) - - constants = [default_circuit_proto()] - deserialized_constants = [default_circuit()] - - assert ( - gateset.deserialize_op( - proto, constants=constants, deserialized_constants=deserialized_constants - ) - == circuit_op - )