diff --git a/cirq-google/cirq_google/api/v2/program.proto b/cirq-google/cirq_google/api/v2/program.proto index b3b6c66d160..80f7f6fbc41 100644 --- a/cirq-google/cirq_google/api/v2/program.proto +++ b/cirq-google/cirq_google/api/v2/program.proto @@ -28,6 +28,12 @@ message Program { // List to store global constants, such as strings used in many places. // constants are referred to their index in this list, starting at zero. repeated Constant constants = 4; + + // A batch of circuits organized by a set of parameters. These + // parameters should also be specified in the sweep as well. + // This field can be used for efficient packing of circuit functions + // that change based on parameters, or for batch sending of circuits. + repeated KeyedCircuit keyed_circuits = 5; } // Constants, such as long strings, that are used throughout the circuit. @@ -54,6 +60,29 @@ message Constant { } } + +// A batch of circuits organized by a set of parameters. These +// parameters should also be specified in the sweep as well. +// This field can be used for efficient packing of circuit functions +// that change based on parameters, or for batch sending of circuits. +message KeyedCircuit { + + // Arguments for a cirq circuit which comes from run_context. + // The key will be the name of the argument, and the value + // will be the value passed into the function. + // e.g. Arguments for a circuit function such as: + // def circuit_fn(freq_GHz: float, num_cycles: int) -> Circuit + // would have the two entries: "freq_GHz" and "num_cycles" + map args = 1; + + // The cirq circuit corresponding to the arguments args. + Circuit circuit = 2; + + // Optional key for program. + // If provided, will be used as a key in a Mapping from string to Circuit. + string key = 3; +} + // The quantum circuit, specified as a series of moments (abstract // slices of times with gates acting on disjoint sets of qubits). message Circuit { diff --git a/cirq-google/cirq_google/api/v2/program_pb2.py b/cirq-google/cirq_google/api/v2/program_pb2.py index 33eb7df9351..cb248d4b6c8 100644 --- a/cirq-google/cirq_google/api/v2/program_pb2.py +++ b/cirq-google/cirq_google/api/v2/program_pb2.py @@ -26,7 +26,7 @@ from . import ndarrays_pb2 as cirq__google_dot_api_dot_v2_dot_ndarrays__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n cirq_google/api/v2/program.proto\x12\x12\x63irq.google.api.v2\x1a\x19tunits/proto/tunits.proto\x1a!cirq_google/api/v2/ndarrays.proto\"\xaf\x01\n\x07Program\x12\x32\n\x08language\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.LanguageB\x02\x18\x01\x12.\n\x07\x63ircuit\x18\x02 \x01(\x0b\x32\x1b.cirq.google.api.v2.CircuitH\x00\x12/\n\tconstants\x18\x04 \x03(\x0b\x32\x1c.cirq.google.api.v2.ConstantB\t\n\x07programJ\x04\x08\x03\x10\x04\"\xaf\x02\n\x08\x43onstant\x12\x16\n\x0cstring_value\x18\x01 \x01(\tH\x00\x12\x34\n\rcircuit_value\x18\x02 \x01(\x0b\x32\x1b.cirq.google.api.v2.CircuitH\x00\x12*\n\x05qubit\x18\x03 \x01(\x0b\x32\x19.cirq.google.api.v2.QubitH\x00\x12\x32\n\x0cmoment_value\x18\x04 \x01(\x0b\x32\x1a.cirq.google.api.v2.MomentH\x00\x12\x38\n\x0foperation_value\x18\x05 \x01(\x0b\x32\x1d.cirq.google.api.v2.OperationH\x00\x12,\n\ttag_value\x18\x06 \x01(\x0b\x32\x17.cirq.google.api.v2.TagH\x00\x42\r\n\x0b\x63onst_value\"\x87\x02\n\x07\x43ircuit\x12K\n\x13scheduling_strategy\x18\x01 \x01(\x0e\x32..cirq.google.api.v2.Circuit.SchedulingStrategy\x12+\n\x07moments\x18\x02 \x03(\x0b\x32\x1a.cirq.google.api.v2.Moment\x12\x16\n\x0emoment_indices\x18\x03 \x03(\x05\x12\x13\n\x0btag_indices\x18\x05 \x03(\x05\"O\n\x12SchedulingStrategy\x12#\n\x1fSCHEDULING_STRATEGY_UNSPECIFIED\x10\x00\x12\x14\n\x10MOMENT_BY_MOMENT\x10\x01J\x04\x08\x04\x10\x05\"\xb3\x01\n\x06Moment\x12\x31\n\noperations\x18\x01 \x03(\x0b\x32\x1d.cirq.google.api.v2.Operation\x12@\n\x12\x63ircuit_operations\x18\x02 \x03(\x0b\x32$.cirq.google.api.v2.CircuitOperation\x12\x19\n\x11operation_indices\x18\x04 \x03(\x05\x12\x13\n\x0btag_indices\x18\x05 \x03(\x05J\x04\x08\x03\x10\x04\"C\n\x08Language\x12\x14\n\x08gate_set\x18\x01 \x01(\tB\x02\x18\x01\x12!\n\x15\x61rg_function_language\x18\x02 \x01(\tB\x02\x18\x01\"k\n\x08\x46loatArg\x12\x15\n\x0b\x66loat_value\x18\x01 \x01(\x02H\x00\x12\x10\n\x06symbol\x18\x02 \x01(\tH\x00\x12/\n\x04\x66unc\x18\x03 \x01(\x0b\x32\x1f.cirq.google.api.v2.ArgFunctionH\x00\x42\x05\n\x03\x61rg\":\n\x08XPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\":\n\x08YPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"Q\n\x08ZPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x15\n\ris_physical_z\x18\x02 \x01(\x08\"v\n\x0ePhasedXPowGate\x12\x34\n\x0ephase_exponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12.\n\x08\x65xponent\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\xad\x01\n\x0cPhasedXZGate\x12\x30\n\nx_exponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x30\n\nz_exponent\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x39\n\x13\x61xis_phase_exponent\x18\x03 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\";\n\tCZPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\x7f\n\x08\x46SimGate\x12+\n\x05theta\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12)\n\x03phi\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x1b\n\x13translate_via_model\x18\x03 \x01(\x08\">\n\x0cISwapPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\x99\x01\n\rISwapLikeGate\x12I\n\roriginal_gate\x18\x01 \x01(\x0e\x32\x32.cirq.google.api.v2.ISwapLikeGate.OriginalCirqGate\"=\n\x10OriginalCirqGate\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0c\n\x08SYCAMORE\x10\x01\x12\n\n\x06WILLOW\x10\x02\"e\n\x0fMeasurementGate\x12$\n\x03key\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12,\n\x0binvert_mask\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\"@\n\x08WaitGate\x12\x34\n\x0e\x64uration_nanos\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\\\n\x13\x44\x65polarizingChannel\x12\x31\n\x0bprobability\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x12\n\nnum_qubits\x18\x02 \x01(\x05\"w\n\x11RandomGateChannel\x12\x31\n\x0bprobability\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12/\n\x08sub_gate\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.Operation\"\xab\x01\n\x0cNoiseChannel\x12\x46\n\x13\x64\x65polarizingchannel\x18\x01 \x01(\x0b\x32\'.cirq.google.api.v2.DepolarizingChannelH\x00\x12\x42\n\x11randomgatechannel\x18\x02 \x01(\x0b\x32%.cirq.google.api.v2.RandomGateChannelH\x00\x42\x0f\n\rchannel_value\"\xa0\x03\n\x17\x41nalogDetuneCouplerOnly\x12\'\n\x06length\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\"\n\x01w\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12$\n\x03g_0\x18\x03 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12&\n\x05g_max\x18\x04 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x30\n\x0fg_ramp_exponent\x18\x05 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x35\n\x14neighbor_qubits_freq\x18\x06 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12:\n\x19prev_neighbor_qubits_freq\x18\x07 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12 \n\x18interpolate_coupling_cal\x18\x08 \x01(\x08\x12#\n\x1b\x61nalog_cal_for_pulseshaping\x18\t \x01(\x08\"\xd6\x02\n\x11\x41nalogDetuneQubit\x12\'\n\x06length\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\"\n\x01w\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12,\n\x0btarget_freq\x18\x03 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12*\n\tprev_freq\x18\x04 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12?\n\x17neighbor_coupler_g_dict\x18\x05 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x44\n\x1cprev_neighbor_coupler_g_dict\x18\x06 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x13\n\x0blinear_rise\x18\x07 \x01(\x08\"P\n\x10WaitGateWithUnit\x12)\n\x08\x64uration\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x11\n\tqid_shape\x18\x02 \x03(\x05\"\x87\x0c\n\tOperation\x12\x30\n\x08xpowgate\x18\x07 \x01(\x0b\x32\x1c.cirq.google.api.v2.XPowGateH\x00\x12\x30\n\x08ypowgate\x18\x08 \x01(\x0b\x32\x1c.cirq.google.api.v2.YPowGateH\x00\x12\x30\n\x08zpowgate\x18\t \x01(\x0b\x32\x1c.cirq.google.api.v2.ZPowGateH\x00\x12<\n\x0ephasedxpowgate\x18\n \x01(\x0b\x32\".cirq.google.api.v2.PhasedXPowGateH\x00\x12\x38\n\x0cphasedxzgate\x18\x0b \x01(\x0b\x32 .cirq.google.api.v2.PhasedXZGateH\x00\x12\x32\n\tczpowgate\x18\x0c \x01(\x0b\x32\x1d.cirq.google.api.v2.CZPowGateH\x00\x12\x30\n\x08\x66simgate\x18\r \x01(\x0b\x32\x1c.cirq.google.api.v2.FSimGateH\x00\x12\x38\n\x0ciswappowgate\x18\x0e \x01(\x0b\x32 .cirq.google.api.v2.ISwapPowGateH\x00\x12>\n\x0fmeasurementgate\x18\x0f \x01(\x0b\x32#.cirq.google.api.v2.MeasurementGateH\x00\x12\x30\n\x08waitgate\x18\x10 \x01(\x0b\x32\x1c.cirq.google.api.v2.WaitGateH\x00\x12\x38\n\x0cinternalgate\x18\x11 \x01(\x0b\x32 .cirq.google.api.v2.InternalGateH\x00\x12@\n\x10\x63ouplerpulsegate\x18\x12 \x01(\x0b\x32$.cirq.google.api.v2.CouplerPulseGateH\x00\x12\x38\n\x0cidentitygate\x18\x13 \x01(\x0b\x32 .cirq.google.api.v2.IdentityGateH\x00\x12\x30\n\x08hpowgate\x18\x14 \x01(\x0b\x32\x1c.cirq.google.api.v2.HPowGateH\x00\x12N\n\x17singlequbitcliffordgate\x18\x15 \x01(\x0b\x32+.cirq.google.api.v2.SingleQubitCliffordGateH\x00\x12\x32\n\tresetgate\x18\x18 \x01(\x0b\x32\x1d.cirq.google.api.v2.ResetGateH\x00\x12:\n\riswaplikegate\x18\x1a \x01(\x0b\x32!.cirq.google.api.v2.ISwapLikeGateH\x00\x12\x38\n\x0cnoisechannel\x18\x1b \x01(\x0b\x32 .cirq.google.api.v2.NoiseChannelH\x00\x12Q\n\x1a\x61nalog_detune_coupler_only\x18\x1c \x01(\x0b\x32+.cirq.google.api.v2.AnalogDetuneCouplerOnlyH\x00\x12\x44\n\x13\x61nalog_detune_qubit\x18\x1d \x01(\x0b\x32%.cirq.google.api.v2.AnalogDetuneQubitH\x00\x12\x43\n\x13wait_gate_with_unit\x18\x1e \x01(\x0b\x32$.cirq.google.api.v2.WaitGateWithUnitH\x00\x12-\n\x06qubits\x18\x03 \x03(\x0b\x32\x19.cirq.google.api.v2.QubitB\x02\x18\x01\x12\x1c\n\x14qubit_constant_index\x18\x06 \x03(\x05\x12\x19\n\x0btoken_value\x18\x04 \x01(\tB\x02\x18\x01H\x01\x12\"\n\x14token_constant_index\x18\x05 \x01(\x05\x42\x02\x18\x01H\x01\x12%\n\x04tags\x18\x16 \x03(\x0b\x32\x17.cirq.google.api.v2.Tag\x12\x13\n\x0btag_indices\x18\x17 \x03(\x05\x12/\n\x0e\x63onditioned_on\x18\x19 \x03(\x0b\x32\x17.cirq.google.api.v2.ArgB\x0c\n\ngate_valueB\x07\n\x05tokenJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03\"<\n\x16\x44ynamicalDecouplingTag\x12\x15\n\x08protocol\x18\x01 \x01(\tH\x00\x88\x01\x01\x42\x0b\n\t_protocol\"\xe9\x04\n\x03Tag\x12J\n\x14\x64ynamical_decoupling\x18\x01 \x01(\x0b\x32*.cirq.google.api.v2.DynamicalDecouplingTagH\x00\x12\x30\n\x07no_sync\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.NoSyncTagH\x00\x12\x38\n\x0bphase_match\x18\x03 \x01(\x0b\x32!.cirq.google.api.v2.PhaseMatchTagH\x00\x12\x36\n\nphysical_z\x18\x04 \x01(\x0b\x32 .cirq.google.api.v2.PhysicalZTagH\x00\x12@\n\x0f\x63lassical_state\x18\x05 \x01(\x0b\x32%.cirq.google.api.v2.ClassicalStateTagH\x00\x12=\n\x0e\x66sim_via_model\x18\x07 \x01(\x0b\x32#.cirq.google.api.v2.FSimViaModelTagH\x00\x12=\n\x0f\x63\x61libration_tag\x18\t \x01(\x0b\x32\".cirq.google.api.v2.CalibrationTagH\x00\x12\x44\n\x11\x63ompress_duration\x18\n \x01(\x0b\x32\'.cirq.google.api.v2.CompressDurationTagH\x00\x12\x37\n\x0cinternal_tag\x18\x08 \x01(\x0b\x32\x1f.cirq.google.api.v2.InternalTagH\x00\x12,\n\traw_value\x18\x0b \x01(\x0b\x32\x17.cirq.google.api.v2.ArgH\x00\x42\x05\n\x03tag\"\x0f\n\rPhaseMatchTag\"\x0e\n\x0cPhysicalZTag\"\x13\n\x11\x43lassicalStateTag\"\x11\n\x0f\x46SimViaModelTag\"\x84\x01\n\tNoSyncTag\x12\x11\n\x07reverse\x18\x01 \x01(\x05H\x00\x12!\n\x17remove_all_syncs_before\x18\x02 \x01(\x08H\x00\x12\x11\n\x07\x66orward\x18\x03 \x01(\x05H\x01\x12 \n\x16remove_all_syncs_after\x18\x04 \x01(\x08H\x01\x42\x05\n\x03revB\x05\n\x03\x66wd\"\x1f\n\x0e\x43\x61librationTag\x12\r\n\x05token\x18\x01 \x01(\t\"\x15\n\x13\x43ompressDurationTag\"\xd5\x02\n\x0bInternalTag\x12\x10\n\x08tag_name\x18\x01 \x01(\t\x12\x13\n\x0btag_package\x18\x02 \x01(\t\x12>\n\x08tag_args\x18\x03 \x03(\x0b\x32,.cirq.google.api.v2.InternalTag.TagArgsEntry\x12\x44\n\x0b\x63ustom_args\x18\x04 \x03(\x0b\x32/.cirq.google.api.v2.InternalTag.CustomArgsEntry\x1aG\n\x0cTagArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x1aP\n\x0f\x43ustomArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.CustomArg:\x02\x38\x01\"\x12\n\x04Gate\x12\n\n\x02id\x18\x01 \x01(\t\"\x13\n\x05Qubit\x12\n\n\x02id\x18\x02 \x01(\t\"\xdb\x01\n\x03\x41rg\x12\x31\n\targ_value\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.ArgValueH\x00\x12\x10\n\x06symbol\x18\x02 \x01(\tH\x00\x12/\n\x04\x66unc\x18\x03 \x01(\x0b\x32\x1f.cirq.google.api.v2.ArgFunctionH\x00\x12\x18\n\x0e\x63onstant_index\x18\x04 \x01(\x05H\x00\x12=\n\x0fmeasurement_key\x18\x05 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKeyH\x00\x42\x05\n\x03\x61rg\"\xc4\x04\n\x08\x41rgValue\x12\x15\n\x0b\x66loat_value\x18\x01 \x01(\x02H\x00\x12:\n\x0b\x62ool_values\x18\x02 \x01(\x0b\x32#.cirq.google.api.v2.RepeatedBooleanH\x00\x12\x16\n\x0cstring_value\x18\x03 \x01(\tH\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x12\x39\n\x0cint64_values\x18\x05 \x01(\x0b\x32!.cirq.google.api.v2.RepeatedInt64H\x00\x12;\n\rdouble_values\x18\x06 \x01(\x0b\x32\".cirq.google.api.v2.RepeatedDoubleH\x00\x12;\n\rstring_values\x18\x07 \x01(\x0b\x32\".cirq.google.api.v2.RepeatedStringH\x00\x12(\n\x0fvalue_with_unit\x18\x08 \x01(\x0b\x32\r.tunits.ValueH\x00\x12\x14\n\nbool_value\x18\t \x01(\x08H\x00\x12\x15\n\x0b\x62ytes_value\x18\n \x01(\x0cH\x00\x12\x34\n\rcomplex_value\x18\x0b \x01(\x0b\x32\x1b.cirq.google.api.v2.ComplexH\x00\x12\x30\n\x0btuple_value\x18\x0c \x01(\x0b\x32\x19.cirq.google.api.v2.TupleH\x00\x12\x34\n\rndarray_value\x18\r \x01(\x0b\x32\x1b.cirq.google.api.v2.NDArrayH\x00\x42\x0b\n\targ_value\"\x1f\n\rRepeatedInt64\x12\x0e\n\x06values\x18\x01 \x03(\x03\" \n\x0eRepeatedDouble\x12\x0e\n\x06values\x18\x01 \x03(\x01\" \n\x0eRepeatedString\x12\x0e\n\x06values\x18\x01 \x03(\t\"!\n\x0fRepeatedBoolean\x12\x0e\n\x06values\x18\x01 \x03(\x08\"\xbd\x01\n\x05Tuple\x12=\n\rsequence_type\x18\x01 \x01(\x0e\x32&.cirq.google.api.v2.Tuple.SequenceType\x12\'\n\x06values\x18\x02 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\"L\n\x0cSequenceType\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x08\n\x04LIST\x10\x01\x12\t\n\x05TUPLE\x10\x02\x12\x07\n\x03SET\x10\x03\x12\r\n\tFROZENSET\x10\x04\"1\n\x07\x43omplex\x12\x12\n\nreal_value\x18\x01 \x01(\x01\x12\x12\n\nimag_value\x18\x02 \x01(\x01\"\x85\x05\n\x07NDArray\x12?\n\x10\x63omplex128_array\x18\x01 \x01(\x0b\x32#.cirq.google.api.v2.Complex128ArrayH\x00\x12=\n\x0f\x63omplex64_array\x18\x02 \x01(\x0b\x32\".cirq.google.api.v2.Complex64ArrayH\x00\x12\x39\n\rfloat16_array\x18\x03 \x01(\x0b\x32 .cirq.google.api.v2.Float16ArrayH\x00\x12\x39\n\rfloat32_array\x18\x04 \x01(\x0b\x32 .cirq.google.api.v2.Float32ArrayH\x00\x12\x39\n\rfloat64_array\x18\x05 \x01(\x0b\x32 .cirq.google.api.v2.Float64ArrayH\x00\x12\x35\n\x0bint64_array\x18\x06 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int64ArrayH\x00\x12\x35\n\x0bint32_array\x18\x07 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int32ArrayH\x00\x12\x35\n\x0bint16_array\x18\x08 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int16ArrayH\x00\x12\x33\n\nint8_array\x18\t \x01(\x0b\x32\x1d.cirq.google.api.v2.Int8ArrayH\x00\x12\x35\n\x0buint8_array\x18\n \x01(\x0b\x32\x1e.cirq.google.api.v2.UInt8ArrayH\x00\x12\x31\n\tbit_array\x18\x0b \x01(\x0b\x32\x1c.cirq.google.api.v2.BitArrayH\x00\x42\x05\n\x03\x61rr\"B\n\x0b\x41rgFunction\x12\x0c\n\x04type\x18\x01 \x01(\t\x12%\n\x04\x61rgs\x18\x02 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\"\xc1\x03\n\x10\x43ircuitOperation\x12\x1e\n\x16\x63ircuit_constant_index\x18\x01 \x01(\x05\x12M\n\x18repetition_specification\x18\x02 \x01(\x0b\x32+.cirq.google.api.v2.RepetitionSpecification\x12\x33\n\tqubit_map\x18\x03 \x01(\x0b\x32 .cirq.google.api.v2.QubitMapping\x12\x46\n\x13measurement_key_map\x18\x04 \x01(\x0b\x32).cirq.google.api.v2.MeasurementKeyMapping\x12/\n\x07\x61rg_map\x18\x05 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x32\n\x0crepeat_until\x18\x06 \x01(\x0b\x32\x17.cirq.google.api.v2.ArgH\x00\x88\x01\x01\x12/\n\x0e\x63onditioned_on\x18\x07 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x1a\n\x12use_repetition_ids\x18\x08 \x01(\x08\x42\x0f\n\r_repeat_until\"\xbc\x01\n\x17RepetitionSpecification\x12S\n\x0erepetition_ids\x18\x01 \x01(\x0b\x32\x39.cirq.google.api.v2.RepetitionSpecification.RepetitionIdsH\x00\x12\x1a\n\x10repetition_count\x18\x02 \x01(\x05H\x00\x1a\x1c\n\rRepetitionIds\x12\x0b\n\x03ids\x18\x01 \x03(\tB\x12\n\x10repetition_value\"\xac\x01\n\x0cQubitMapping\x12<\n\x07\x65ntries\x18\x01 \x03(\x0b\x32+.cirq.google.api.v2.QubitMapping.QubitEntry\x1a^\n\nQubitEntry\x12&\n\x03key\x18\x01 \x01(\x0b\x32\x19.cirq.google.api.v2.Qubit\x12(\n\x05value\x18\x02 \x01(\x0b\x32\x19.cirq.google.api.v2.Qubit\"P\n\x0eMeasurementKey\x12\x12\n\nstring_key\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x12\n\x05index\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\x08\n\x06_index\"\xe2\x01\n\x15MeasurementKeyMapping\x12N\n\x07\x65ntries\x18\x01 \x03(\x0b\x32=.cirq.google.api.v2.MeasurementKeyMapping.MeasurementKeyEntry\x1ay\n\x13MeasurementKeyEntry\x12/\n\x03key\x18\x01 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKey\x12\x31\n\x05value\x18\x02 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKey\"\xa0\x01\n\nArgMapping\x12\x38\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\'.cirq.google.api.v2.ArgMapping.ArgEntry\x1aX\n\x08\x41rgEntry\x12$\n\x03key\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\"C\n\x15\x46unctionInterpolation\x12\x14\n\x08x_values\x18\x01 \x03(\x02\x42\x02\x10\x01\x12\x14\n\x08y_values\x18\x02 \x03(\x02\x42\x02\x10\x01\"k\n\tCustomArg\x12P\n\x1b\x66unction_interpolation_data\x18\x01 \x01(\x0b\x32).cirq.google.api.v2.FunctionInterpolationH\x00\x42\x0c\n\ncustom_arg\"\xe6\x02\n\x0cInternalGate\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06module\x18\x02 \x01(\t\x12\x12\n\nnum_qubits\x18\x03 \x01(\x05\x12\x41\n\tgate_args\x18\x04 \x03(\x0b\x32..cirq.google.api.v2.InternalGate.GateArgsEntry\x12\x45\n\x0b\x63ustom_args\x18\x05 \x03(\x0b\x32\x30.cirq.google.api.v2.InternalGate.CustomArgsEntry\x1aH\n\rGateArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x1aP\n\x0f\x43ustomArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.CustomArg:\x02\x38\x01\"\xd8\x03\n\x10\x43ouplerPulseGate\x12\x37\n\x0chold_time_ps\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x00\x88\x01\x01\x12\x37\n\x0crise_time_ps\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x01\x88\x01\x01\x12:\n\x0fpadding_time_ps\x18\x03 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x02\x88\x01\x01\x12\x37\n\x0c\x63oupling_mhz\x18\x04 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x03\x88\x01\x01\x12\x38\n\rq0_detune_mhz\x18\x05 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x04\x88\x01\x01\x12\x38\n\rq1_detune_mhz\x18\x06 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x05\x88\x01\x01\x42\x0f\n\r_hold_time_psB\x0f\n\r_rise_time_psB\x12\n\x10_padding_time_psB\x0f\n\r_coupling_mhzB\x10\n\x0e_q0_detune_mhzB\x10\n\x0e_q1_detune_mhz\"\x8b\x01\n\x0f\x43liffordTableau\x12\x17\n\nnum_qubits\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x1a\n\rinitial_state\x18\x02 \x01(\x05H\x01\x88\x01\x01\x12\n\n\x02rs\x18\x03 \x03(\x08\x12\n\n\x02xs\x18\x04 \x03(\x08\x12\n\n\x02zs\x18\x05 \x03(\x08\x42\r\n\x0b_num_qubitsB\x10\n\x0e_initial_state\"O\n\x17SingleQubitCliffordGate\x12\x34\n\x07tableau\x18\x01 \x01(\x0b\x32#.cirq.google.api.v2.CliffordTableau\"!\n\x0cIdentityGate\x12\x11\n\tqid_shape\x18\x01 \x03(\r\":\n\x08HPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\xab\x01\n\tResetGate\x12\x12\n\nreset_type\x18\x01 \x01(\t\x12?\n\targuments\x18\x02 \x03(\x0b\x32,.cirq.google.api.v2.ResetGate.ArgumentsEntry\x1aI\n\x0e\x41rgumentsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x42/\n\x1d\x63om.google.cirq.google.api.v2B\x0cProgramProtoP\x01\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n cirq_google/api/v2/program.proto\x12\x12\x63irq.google.api.v2\x1a\x19tunits/proto/tunits.proto\x1a!cirq_google/api/v2/ndarrays.proto\"\xe9\x01\n\x07Program\x12\x32\n\x08language\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.LanguageB\x02\x18\x01\x12.\n\x07\x63ircuit\x18\x02 \x01(\x0b\x32\x1b.cirq.google.api.v2.CircuitH\x00\x12/\n\tconstants\x18\x04 \x03(\x0b\x32\x1c.cirq.google.api.v2.Constant\x12\x38\n\x0ekeyed_circuits\x18\x05 \x03(\x0b\x32 .cirq.google.api.v2.KeyedCircuitB\t\n\x07programJ\x04\x08\x03\x10\x04\"\xaf\x02\n\x08\x43onstant\x12\x16\n\x0cstring_value\x18\x01 \x01(\tH\x00\x12\x34\n\rcircuit_value\x18\x02 \x01(\x0b\x32\x1b.cirq.google.api.v2.CircuitH\x00\x12*\n\x05qubit\x18\x03 \x01(\x0b\x32\x19.cirq.google.api.v2.QubitH\x00\x12\x32\n\x0cmoment_value\x18\x04 \x01(\x0b\x32\x1a.cirq.google.api.v2.MomentH\x00\x12\x38\n\x0foperation_value\x18\x05 \x01(\x0b\x32\x1d.cirq.google.api.v2.OperationH\x00\x12,\n\ttag_value\x18\x06 \x01(\x0b\x32\x17.cirq.google.api.v2.TagH\x00\x42\r\n\x0b\x63onst_value\"\xc9\x01\n\x0cKeyedCircuit\x12\x38\n\x04\x61rgs\x18\x01 \x03(\x0b\x32*.cirq.google.api.v2.KeyedCircuit.ArgsEntry\x12,\n\x07\x63ircuit\x18\x02 \x01(\x0b\x32\x1b.cirq.google.api.v2.Circuit\x12\x0b\n\x03key\x18\x03 \x01(\t\x1a\x44\n\tArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\"\x87\x02\n\x07\x43ircuit\x12K\n\x13scheduling_strategy\x18\x01 \x01(\x0e\x32..cirq.google.api.v2.Circuit.SchedulingStrategy\x12+\n\x07moments\x18\x02 \x03(\x0b\x32\x1a.cirq.google.api.v2.Moment\x12\x16\n\x0emoment_indices\x18\x03 \x03(\x05\x12\x13\n\x0btag_indices\x18\x05 \x03(\x05\"O\n\x12SchedulingStrategy\x12#\n\x1fSCHEDULING_STRATEGY_UNSPECIFIED\x10\x00\x12\x14\n\x10MOMENT_BY_MOMENT\x10\x01J\x04\x08\x04\x10\x05\"\xb3\x01\n\x06Moment\x12\x31\n\noperations\x18\x01 \x03(\x0b\x32\x1d.cirq.google.api.v2.Operation\x12@\n\x12\x63ircuit_operations\x18\x02 \x03(\x0b\x32$.cirq.google.api.v2.CircuitOperation\x12\x19\n\x11operation_indices\x18\x04 \x03(\x05\x12\x13\n\x0btag_indices\x18\x05 \x03(\x05J\x04\x08\x03\x10\x04\"C\n\x08Language\x12\x14\n\x08gate_set\x18\x01 \x01(\tB\x02\x18\x01\x12!\n\x15\x61rg_function_language\x18\x02 \x01(\tB\x02\x18\x01\"k\n\x08\x46loatArg\x12\x15\n\x0b\x66loat_value\x18\x01 \x01(\x02H\x00\x12\x10\n\x06symbol\x18\x02 \x01(\tH\x00\x12/\n\x04\x66unc\x18\x03 \x01(\x0b\x32\x1f.cirq.google.api.v2.ArgFunctionH\x00\x42\x05\n\x03\x61rg\":\n\x08XPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\":\n\x08YPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"Q\n\x08ZPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x15\n\ris_physical_z\x18\x02 \x01(\x08\"v\n\x0ePhasedXPowGate\x12\x34\n\x0ephase_exponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12.\n\x08\x65xponent\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\xad\x01\n\x0cPhasedXZGate\x12\x30\n\nx_exponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x30\n\nz_exponent\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x39\n\x13\x61xis_phase_exponent\x18\x03 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\";\n\tCZPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\x7f\n\x08\x46SimGate\x12+\n\x05theta\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12)\n\x03phi\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x1b\n\x13translate_via_model\x18\x03 \x01(\x08\">\n\x0cISwapPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\x99\x01\n\rISwapLikeGate\x12I\n\roriginal_gate\x18\x01 \x01(\x0e\x32\x32.cirq.google.api.v2.ISwapLikeGate.OriginalCirqGate\"=\n\x10OriginalCirqGate\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0c\n\x08SYCAMORE\x10\x01\x12\n\n\x06WILLOW\x10\x02\"e\n\x0fMeasurementGate\x12$\n\x03key\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12,\n\x0binvert_mask\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\"@\n\x08WaitGate\x12\x34\n\x0e\x64uration_nanos\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\\\n\x13\x44\x65polarizingChannel\x12\x31\n\x0bprobability\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12\x12\n\nnum_qubits\x18\x02 \x01(\x05\"w\n\x11RandomGateChannel\x12\x31\n\x0bprobability\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\x12/\n\x08sub_gate\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.Operation\"\xab\x01\n\x0cNoiseChannel\x12\x46\n\x13\x64\x65polarizingchannel\x18\x01 \x01(\x0b\x32\'.cirq.google.api.v2.DepolarizingChannelH\x00\x12\x42\n\x11randomgatechannel\x18\x02 \x01(\x0b\x32%.cirq.google.api.v2.RandomGateChannelH\x00\x42\x0f\n\rchannel_value\"\xa0\x03\n\x17\x41nalogDetuneCouplerOnly\x12\'\n\x06length\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\"\n\x01w\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12$\n\x03g_0\x18\x03 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12&\n\x05g_max\x18\x04 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x30\n\x0fg_ramp_exponent\x18\x05 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x35\n\x14neighbor_qubits_freq\x18\x06 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12:\n\x19prev_neighbor_qubits_freq\x18\x07 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12 \n\x18interpolate_coupling_cal\x18\x08 \x01(\x08\x12#\n\x1b\x61nalog_cal_for_pulseshaping\x18\t \x01(\x08\"\xd6\x02\n\x11\x41nalogDetuneQubit\x12\'\n\x06length\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\"\n\x01w\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12,\n\x0btarget_freq\x18\x03 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12*\n\tprev_freq\x18\x04 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12?\n\x17neighbor_coupler_g_dict\x18\x05 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x44\n\x1cprev_neighbor_coupler_g_dict\x18\x06 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x13\n\x0blinear_rise\x18\x07 \x01(\x08\"P\n\x10WaitGateWithUnit\x12)\n\x08\x64uration\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x11\n\tqid_shape\x18\x02 \x03(\x05\"\x87\x0c\n\tOperation\x12\x30\n\x08xpowgate\x18\x07 \x01(\x0b\x32\x1c.cirq.google.api.v2.XPowGateH\x00\x12\x30\n\x08ypowgate\x18\x08 \x01(\x0b\x32\x1c.cirq.google.api.v2.YPowGateH\x00\x12\x30\n\x08zpowgate\x18\t \x01(\x0b\x32\x1c.cirq.google.api.v2.ZPowGateH\x00\x12<\n\x0ephasedxpowgate\x18\n \x01(\x0b\x32\".cirq.google.api.v2.PhasedXPowGateH\x00\x12\x38\n\x0cphasedxzgate\x18\x0b \x01(\x0b\x32 .cirq.google.api.v2.PhasedXZGateH\x00\x12\x32\n\tczpowgate\x18\x0c \x01(\x0b\x32\x1d.cirq.google.api.v2.CZPowGateH\x00\x12\x30\n\x08\x66simgate\x18\r \x01(\x0b\x32\x1c.cirq.google.api.v2.FSimGateH\x00\x12\x38\n\x0ciswappowgate\x18\x0e \x01(\x0b\x32 .cirq.google.api.v2.ISwapPowGateH\x00\x12>\n\x0fmeasurementgate\x18\x0f \x01(\x0b\x32#.cirq.google.api.v2.MeasurementGateH\x00\x12\x30\n\x08waitgate\x18\x10 \x01(\x0b\x32\x1c.cirq.google.api.v2.WaitGateH\x00\x12\x38\n\x0cinternalgate\x18\x11 \x01(\x0b\x32 .cirq.google.api.v2.InternalGateH\x00\x12@\n\x10\x63ouplerpulsegate\x18\x12 \x01(\x0b\x32$.cirq.google.api.v2.CouplerPulseGateH\x00\x12\x38\n\x0cidentitygate\x18\x13 \x01(\x0b\x32 .cirq.google.api.v2.IdentityGateH\x00\x12\x30\n\x08hpowgate\x18\x14 \x01(\x0b\x32\x1c.cirq.google.api.v2.HPowGateH\x00\x12N\n\x17singlequbitcliffordgate\x18\x15 \x01(\x0b\x32+.cirq.google.api.v2.SingleQubitCliffordGateH\x00\x12\x32\n\tresetgate\x18\x18 \x01(\x0b\x32\x1d.cirq.google.api.v2.ResetGateH\x00\x12:\n\riswaplikegate\x18\x1a \x01(\x0b\x32!.cirq.google.api.v2.ISwapLikeGateH\x00\x12\x38\n\x0cnoisechannel\x18\x1b \x01(\x0b\x32 .cirq.google.api.v2.NoiseChannelH\x00\x12Q\n\x1a\x61nalog_detune_coupler_only\x18\x1c \x01(\x0b\x32+.cirq.google.api.v2.AnalogDetuneCouplerOnlyH\x00\x12\x44\n\x13\x61nalog_detune_qubit\x18\x1d \x01(\x0b\x32%.cirq.google.api.v2.AnalogDetuneQubitH\x00\x12\x43\n\x13wait_gate_with_unit\x18\x1e \x01(\x0b\x32$.cirq.google.api.v2.WaitGateWithUnitH\x00\x12-\n\x06qubits\x18\x03 \x03(\x0b\x32\x19.cirq.google.api.v2.QubitB\x02\x18\x01\x12\x1c\n\x14qubit_constant_index\x18\x06 \x03(\x05\x12\x19\n\x0btoken_value\x18\x04 \x01(\tB\x02\x18\x01H\x01\x12\"\n\x14token_constant_index\x18\x05 \x01(\x05\x42\x02\x18\x01H\x01\x12%\n\x04tags\x18\x16 \x03(\x0b\x32\x17.cirq.google.api.v2.Tag\x12\x13\n\x0btag_indices\x18\x17 \x03(\x05\x12/\n\x0e\x63onditioned_on\x18\x19 \x03(\x0b\x32\x17.cirq.google.api.v2.ArgB\x0c\n\ngate_valueB\x07\n\x05tokenJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03\"<\n\x16\x44ynamicalDecouplingTag\x12\x15\n\x08protocol\x18\x01 \x01(\tH\x00\x88\x01\x01\x42\x0b\n\t_protocol\"\xe9\x04\n\x03Tag\x12J\n\x14\x64ynamical_decoupling\x18\x01 \x01(\x0b\x32*.cirq.google.api.v2.DynamicalDecouplingTagH\x00\x12\x30\n\x07no_sync\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.NoSyncTagH\x00\x12\x38\n\x0bphase_match\x18\x03 \x01(\x0b\x32!.cirq.google.api.v2.PhaseMatchTagH\x00\x12\x36\n\nphysical_z\x18\x04 \x01(\x0b\x32 .cirq.google.api.v2.PhysicalZTagH\x00\x12@\n\x0f\x63lassical_state\x18\x05 \x01(\x0b\x32%.cirq.google.api.v2.ClassicalStateTagH\x00\x12=\n\x0e\x66sim_via_model\x18\x07 \x01(\x0b\x32#.cirq.google.api.v2.FSimViaModelTagH\x00\x12=\n\x0f\x63\x61libration_tag\x18\t \x01(\x0b\x32\".cirq.google.api.v2.CalibrationTagH\x00\x12\x44\n\x11\x63ompress_duration\x18\n \x01(\x0b\x32\'.cirq.google.api.v2.CompressDurationTagH\x00\x12\x37\n\x0cinternal_tag\x18\x08 \x01(\x0b\x32\x1f.cirq.google.api.v2.InternalTagH\x00\x12,\n\traw_value\x18\x0b \x01(\x0b\x32\x17.cirq.google.api.v2.ArgH\x00\x42\x05\n\x03tag\"\x0f\n\rPhaseMatchTag\"\x0e\n\x0cPhysicalZTag\"\x13\n\x11\x43lassicalStateTag\"\x11\n\x0f\x46SimViaModelTag\"\x84\x01\n\tNoSyncTag\x12\x11\n\x07reverse\x18\x01 \x01(\x05H\x00\x12!\n\x17remove_all_syncs_before\x18\x02 \x01(\x08H\x00\x12\x11\n\x07\x66orward\x18\x03 \x01(\x05H\x01\x12 \n\x16remove_all_syncs_after\x18\x04 \x01(\x08H\x01\x42\x05\n\x03revB\x05\n\x03\x66wd\"\x1f\n\x0e\x43\x61librationTag\x12\r\n\x05token\x18\x01 \x01(\t\"\x15\n\x13\x43ompressDurationTag\"\xd5\x02\n\x0bInternalTag\x12\x10\n\x08tag_name\x18\x01 \x01(\t\x12\x13\n\x0btag_package\x18\x02 \x01(\t\x12>\n\x08tag_args\x18\x03 \x03(\x0b\x32,.cirq.google.api.v2.InternalTag.TagArgsEntry\x12\x44\n\x0b\x63ustom_args\x18\x04 \x03(\x0b\x32/.cirq.google.api.v2.InternalTag.CustomArgsEntry\x1aG\n\x0cTagArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x1aP\n\x0f\x43ustomArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.CustomArg:\x02\x38\x01\"\x12\n\x04Gate\x12\n\n\x02id\x18\x01 \x01(\t\"\x13\n\x05Qubit\x12\n\n\x02id\x18\x02 \x01(\t\"\xdb\x01\n\x03\x41rg\x12\x31\n\targ_value\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.ArgValueH\x00\x12\x10\n\x06symbol\x18\x02 \x01(\tH\x00\x12/\n\x04\x66unc\x18\x03 \x01(\x0b\x32\x1f.cirq.google.api.v2.ArgFunctionH\x00\x12\x18\n\x0e\x63onstant_index\x18\x04 \x01(\x05H\x00\x12=\n\x0fmeasurement_key\x18\x05 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKeyH\x00\x42\x05\n\x03\x61rg\"\xc4\x04\n\x08\x41rgValue\x12\x15\n\x0b\x66loat_value\x18\x01 \x01(\x02H\x00\x12:\n\x0b\x62ool_values\x18\x02 \x01(\x0b\x32#.cirq.google.api.v2.RepeatedBooleanH\x00\x12\x16\n\x0cstring_value\x18\x03 \x01(\tH\x00\x12\x16\n\x0c\x64ouble_value\x18\x04 \x01(\x01H\x00\x12\x39\n\x0cint64_values\x18\x05 \x01(\x0b\x32!.cirq.google.api.v2.RepeatedInt64H\x00\x12;\n\rdouble_values\x18\x06 \x01(\x0b\x32\".cirq.google.api.v2.RepeatedDoubleH\x00\x12;\n\rstring_values\x18\x07 \x01(\x0b\x32\".cirq.google.api.v2.RepeatedStringH\x00\x12(\n\x0fvalue_with_unit\x18\x08 \x01(\x0b\x32\r.tunits.ValueH\x00\x12\x14\n\nbool_value\x18\t \x01(\x08H\x00\x12\x15\n\x0b\x62ytes_value\x18\n \x01(\x0cH\x00\x12\x34\n\rcomplex_value\x18\x0b \x01(\x0b\x32\x1b.cirq.google.api.v2.ComplexH\x00\x12\x30\n\x0btuple_value\x18\x0c \x01(\x0b\x32\x19.cirq.google.api.v2.TupleH\x00\x12\x34\n\rndarray_value\x18\r \x01(\x0b\x32\x1b.cirq.google.api.v2.NDArrayH\x00\x42\x0b\n\targ_value\"\x1f\n\rRepeatedInt64\x12\x0e\n\x06values\x18\x01 \x03(\x03\" \n\x0eRepeatedDouble\x12\x0e\n\x06values\x18\x01 \x03(\x01\" \n\x0eRepeatedString\x12\x0e\n\x06values\x18\x01 \x03(\t\"!\n\x0fRepeatedBoolean\x12\x0e\n\x06values\x18\x01 \x03(\x08\"\xbd\x01\n\x05Tuple\x12=\n\rsequence_type\x18\x01 \x01(\x0e\x32&.cirq.google.api.v2.Tuple.SequenceType\x12\'\n\x06values\x18\x02 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\"L\n\x0cSequenceType\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x08\n\x04LIST\x10\x01\x12\t\n\x05TUPLE\x10\x02\x12\x07\n\x03SET\x10\x03\x12\r\n\tFROZENSET\x10\x04\"1\n\x07\x43omplex\x12\x12\n\nreal_value\x18\x01 \x01(\x01\x12\x12\n\nimag_value\x18\x02 \x01(\x01\"\x85\x05\n\x07NDArray\x12?\n\x10\x63omplex128_array\x18\x01 \x01(\x0b\x32#.cirq.google.api.v2.Complex128ArrayH\x00\x12=\n\x0f\x63omplex64_array\x18\x02 \x01(\x0b\x32\".cirq.google.api.v2.Complex64ArrayH\x00\x12\x39\n\rfloat16_array\x18\x03 \x01(\x0b\x32 .cirq.google.api.v2.Float16ArrayH\x00\x12\x39\n\rfloat32_array\x18\x04 \x01(\x0b\x32 .cirq.google.api.v2.Float32ArrayH\x00\x12\x39\n\rfloat64_array\x18\x05 \x01(\x0b\x32 .cirq.google.api.v2.Float64ArrayH\x00\x12\x35\n\x0bint64_array\x18\x06 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int64ArrayH\x00\x12\x35\n\x0bint32_array\x18\x07 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int32ArrayH\x00\x12\x35\n\x0bint16_array\x18\x08 \x01(\x0b\x32\x1e.cirq.google.api.v2.Int16ArrayH\x00\x12\x33\n\nint8_array\x18\t \x01(\x0b\x32\x1d.cirq.google.api.v2.Int8ArrayH\x00\x12\x35\n\x0buint8_array\x18\n \x01(\x0b\x32\x1e.cirq.google.api.v2.UInt8ArrayH\x00\x12\x31\n\tbit_array\x18\x0b \x01(\x0b\x32\x1c.cirq.google.api.v2.BitArrayH\x00\x42\x05\n\x03\x61rr\"B\n\x0b\x41rgFunction\x12\x0c\n\x04type\x18\x01 \x01(\t\x12%\n\x04\x61rgs\x18\x02 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\"\xc1\x03\n\x10\x43ircuitOperation\x12\x1e\n\x16\x63ircuit_constant_index\x18\x01 \x01(\x05\x12M\n\x18repetition_specification\x18\x02 \x01(\x0b\x32+.cirq.google.api.v2.RepetitionSpecification\x12\x33\n\tqubit_map\x18\x03 \x01(\x0b\x32 .cirq.google.api.v2.QubitMapping\x12\x46\n\x13measurement_key_map\x18\x04 \x01(\x0b\x32).cirq.google.api.v2.MeasurementKeyMapping\x12/\n\x07\x61rg_map\x18\x05 \x01(\x0b\x32\x1e.cirq.google.api.v2.ArgMapping\x12\x32\n\x0crepeat_until\x18\x06 \x01(\x0b\x32\x17.cirq.google.api.v2.ArgH\x00\x88\x01\x01\x12/\n\x0e\x63onditioned_on\x18\x07 \x03(\x0b\x32\x17.cirq.google.api.v2.Arg\x12\x1a\n\x12use_repetition_ids\x18\x08 \x01(\x08\x42\x0f\n\r_repeat_until\"\xbc\x01\n\x17RepetitionSpecification\x12S\n\x0erepetition_ids\x18\x01 \x01(\x0b\x32\x39.cirq.google.api.v2.RepetitionSpecification.RepetitionIdsH\x00\x12\x1a\n\x10repetition_count\x18\x02 \x01(\x05H\x00\x1a\x1c\n\rRepetitionIds\x12\x0b\n\x03ids\x18\x01 \x03(\tB\x12\n\x10repetition_value\"\xac\x01\n\x0cQubitMapping\x12<\n\x07\x65ntries\x18\x01 \x03(\x0b\x32+.cirq.google.api.v2.QubitMapping.QubitEntry\x1a^\n\nQubitEntry\x12&\n\x03key\x18\x01 \x01(\x0b\x32\x19.cirq.google.api.v2.Qubit\x12(\n\x05value\x18\x02 \x01(\x0b\x32\x19.cirq.google.api.v2.Qubit\"P\n\x0eMeasurementKey\x12\x12\n\nstring_key\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x12\n\x05index\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\x08\n\x06_index\"\xe2\x01\n\x15MeasurementKeyMapping\x12N\n\x07\x65ntries\x18\x01 \x03(\x0b\x32=.cirq.google.api.v2.MeasurementKeyMapping.MeasurementKeyEntry\x1ay\n\x13MeasurementKeyEntry\x12/\n\x03key\x18\x01 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKey\x12\x31\n\x05value\x18\x02 \x01(\x0b\x32\".cirq.google.api.v2.MeasurementKey\"\xa0\x01\n\nArgMapping\x12\x38\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\'.cirq.google.api.v2.ArgMapping.ArgEntry\x1aX\n\x08\x41rgEntry\x12$\n\x03key\x18\x01 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg\"C\n\x15\x46unctionInterpolation\x12\x14\n\x08x_values\x18\x01 \x03(\x02\x42\x02\x10\x01\x12\x14\n\x08y_values\x18\x02 \x03(\x02\x42\x02\x10\x01\"k\n\tCustomArg\x12P\n\x1b\x66unction_interpolation_data\x18\x01 \x01(\x0b\x32).cirq.google.api.v2.FunctionInterpolationH\x00\x42\x0c\n\ncustom_arg\"\xe6\x02\n\x0cInternalGate\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06module\x18\x02 \x01(\t\x12\x12\n\nnum_qubits\x18\x03 \x01(\x05\x12\x41\n\tgate_args\x18\x04 \x03(\x0b\x32..cirq.google.api.v2.InternalGate.GateArgsEntry\x12\x45\n\x0b\x63ustom_args\x18\x05 \x03(\x0b\x32\x30.cirq.google.api.v2.InternalGate.CustomArgsEntry\x1aH\n\rGateArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x1aP\n\x0f\x43ustomArgsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x05value\x18\x02 \x01(\x0b\x32\x1d.cirq.google.api.v2.CustomArg:\x02\x38\x01\"\xd8\x03\n\x10\x43ouplerPulseGate\x12\x37\n\x0chold_time_ps\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x00\x88\x01\x01\x12\x37\n\x0crise_time_ps\x18\x02 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x01\x88\x01\x01\x12:\n\x0fpadding_time_ps\x18\x03 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x02\x88\x01\x01\x12\x37\n\x0c\x63oupling_mhz\x18\x04 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x03\x88\x01\x01\x12\x38\n\rq0_detune_mhz\x18\x05 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x04\x88\x01\x01\x12\x38\n\rq1_detune_mhz\x18\x06 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArgH\x05\x88\x01\x01\x42\x0f\n\r_hold_time_psB\x0f\n\r_rise_time_psB\x12\n\x10_padding_time_psB\x0f\n\r_coupling_mhzB\x10\n\x0e_q0_detune_mhzB\x10\n\x0e_q1_detune_mhz\"\x8b\x01\n\x0f\x43liffordTableau\x12\x17\n\nnum_qubits\x18\x01 \x01(\x05H\x00\x88\x01\x01\x12\x1a\n\rinitial_state\x18\x02 \x01(\x05H\x01\x88\x01\x01\x12\n\n\x02rs\x18\x03 \x03(\x08\x12\n\n\x02xs\x18\x04 \x03(\x08\x12\n\n\x02zs\x18\x05 \x03(\x08\x42\r\n\x0b_num_qubitsB\x10\n\x0e_initial_state\"O\n\x17SingleQubitCliffordGate\x12\x34\n\x07tableau\x18\x01 \x01(\x0b\x32#.cirq.google.api.v2.CliffordTableau\"!\n\x0cIdentityGate\x12\x11\n\tqid_shape\x18\x01 \x03(\r\":\n\x08HPowGate\x12.\n\x08\x65xponent\x18\x01 \x01(\x0b\x32\x1c.cirq.google.api.v2.FloatArg\"\xab\x01\n\tResetGate\x12\x12\n\nreset_type\x18\x01 \x01(\t\x12?\n\targuments\x18\x02 \x03(\x0b\x32,.cirq.google.api.v2.ResetGate.ArgumentsEntry\x1aI\n\x0e\x41rgumentsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.cirq.google.api.v2.Arg:\x02\x38\x01\x42/\n\x1d\x63om.google.cirq.google.api.v2B\x0cProgramProtoP\x01\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -36,6 +36,8 @@ _globals['DESCRIPTOR']._serialized_options = b'\n\035com.google.cirq.google.api.v2B\014ProgramProtoP\001' _globals['_PROGRAM'].fields_by_name['language']._loaded_options = None _globals['_PROGRAM'].fields_by_name['language']._serialized_options = b'\030\001' + _globals['_KEYEDCIRCUIT_ARGSENTRY']._loaded_options = None + _globals['_KEYEDCIRCUIT_ARGSENTRY']._serialized_options = b'8\001' _globals['_LANGUAGE'].fields_by_name['gate_set']._loaded_options = None _globals['_LANGUAGE'].fields_by_name['gate_set']._serialized_options = b'\030\001' _globals['_LANGUAGE'].fields_by_name['arg_function_language']._loaded_options = None @@ -61,149 +63,153 @@ _globals['_RESETGATE_ARGUMENTSENTRY']._loaded_options = None _globals['_RESETGATE_ARGUMENTSENTRY']._serialized_options = b'8\001' _globals['_PROGRAM']._serialized_start=119 - _globals['_PROGRAM']._serialized_end=294 - _globals['_CONSTANT']._serialized_start=297 - _globals['_CONSTANT']._serialized_end=600 - _globals['_CIRCUIT']._serialized_start=603 - _globals['_CIRCUIT']._serialized_end=866 - _globals['_CIRCUIT_SCHEDULINGSTRATEGY']._serialized_start=781 - _globals['_CIRCUIT_SCHEDULINGSTRATEGY']._serialized_end=860 - _globals['_MOMENT']._serialized_start=869 - _globals['_MOMENT']._serialized_end=1048 - _globals['_LANGUAGE']._serialized_start=1050 - _globals['_LANGUAGE']._serialized_end=1117 - _globals['_FLOATARG']._serialized_start=1119 - _globals['_FLOATARG']._serialized_end=1226 - _globals['_XPOWGATE']._serialized_start=1228 - _globals['_XPOWGATE']._serialized_end=1286 - _globals['_YPOWGATE']._serialized_start=1288 - _globals['_YPOWGATE']._serialized_end=1346 - _globals['_ZPOWGATE']._serialized_start=1348 - _globals['_ZPOWGATE']._serialized_end=1429 - _globals['_PHASEDXPOWGATE']._serialized_start=1431 - _globals['_PHASEDXPOWGATE']._serialized_end=1549 - _globals['_PHASEDXZGATE']._serialized_start=1552 - _globals['_PHASEDXZGATE']._serialized_end=1725 - _globals['_CZPOWGATE']._serialized_start=1727 - _globals['_CZPOWGATE']._serialized_end=1786 - _globals['_FSIMGATE']._serialized_start=1788 - _globals['_FSIMGATE']._serialized_end=1915 - _globals['_ISWAPPOWGATE']._serialized_start=1917 - _globals['_ISWAPPOWGATE']._serialized_end=1979 - _globals['_ISWAPLIKEGATE']._serialized_start=1982 - _globals['_ISWAPLIKEGATE']._serialized_end=2135 - _globals['_ISWAPLIKEGATE_ORIGINALCIRQGATE']._serialized_start=2074 - _globals['_ISWAPLIKEGATE_ORIGINALCIRQGATE']._serialized_end=2135 - _globals['_MEASUREMENTGATE']._serialized_start=2137 - _globals['_MEASUREMENTGATE']._serialized_end=2238 - _globals['_WAITGATE']._serialized_start=2240 - _globals['_WAITGATE']._serialized_end=2304 - _globals['_DEPOLARIZINGCHANNEL']._serialized_start=2306 - _globals['_DEPOLARIZINGCHANNEL']._serialized_end=2398 - _globals['_RANDOMGATECHANNEL']._serialized_start=2400 - _globals['_RANDOMGATECHANNEL']._serialized_end=2519 - _globals['_NOISECHANNEL']._serialized_start=2522 - _globals['_NOISECHANNEL']._serialized_end=2693 - _globals['_ANALOGDETUNECOUPLERONLY']._serialized_start=2696 - _globals['_ANALOGDETUNECOUPLERONLY']._serialized_end=3112 - _globals['_ANALOGDETUNEQUBIT']._serialized_start=3115 - _globals['_ANALOGDETUNEQUBIT']._serialized_end=3457 - _globals['_WAITGATEWITHUNIT']._serialized_start=3459 - _globals['_WAITGATEWITHUNIT']._serialized_end=3539 - _globals['_OPERATION']._serialized_start=3542 - _globals['_OPERATION']._serialized_end=5085 - _globals['_DYNAMICALDECOUPLINGTAG']._serialized_start=5087 - _globals['_DYNAMICALDECOUPLINGTAG']._serialized_end=5147 - _globals['_TAG']._serialized_start=5150 - _globals['_TAG']._serialized_end=5767 - _globals['_PHASEMATCHTAG']._serialized_start=5769 - _globals['_PHASEMATCHTAG']._serialized_end=5784 - _globals['_PHYSICALZTAG']._serialized_start=5786 - _globals['_PHYSICALZTAG']._serialized_end=5800 - _globals['_CLASSICALSTATETAG']._serialized_start=5802 - _globals['_CLASSICALSTATETAG']._serialized_end=5821 - _globals['_FSIMVIAMODELTAG']._serialized_start=5823 - _globals['_FSIMVIAMODELTAG']._serialized_end=5840 - _globals['_NOSYNCTAG']._serialized_start=5843 - _globals['_NOSYNCTAG']._serialized_end=5975 - _globals['_CALIBRATIONTAG']._serialized_start=5977 - _globals['_CALIBRATIONTAG']._serialized_end=6008 - _globals['_COMPRESSDURATIONTAG']._serialized_start=6010 - _globals['_COMPRESSDURATIONTAG']._serialized_end=6031 - _globals['_INTERNALTAG']._serialized_start=6034 - _globals['_INTERNALTAG']._serialized_end=6375 - _globals['_INTERNALTAG_TAGARGSENTRY']._serialized_start=6222 - _globals['_INTERNALTAG_TAGARGSENTRY']._serialized_end=6293 - _globals['_INTERNALTAG_CUSTOMARGSENTRY']._serialized_start=6295 - _globals['_INTERNALTAG_CUSTOMARGSENTRY']._serialized_end=6375 - _globals['_GATE']._serialized_start=6377 - _globals['_GATE']._serialized_end=6395 - _globals['_QUBIT']._serialized_start=6397 - _globals['_QUBIT']._serialized_end=6416 - _globals['_ARG']._serialized_start=6419 - _globals['_ARG']._serialized_end=6638 - _globals['_ARGVALUE']._serialized_start=6641 - _globals['_ARGVALUE']._serialized_end=7221 - _globals['_REPEATEDINT64']._serialized_start=7223 - _globals['_REPEATEDINT64']._serialized_end=7254 - _globals['_REPEATEDDOUBLE']._serialized_start=7256 - _globals['_REPEATEDDOUBLE']._serialized_end=7288 - _globals['_REPEATEDSTRING']._serialized_start=7290 - _globals['_REPEATEDSTRING']._serialized_end=7322 - _globals['_REPEATEDBOOLEAN']._serialized_start=7324 - _globals['_REPEATEDBOOLEAN']._serialized_end=7357 - _globals['_TUPLE']._serialized_start=7360 - _globals['_TUPLE']._serialized_end=7549 - _globals['_TUPLE_SEQUENCETYPE']._serialized_start=7473 - _globals['_TUPLE_SEQUENCETYPE']._serialized_end=7549 - _globals['_COMPLEX']._serialized_start=7551 - _globals['_COMPLEX']._serialized_end=7600 - _globals['_NDARRAY']._serialized_start=7603 - _globals['_NDARRAY']._serialized_end=8248 - _globals['_ARGFUNCTION']._serialized_start=8250 - _globals['_ARGFUNCTION']._serialized_end=8316 - _globals['_CIRCUITOPERATION']._serialized_start=8319 - _globals['_CIRCUITOPERATION']._serialized_end=8768 - _globals['_REPETITIONSPECIFICATION']._serialized_start=8771 - _globals['_REPETITIONSPECIFICATION']._serialized_end=8959 - _globals['_REPETITIONSPECIFICATION_REPETITIONIDS']._serialized_start=8911 - _globals['_REPETITIONSPECIFICATION_REPETITIONIDS']._serialized_end=8939 - _globals['_QUBITMAPPING']._serialized_start=8962 - _globals['_QUBITMAPPING']._serialized_end=9134 - _globals['_QUBITMAPPING_QUBITENTRY']._serialized_start=9040 - _globals['_QUBITMAPPING_QUBITENTRY']._serialized_end=9134 - _globals['_MEASUREMENTKEY']._serialized_start=9136 - _globals['_MEASUREMENTKEY']._serialized_end=9216 - _globals['_MEASUREMENTKEYMAPPING']._serialized_start=9219 - _globals['_MEASUREMENTKEYMAPPING']._serialized_end=9445 - _globals['_MEASUREMENTKEYMAPPING_MEASUREMENTKEYENTRY']._serialized_start=9324 - _globals['_MEASUREMENTKEYMAPPING_MEASUREMENTKEYENTRY']._serialized_end=9445 - _globals['_ARGMAPPING']._serialized_start=9448 - _globals['_ARGMAPPING']._serialized_end=9608 - _globals['_ARGMAPPING_ARGENTRY']._serialized_start=9520 - _globals['_ARGMAPPING_ARGENTRY']._serialized_end=9608 - _globals['_FUNCTIONINTERPOLATION']._serialized_start=9610 - _globals['_FUNCTIONINTERPOLATION']._serialized_end=9677 - _globals['_CUSTOMARG']._serialized_start=9679 - _globals['_CUSTOMARG']._serialized_end=9786 - _globals['_INTERNALGATE']._serialized_start=9789 - _globals['_INTERNALGATE']._serialized_end=10147 - _globals['_INTERNALGATE_GATEARGSENTRY']._serialized_start=9993 - _globals['_INTERNALGATE_GATEARGSENTRY']._serialized_end=10065 - _globals['_INTERNALGATE_CUSTOMARGSENTRY']._serialized_start=6295 - _globals['_INTERNALGATE_CUSTOMARGSENTRY']._serialized_end=6375 - _globals['_COUPLERPULSEGATE']._serialized_start=10150 - _globals['_COUPLERPULSEGATE']._serialized_end=10622 - _globals['_CLIFFORDTABLEAU']._serialized_start=10625 - _globals['_CLIFFORDTABLEAU']._serialized_end=10764 - _globals['_SINGLEQUBITCLIFFORDGATE']._serialized_start=10766 - _globals['_SINGLEQUBITCLIFFORDGATE']._serialized_end=10845 - _globals['_IDENTITYGATE']._serialized_start=10847 - _globals['_IDENTITYGATE']._serialized_end=10880 - _globals['_HPOWGATE']._serialized_start=10882 - _globals['_HPOWGATE']._serialized_end=10940 - _globals['_RESETGATE']._serialized_start=10943 - _globals['_RESETGATE']._serialized_end=11114 - _globals['_RESETGATE_ARGUMENTSENTRY']._serialized_start=11041 - _globals['_RESETGATE_ARGUMENTSENTRY']._serialized_end=11114 + _globals['_PROGRAM']._serialized_end=352 + _globals['_CONSTANT']._serialized_start=355 + _globals['_CONSTANT']._serialized_end=658 + _globals['_KEYEDCIRCUIT']._serialized_start=661 + _globals['_KEYEDCIRCUIT']._serialized_end=862 + _globals['_KEYEDCIRCUIT_ARGSENTRY']._serialized_start=794 + _globals['_KEYEDCIRCUIT_ARGSENTRY']._serialized_end=862 + _globals['_CIRCUIT']._serialized_start=865 + _globals['_CIRCUIT']._serialized_end=1128 + _globals['_CIRCUIT_SCHEDULINGSTRATEGY']._serialized_start=1043 + _globals['_CIRCUIT_SCHEDULINGSTRATEGY']._serialized_end=1122 + _globals['_MOMENT']._serialized_start=1131 + _globals['_MOMENT']._serialized_end=1310 + _globals['_LANGUAGE']._serialized_start=1312 + _globals['_LANGUAGE']._serialized_end=1379 + _globals['_FLOATARG']._serialized_start=1381 + _globals['_FLOATARG']._serialized_end=1488 + _globals['_XPOWGATE']._serialized_start=1490 + _globals['_XPOWGATE']._serialized_end=1548 + _globals['_YPOWGATE']._serialized_start=1550 + _globals['_YPOWGATE']._serialized_end=1608 + _globals['_ZPOWGATE']._serialized_start=1610 + _globals['_ZPOWGATE']._serialized_end=1691 + _globals['_PHASEDXPOWGATE']._serialized_start=1693 + _globals['_PHASEDXPOWGATE']._serialized_end=1811 + _globals['_PHASEDXZGATE']._serialized_start=1814 + _globals['_PHASEDXZGATE']._serialized_end=1987 + _globals['_CZPOWGATE']._serialized_start=1989 + _globals['_CZPOWGATE']._serialized_end=2048 + _globals['_FSIMGATE']._serialized_start=2050 + _globals['_FSIMGATE']._serialized_end=2177 + _globals['_ISWAPPOWGATE']._serialized_start=2179 + _globals['_ISWAPPOWGATE']._serialized_end=2241 + _globals['_ISWAPLIKEGATE']._serialized_start=2244 + _globals['_ISWAPLIKEGATE']._serialized_end=2397 + _globals['_ISWAPLIKEGATE_ORIGINALCIRQGATE']._serialized_start=2336 + _globals['_ISWAPLIKEGATE_ORIGINALCIRQGATE']._serialized_end=2397 + _globals['_MEASUREMENTGATE']._serialized_start=2399 + _globals['_MEASUREMENTGATE']._serialized_end=2500 + _globals['_WAITGATE']._serialized_start=2502 + _globals['_WAITGATE']._serialized_end=2566 + _globals['_DEPOLARIZINGCHANNEL']._serialized_start=2568 + _globals['_DEPOLARIZINGCHANNEL']._serialized_end=2660 + _globals['_RANDOMGATECHANNEL']._serialized_start=2662 + _globals['_RANDOMGATECHANNEL']._serialized_end=2781 + _globals['_NOISECHANNEL']._serialized_start=2784 + _globals['_NOISECHANNEL']._serialized_end=2955 + _globals['_ANALOGDETUNECOUPLERONLY']._serialized_start=2958 + _globals['_ANALOGDETUNECOUPLERONLY']._serialized_end=3374 + _globals['_ANALOGDETUNEQUBIT']._serialized_start=3377 + _globals['_ANALOGDETUNEQUBIT']._serialized_end=3719 + _globals['_WAITGATEWITHUNIT']._serialized_start=3721 + _globals['_WAITGATEWITHUNIT']._serialized_end=3801 + _globals['_OPERATION']._serialized_start=3804 + _globals['_OPERATION']._serialized_end=5347 + _globals['_DYNAMICALDECOUPLINGTAG']._serialized_start=5349 + _globals['_DYNAMICALDECOUPLINGTAG']._serialized_end=5409 + _globals['_TAG']._serialized_start=5412 + _globals['_TAG']._serialized_end=6029 + _globals['_PHASEMATCHTAG']._serialized_start=6031 + _globals['_PHASEMATCHTAG']._serialized_end=6046 + _globals['_PHYSICALZTAG']._serialized_start=6048 + _globals['_PHYSICALZTAG']._serialized_end=6062 + _globals['_CLASSICALSTATETAG']._serialized_start=6064 + _globals['_CLASSICALSTATETAG']._serialized_end=6083 + _globals['_FSIMVIAMODELTAG']._serialized_start=6085 + _globals['_FSIMVIAMODELTAG']._serialized_end=6102 + _globals['_NOSYNCTAG']._serialized_start=6105 + _globals['_NOSYNCTAG']._serialized_end=6237 + _globals['_CALIBRATIONTAG']._serialized_start=6239 + _globals['_CALIBRATIONTAG']._serialized_end=6270 + _globals['_COMPRESSDURATIONTAG']._serialized_start=6272 + _globals['_COMPRESSDURATIONTAG']._serialized_end=6293 + _globals['_INTERNALTAG']._serialized_start=6296 + _globals['_INTERNALTAG']._serialized_end=6637 + _globals['_INTERNALTAG_TAGARGSENTRY']._serialized_start=6484 + _globals['_INTERNALTAG_TAGARGSENTRY']._serialized_end=6555 + _globals['_INTERNALTAG_CUSTOMARGSENTRY']._serialized_start=6557 + _globals['_INTERNALTAG_CUSTOMARGSENTRY']._serialized_end=6637 + _globals['_GATE']._serialized_start=6639 + _globals['_GATE']._serialized_end=6657 + _globals['_QUBIT']._serialized_start=6659 + _globals['_QUBIT']._serialized_end=6678 + _globals['_ARG']._serialized_start=6681 + _globals['_ARG']._serialized_end=6900 + _globals['_ARGVALUE']._serialized_start=6903 + _globals['_ARGVALUE']._serialized_end=7483 + _globals['_REPEATEDINT64']._serialized_start=7485 + _globals['_REPEATEDINT64']._serialized_end=7516 + _globals['_REPEATEDDOUBLE']._serialized_start=7518 + _globals['_REPEATEDDOUBLE']._serialized_end=7550 + _globals['_REPEATEDSTRING']._serialized_start=7552 + _globals['_REPEATEDSTRING']._serialized_end=7584 + _globals['_REPEATEDBOOLEAN']._serialized_start=7586 + _globals['_REPEATEDBOOLEAN']._serialized_end=7619 + _globals['_TUPLE']._serialized_start=7622 + _globals['_TUPLE']._serialized_end=7811 + _globals['_TUPLE_SEQUENCETYPE']._serialized_start=7735 + _globals['_TUPLE_SEQUENCETYPE']._serialized_end=7811 + _globals['_COMPLEX']._serialized_start=7813 + _globals['_COMPLEX']._serialized_end=7862 + _globals['_NDARRAY']._serialized_start=7865 + _globals['_NDARRAY']._serialized_end=8510 + _globals['_ARGFUNCTION']._serialized_start=8512 + _globals['_ARGFUNCTION']._serialized_end=8578 + _globals['_CIRCUITOPERATION']._serialized_start=8581 + _globals['_CIRCUITOPERATION']._serialized_end=9030 + _globals['_REPETITIONSPECIFICATION']._serialized_start=9033 + _globals['_REPETITIONSPECIFICATION']._serialized_end=9221 + _globals['_REPETITIONSPECIFICATION_REPETITIONIDS']._serialized_start=9173 + _globals['_REPETITIONSPECIFICATION_REPETITIONIDS']._serialized_end=9201 + _globals['_QUBITMAPPING']._serialized_start=9224 + _globals['_QUBITMAPPING']._serialized_end=9396 + _globals['_QUBITMAPPING_QUBITENTRY']._serialized_start=9302 + _globals['_QUBITMAPPING_QUBITENTRY']._serialized_end=9396 + _globals['_MEASUREMENTKEY']._serialized_start=9398 + _globals['_MEASUREMENTKEY']._serialized_end=9478 + _globals['_MEASUREMENTKEYMAPPING']._serialized_start=9481 + _globals['_MEASUREMENTKEYMAPPING']._serialized_end=9707 + _globals['_MEASUREMENTKEYMAPPING_MEASUREMENTKEYENTRY']._serialized_start=9586 + _globals['_MEASUREMENTKEYMAPPING_MEASUREMENTKEYENTRY']._serialized_end=9707 + _globals['_ARGMAPPING']._serialized_start=9710 + _globals['_ARGMAPPING']._serialized_end=9870 + _globals['_ARGMAPPING_ARGENTRY']._serialized_start=9782 + _globals['_ARGMAPPING_ARGENTRY']._serialized_end=9870 + _globals['_FUNCTIONINTERPOLATION']._serialized_start=9872 + _globals['_FUNCTIONINTERPOLATION']._serialized_end=9939 + _globals['_CUSTOMARG']._serialized_start=9941 + _globals['_CUSTOMARG']._serialized_end=10048 + _globals['_INTERNALGATE']._serialized_start=10051 + _globals['_INTERNALGATE']._serialized_end=10409 + _globals['_INTERNALGATE_GATEARGSENTRY']._serialized_start=10255 + _globals['_INTERNALGATE_GATEARGSENTRY']._serialized_end=10327 + _globals['_INTERNALGATE_CUSTOMARGSENTRY']._serialized_start=6557 + _globals['_INTERNALGATE_CUSTOMARGSENTRY']._serialized_end=6637 + _globals['_COUPLERPULSEGATE']._serialized_start=10412 + _globals['_COUPLERPULSEGATE']._serialized_end=10884 + _globals['_CLIFFORDTABLEAU']._serialized_start=10887 + _globals['_CLIFFORDTABLEAU']._serialized_end=11026 + _globals['_SINGLEQUBITCLIFFORDGATE']._serialized_start=11028 + _globals['_SINGLEQUBITCLIFFORDGATE']._serialized_end=11107 + _globals['_IDENTITYGATE']._serialized_start=11109 + _globals['_IDENTITYGATE']._serialized_end=11142 + _globals['_HPOWGATE']._serialized_start=11144 + _globals['_HPOWGATE']._serialized_end=11202 + _globals['_RESETGATE']._serialized_start=11205 + _globals['_RESETGATE']._serialized_end=11376 + _globals['_RESETGATE_ARGUMENTSENTRY']._serialized_start=11303 + _globals['_RESETGATE_ARGUMENTSENTRY']._serialized_end=11376 # @@protoc_insertion_point(module_scope) diff --git a/cirq-google/cirq_google/api/v2/program_pb2.pyi b/cirq-google/cirq_google/api/v2/program_pb2.pyi index 0cf28a7cb4d..2f4e23b0c23 100644 --- a/cirq-google/cirq_google/api/v2/program_pb2.pyi +++ b/cirq-google/cirq_google/api/v2/program_pb2.pyi @@ -30,6 +30,7 @@ class Program(google.protobuf.message.Message): LANGUAGE_FIELD_NUMBER: builtins.int CIRCUIT_FIELD_NUMBER: builtins.int CONSTANTS_FIELD_NUMBER: builtins.int + KEYED_CIRCUITS_FIELD_NUMBER: builtins.int @property def language(self) -> global___Language: """The language in which the program is written.""" @@ -47,15 +48,24 @@ class Program(google.protobuf.message.Message): constants are referred to their index in this list, starting at zero. """ + @property + def keyed_circuits(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___KeyedCircuit]: + """A batch of circuits organized by a set of parameters. These + parameters should also be specified in the sweep as well. + This field can be used for efficient packing of circuit functions + that change based on parameters, or for batch sending of circuits. + """ + def __init__( self, *, language: global___Language | None = ..., circuit: global___Circuit | None = ..., constants: collections.abc.Iterable[global___Constant] | None = ..., + keyed_circuits: collections.abc.Iterable[global___KeyedCircuit] | None = ..., ) -> None: ... def HasField(self, field_name: typing.Literal["circuit", b"circuit", "language", b"language", "program", b"program"]) -> builtins.bool: ... - def ClearField(self, field_name: typing.Literal["circuit", b"circuit", "constants", b"constants", "language", b"language", "program", b"program"]) -> None: ... + def ClearField(self, field_name: typing.Literal["circuit", b"circuit", "constants", b"constants", "keyed_circuits", b"keyed_circuits", "language", b"language", "program", b"program"]) -> None: ... def WhichOneof(self, oneof_group: typing.Literal["program", b"program"]) -> typing.Literal["circuit"] | None: ... global___Program = Program @@ -112,6 +122,67 @@ class Constant(google.protobuf.message.Message): global___Constant = Constant +@typing.final +class KeyedCircuit(google.protobuf.message.Message): + """A batch of circuits organized by a set of parameters. These + parameters should also be specified in the sweep as well. + This field can be used for efficient packing of circuit functions + that change based on parameters, or for batch sending of circuits. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class ArgsEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + @property + def value(self) -> global___Arg: ... + def __init__( + self, + *, + key: builtins.str = ..., + value: global___Arg | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... + + ARGS_FIELD_NUMBER: builtins.int + CIRCUIT_FIELD_NUMBER: builtins.int + KEY_FIELD_NUMBER: builtins.int + key: builtins.str + """Optional key for program. + If provided, will be used as a key in a Mapping from string to Circuit. + """ + @property + def args(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___Arg]: + """Arguments for a cirq circuit which comes from run_context. + The key will be the name of the argument, and the value + will be the value passed into the function. + e.g. Arguments for a circuit function such as: + def circuit_fn(freq_GHz: float, num_cycles: int) -> Circuit + would have the two entries: "freq_GHz" and "num_cycles" + """ + + @property + def circuit(self) -> global___Circuit: + """The cirq circuit corresponding to the arguments args.""" + + def __init__( + self, + *, + args: collections.abc.Mapping[builtins.str, global___Arg] | None = ..., + circuit: global___Circuit | None = ..., + key: builtins.str = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["circuit", b"circuit"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["args", b"args", "circuit", b"circuit", "key", b"key"]) -> None: ... + +global___KeyedCircuit = KeyedCircuit + @typing.final class Circuit(google.protobuf.message.Message): """The quantum circuit, specified as a series of moments (abstract diff --git a/cirq-google/cirq_google/serialization/circuit_serializer.py b/cirq-google/cirq_google/serialization/circuit_serializer.py index 8f13b8007d5..fd8d25c34ad 100644 --- a/cirq-google/cirq_google/serialization/circuit_serializer.py +++ b/cirq-google/cirq_google/serialization/circuit_serializer.py @@ -17,8 +17,10 @@ from __future__ import annotations import functools +import inspect import warnings -from typing import Any, Hashable +from collections.abc import Mapping, Sequence +from typing import Any, Callable, Hashable import sympy @@ -101,7 +103,7 @@ def serialize( results. Raises: - NotImplementedError: If the program is of a type that is supported. + NotImplementedError: If the program is of a type that is not supported. """ if not isinstance(program, (cirq.Circuit, cirq.FrozenCircuit)): raise NotImplementedError(f'Unrecognized program type: {type(program)}') @@ -116,6 +118,118 @@ def serialize( ) return msg + def serialize_multi_program( + self, + multi_program: Sequence[cirq.AbstractCircuit] | Mapping[str, cirq.AbstractCircuit], + msg: v2.program_pb2.Program | None = None, + ) -> v2.program_pb2.Program: + """Serialize multiple related circuits to cirq_google.api.v2.Program proto. + + Args: + multi_program: A collection of circuits to serialize. This + should take the form of either a sequence of circuits (such as a list) + or a mapping from a key string to circuits. + msg: An optional proto object to populate with the serialization + results. + + Raises: + NotImplementedError: If the program is of a type that is not supported. + ValueError: If the function returns something not a circuit. + """ + raw_constants: dict[Any, int] = {} + if msg is None: + msg = v2.program_pb2.Program() + msg.language.gate_set = self.name + msg.language.arg_function_language = 'exp' + if isinstance(multi_program, Mapping): + for key, program in multi_program.items(): + new_program = msg.keyed_circuits.add() + new_program.key = key + self._serialize_circuit( + program, + new_program.circuit, + constants=msg.constants, + raw_constants=raw_constants, + ) + elif isinstance(multi_program, Sequence): + for program in multi_program: + new_program = msg.keyed_circuits.add() + self._serialize_circuit( + program, + new_program.circuit, + constants=msg.constants, + raw_constants=raw_constants, + ) + else: + raise NotImplementedError(f'Unrecognized program type: {type(multi_program)}') + return msg + + def serialize_circuit_function( + self, + circuit_function: ( + Callable[..., cirq.AbstractCircuit] | Callable[..., Mapping[str, cirq.AbstractCircuit]] + ), + sweep: cirq.Sweep, + msg: v2.program_pb2.Program | None = None, + ) -> v2.program_pb2.Program: + """Serialize multiple related circuits to cirq_google.api.v2.Program proto. + + Args: + circuit_function: A function returning circuits to serialize. + This function should return a circuit or mapping from string to + a circuit. The arguments in this function should match a (subset of) + the parameters in the accompanied sweep call. The function will + be unrolled for each combination of sweep parameters. + sweep: If a function is passed in, this will be the sweep to call on the + function. + msg: An optional proto object to populate with the serialization + results. + + Raises: + NotImplementedError: If the program is of a type that is not supported. + ValueError: If the function returns something not a circuit. + """ + raw_constants: dict[Any, int] = {} + if msg is None: + msg = v2.program_pb2.Program() + msg.language.gate_set = self.name + msg.language.arg_function_language = 'exp' + if not callable(circuit_function): + raise NotImplementedError(f'Unrecognized program type: {type(circuit_function)}') + + sig = inspect.signature(circuit_function) + if all(p.kind != inspect.Parameter.VAR_KEYWORD for p in sig.parameters.values()): + # func does not accept **kwds, call with named parameters only. + names = set(sig.parameters) + else: + # func accepts **kwds, call with all parameters from resolver. + names = None + for param_tuple in sweep.param_tuples(): + if names is None: + circuit_or_map = circuit_function(**dict(param_tuple)) + else: + circuit_or_map = circuit_function( + **dict({k: v for k, v in param_tuple if k in names}) + ) + if isinstance(circuit_or_map, cirq.AbstractCircuit): + circuit_tuples: Sequence[tuple[str, cirq.AbstractCircuit]] = [("", circuit_or_map)] + elif isinstance(circuit_or_map, Mapping): + circuit_tuples = list(circuit_or_map.items()) + else: + raise ValueError(f'Function returned unrecognized type: {type(circuit_or_map)}') + for key, circuit in circuit_tuples: + new_program = msg.keyed_circuits.add() + new_program.key = key + for key, val in param_tuple: + arg_func_langs.arg_to_proto(val, out=new_program.args[key]) + self._serialize_circuit( + circuit, + new_program.circuit, + constants=msg.constants, + raw_constants=raw_constants, + ) + return msg + def _serialize_circuit( self, circuit: cirq.AbstractCircuit, @@ -426,6 +540,35 @@ def _serialize_circuit_op( raw_constants[circuit] = len(constants) - 1 return serializer.to_proto(op, msg, constants=constants, raw_constants=raw_constants) + def deserialize_multi_program( + self, proto: v2.program_pb2.Program + ) -> Sequence[tuple[str, tuple[tuple[str, Any], ...], cirq.AbstractCircuit]]: + """Deserialize multiple circuits from a KeyedCircuit in a Program proto. + + This unrolls the KeyedCircuit message with a Program proto into a list + of circuits. Returned is a list of tuples in the form: + (key, (args,...), circuit). + + If the original input was a map, key will be populated. + If the input was a function, args will be populated with the input parameters. + If the input was a function that returned a map of circuits, then both + will be populated.""" + deserialized_constants: list[Any] = self._deserialize_constants(proto) + return_circuits: list[tuple[str, tuple[tuple[str, Any], ...], cirq.AbstractCircuit]] = [] + for keyed_circuit in proto.keyed_circuits: + key = keyed_circuit.key + param_tuples = tuple( + (param, arg_func_langs.arg_from_proto(arg)) + for param, arg in keyed_circuit.args.items() + ) + circuit = self._deserialize_circuit( + keyed_circuit.circuit, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + return_circuits.append((key, param_tuples, circuit)) + return return_circuits + def deserialize(self, proto: v2.program_pb2.Program) -> cirq.Circuit: """Deserialize a Circuit from a cirq_google.api.v2.Program. @@ -442,69 +585,8 @@ def deserialize(self, proto: v2.program_pb2.Program) -> cirq.Circuit: NotImplementedError: If the program proto does not contain a circuit or schedule. """ which = proto.WhichOneof('program') - if which == 'circuit': - deserialized_constants: list[Any] = [] - for constant in proto.constants: - which_const = constant.WhichOneof('const_value') - if which_const == 'string_value': - deserialized_constants.append(constant.string_value) - elif which_const == 'circuit_value': - circuit = self._deserialize_circuit( - constant.circuit_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - deserialized_constants.append(circuit.freeze()) - elif which_const == 'qubit': - deserialized_constants.append(v2.qubit_from_proto_id(constant.qubit.id)) - elif which_const == 'operation_value': - if self.op_deserializer and self.op_deserializer.can_deserialize_proto( - constant.operation_value - ): - op_pb = self.op_deserializer.from_proto( - constant.operation_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - elif self.stimcirq_deserializer.can_deserialize_proto(constant.operation_value): - op_pb = self.stimcirq_deserializer.from_proto( - constant.operation_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - else: - op_pb = self._deserialize_gate_op( - constant.operation_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - deserialized_constants.append(op_pb) - elif which_const == 'moment_value': - deserialized_constants.append( - self._deserialize_moment( - constant.moment_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - ) - elif which_const == 'tag_value': - if self.tag_deserializer and self.tag_deserializer.can_deserialize_proto( - constant.tag_value - ): - deserialized_constants.append( - self.tag_deserializer.from_proto( - constant.tag_value, - constants=proto.constants, - deserialized_constants=deserialized_constants, - ) - ) - else: - deserialized_constants.append(self._deserialize_tag(constant.tag_value)) - else: - msg = f'Unrecognized constant type {which_const}, ignoring.' # pragma: no cover - warnings.warn(msg) # pragma: no cover - deserialized_constants.append(None) # pragma: no cover + deserialized_constants: list[Any] = self._deserialize_constants(proto) circuit = self._deserialize_circuit( proto.circuit, constants=proto.constants, @@ -516,6 +598,71 @@ def deserialize(self, proto: v2.program_pb2.Program) -> cirq.Circuit: raise NotImplementedError('Program proto does not contain a circuit.') + def _deserialize_constants(self, proto: v2.program_pb2.Program) -> list[Any]: + deserialized_constants: list[Any] = [] + for constant in proto.constants: + which_const = constant.WhichOneof('const_value') + if which_const == 'string_value': + # No longer used, but kept for backwards compatibility. + deserialized_constants.append(constant.string_value) # pragma: nocover + elif which_const == 'circuit_value': + circuit = self._deserialize_circuit( + constant.circuit_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + deserialized_constants.append(circuit.freeze()) + elif which_const == 'qubit': + deserialized_constants.append(v2.qubit_from_proto_id(constant.qubit.id)) + elif which_const == 'operation_value': + if self.op_deserializer and self.op_deserializer.can_deserialize_proto( + constant.operation_value + ): + op_pb = self.op_deserializer.from_proto( + constant.operation_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + elif self.stimcirq_deserializer.can_deserialize_proto(constant.operation_value): + op_pb = self.stimcirq_deserializer.from_proto( + constant.operation_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + else: + op_pb = self._deserialize_gate_op( + constant.operation_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + deserialized_constants.append(op_pb) + elif which_const == 'moment_value': + deserialized_constants.append( + self._deserialize_moment( + constant.moment_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + ) + elif which_const == 'tag_value': + if self.tag_deserializer and self.tag_deserializer.can_deserialize_proto( + constant.tag_value + ): + deserialized_constants.append( + self.tag_deserializer.from_proto( + constant.tag_value, + constants=proto.constants, + deserialized_constants=deserialized_constants, + ) + ) + else: + deserialized_constants.append(self._deserialize_tag(constant.tag_value)) + else: + msg = f'Unrecognized constant type {which_const}, ignoring.' # pragma: no cover + warnings.warn(msg) # pragma: no cover + deserialized_constants.append(None) # pragma: no cover + return deserialized_constants + def _deserialize_circuit( self, circuit_proto: v2.program_pb2.Circuit, diff --git a/cirq-google/cirq_google/serialization/circuit_serializer_test.py b/cirq-google/cirq_google/serialization/circuit_serializer_test.py index 8feb79ceab4..193665e1e01 100644 --- a/cirq-google/cirq_google/serialization/circuit_serializer_test.py +++ b/cirq-google/cirq_google/serialization/circuit_serializer_test.py @@ -1415,3 +1415,91 @@ def test_stimcirq_gates(): msg = serializer.serialize(c) deserialized_circuit = serializer.deserialize(msg) assert deserialized_circuit == c + + +def _create_circuit(num_x: int, exponent: float) -> cirq.Circuit: + q = cirq.q(1, 2) + circuit = cirq.Circuit() + for i in range(num_x): + circuit.append(cirq.X(q) ** exponent) + return circuit + + +def _create_circuit_returns_map(num_x: int) -> dict[str, cirq.Circuit]: + q = cirq.q(1, 2) + rtn_map = {} + for key, gate in [("X", cirq.X), ("Y", cirq.Y), ("Z", cirq.Z)]: + circuit = cirq.Circuit() + for i in range(num_x): + circuit.append(gate(q)) + rtn_map[key] = circuit + return rtn_map + + +def _create_circuit_kwargs(**kwargs) -> cirq.Circuit: + return _create_circuit(kwargs['num_x'], kwargs['exponent']) + + +def test_multi_programs_list() -> None: + """Test serialize_multi_program with a list of circuits.""" + serializer = cg.CircuitSerializer() + circuits = [_create_circuit(i, 1.0) for i in range(10)] + proto = serializer.serialize_multi_program(circuits) + circuit_tuples = serializer.deserialize_multi_program(proto) + assert circuit_tuples == [("", (), circuit) for circuit in circuits] + + +def test_multi_programs_map() -> None: + """Test serialize_multi_program with a dictionary of circuits.""" + serializer = cg.CircuitSerializer() + circuits = {f"circuit_{i}": _create_circuit(i, 1.0) for i in range(10)} + proto = serializer.serialize_multi_program(circuits) + circuit_tuples = serializer.deserialize_multi_program(proto) + assert circuit_tuples == [(key, (), circuit) for key, circuit in circuits.items()] + + +@pytest.mark.parametrize('circuit_func', [_create_circuit, _create_circuit_kwargs]) +def test_multi_programs_function(circuit_func) -> None: + """Test serialize_circuit_function with a function that returns a circuit.""" + serializer = cg.CircuitSerializer() + sweep = cirq.Points('num_x', [1, 2, 4, 8, 16]) * cirq.Points('exponent', [0.25, 0.5, 0.75, 1.0]) + proto = serializer.serialize_circuit_function(circuit_func, sweep) + circuit_tuples = list(serializer.deserialize_multi_program(proto)) + assert len(circuit_tuples) == 20 + for param_tuple, circuit_tuple in zip(sweep.param_tuples(), circuit_tuples): + assert circuit_tuple[0] == "" + param_dict = dict(circuit_tuple[1]) + assert param_dict == dict(param_tuple) + assert circuit_tuple[2] == _create_circuit( + num_x=param_dict['num_x'], exponent=param_dict['exponent'] + ) + + +def test_multi_programs_function_map() -> None: + """Test serialize_circuit_function with a function that returns a dict of circuits.""" + serializer = cg.CircuitSerializer() + sweep = cirq.Points('num_x', [1, 2]) + proto = serializer.serialize_circuit_function(_create_circuit_returns_map, sweep) + circuit_tuples = list(serializer.deserialize_multi_program(proto)) + assert len(circuit_tuples) == 6 + q = cirq.q(1, 2) + assert circuit_tuples == [ + ("X", (("num_x", 1),), cirq.Circuit(cirq.X(q))), + ("Y", (("num_x", 1),), cirq.Circuit(cirq.Y(q))), + ("Z", (("num_x", 1),), cirq.Circuit(cirq.Z(q))), + ("X", (("num_x", 2),), cirq.Circuit(cirq.X(q), cirq.X(q))), + ("Y", (("num_x", 2),), cirq.Circuit(cirq.Y(q), cirq.Y(q))), + ("Z", (("num_x", 2),), cirq.Circuit(cirq.Z(q), cirq.Z(q))), + ] + + +def test_multi_programs_bad_function() -> None: + """Test serialize_circuit_function with a function that returns something besides circuits.""" + serializer = cg.CircuitSerializer() + + def _bad_function(num_x: int) -> float: + return num_x * 2.25 + + sweep = cirq.Points('num_x', [1, 2]) + with pytest.raises(ValueError, match="Function returned unrecognized type"): + _ = serializer.serialize_circuit_function(_bad_function, sweep) # type: ignore