From f246c2be59458940ad982e43177198c5a2014ae9 Mon Sep 17 00:00:00 2001 From: Seneca Meeks Date: Wed, 22 May 2024 15:44:03 -0700 Subject: [PATCH] Add Quantum Engine Support for InternalGate (#6613) * add internal gate to device proto * build protos * tests pass * add docstring * build protos * build protos --- cirq-google/cirq_google/api/v2/device.proto | 4 + cirq-google/cirq_google/api/v2/device_pb2.py | 86 ++++++++++--------- cirq-google/cirq_google/api/v2/device_pb2.pyi | 22 ++++- .../cirq_google/devices/grid_device.py | 3 + .../cirq_google/devices/grid_device_test.py | 9 ++ 5 files changed, 79 insertions(+), 45 deletions(-) diff --git a/cirq-google/cirq_google/api/v2/device.proto b/cirq-google/cirq_google/api/v2/device.proto index 65b779e7046..da0d6a6c426 100644 --- a/cirq-google/cirq_google/api/v2/device.proto +++ b/cirq-google/cirq_google/api/v2/device.proto @@ -58,6 +58,7 @@ message GateSpecification { Wait wait = 11; FSimViaModel fsim_via_model = 12; CZPowGate cz_pow_gate = 13; + InternalGate internal_gate = 14; } // Gate types available to Google devices. @@ -76,6 +77,9 @@ message GateSpecification { message Wait {} message FSimViaModel {} message CZPowGate {} + // This gate gets mapped to the internal representation corresponding + // to . + message InternalGate {} } message GateSet { diff --git a/cirq-google/cirq_google/api/v2/device_pb2.py b/cirq-google/cirq_google/api/v2/device_pb2.py index b1ce40e172b..23f7899852f 100644 --- a/cirq-google/cirq_google/api/v2/device_pb2.py +++ b/cirq-google/cirq_google/api/v2/device_pb2.py @@ -13,7 +13,7 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1f\x63irq_google/api/v2/device.proto\x12\x12\x63irq.google.api.v2\"\xfa\x01\n\x13\x44\x65viceSpecification\x12\x38\n\x0fvalid_gate_sets\x18\x01 \x03(\x0b\x32\x1b.cirq.google.api.v2.GateSetB\x02\x18\x01\x12:\n\x0bvalid_gates\x18\x05 \x03(\x0b\x32%.cirq.google.api.v2.GateSpecification\x12\x14\n\x0cvalid_qubits\x18\x02 \x03(\t\x12\x34\n\rvalid_targets\x18\x03 \x03(\x0b\x32\x1d.cirq.google.api.v2.TargetSet\x12!\n\x19\x64\x65veloper_recommendations\x18\x04 \x01(\t\"\xa1\x08\n\x11GateSpecification\x12\x1b\n\x13gate_duration_picos\x18\x01 \x01(\x03\x12=\n\x03syc\x18\x02 \x01(\x0b\x32..cirq.google.api.v2.GateSpecification.SycamoreH\x00\x12\x45\n\nsqrt_iswap\x18\x03 \x01(\x0b\x32/.cirq.google.api.v2.GateSpecification.SqrtISwapH\x00\x12L\n\x0esqrt_iswap_inv\x18\x04 \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.SqrtISwapInvH\x00\x12\x36\n\x02\x63z\x18\x05 \x01(\x0b\x32(.cirq.google.api.v2.GateSpecification.CZH\x00\x12\x43\n\tphased_xz\x18\x06 \x01(\x0b\x32..cirq.google.api.v2.GateSpecification.PhasedXZH\x00\x12I\n\x0cvirtual_zpow\x18\x07 \x01(\x0b\x32\x31.cirq.google.api.v2.GateSpecification.VirtualZPowH\x00\x12K\n\rphysical_zpow\x18\x08 \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.PhysicalZPowH\x00\x12K\n\rcoupler_pulse\x18\t \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.CouplerPulseH\x00\x12\x41\n\x04meas\x18\n \x01(\x0b\x32\x31.cirq.google.api.v2.GateSpecification.MeasurementH\x00\x12:\n\x04wait\x18\x0b \x01(\x0b\x32*.cirq.google.api.v2.GateSpecification.WaitH\x00\x12L\n\x0e\x66sim_via_model\x18\x0c \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.FSimViaModelH\x00\x12\x46\n\x0b\x63z_pow_gate\x18\r \x01(\x0b\x32/.cirq.google.api.v2.GateSpecification.CZPowGateH\x00\x1a\n\n\x08Sycamore\x1a\x0b\n\tSqrtISwap\x1a\x0e\n\x0cSqrtISwapInv\x1a\x04\n\x02\x43Z\x1a\n\n\x08PhasedXZ\x1a\r\n\x0bVirtualZPow\x1a\x0e\n\x0cPhysicalZPow\x1a\x0e\n\x0c\x43ouplerPulse\x1a\r\n\x0bMeasurement\x1a\x06\n\x04Wait\x1a\x0e\n\x0c\x46SimViaModel\x1a\x0b\n\tCZPowGateB\x06\n\x04gate\"P\n\x07GateSet\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\x0bvalid_gates\x18\x02 \x03(\x0b\x32\".cirq.google.api.v2.GateDefinition\"\xa1\x01\n\x0eGateDefinition\x12\n\n\x02id\x18\x01 \x01(\t\x12\x18\n\x10number_of_qubits\x18\x02 \x01(\x05\x12\x35\n\nvalid_args\x18\x03 \x03(\x0b\x32!.cirq.google.api.v2.ArgDefinition\x12\x1b\n\x13gate_duration_picos\x18\x04 \x01(\x03\x12\x15\n\rvalid_targets\x18\x05 \x03(\t\"\xda\x01\n\rArgDefinition\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).cirq.google.api.v2.ArgDefinition.ArgType\x12\x39\n\x0e\x61llowed_ranges\x18\x03 \x03(\x0b\x32!.cirq.google.api.v2.ArgumentRange\"G\n\x07\x41rgType\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\t\n\x05\x46LOAT\x10\x01\x12\x14\n\x10REPEATED_BOOLEAN\x10\x02\x12\n\n\x06STRING\x10\x03\"=\n\rArgumentRange\x12\x15\n\rminimum_value\x18\x01 \x01(\x02\x12\x15\n\rmaximum_value\x18\x02 \x01(\x02\"\xef\x01\n\tTargetSet\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x45\n\x0ftarget_ordering\x18\x02 \x01(\x0e\x32,.cirq.google.api.v2.TargetSet.TargetOrdering\x12+\n\x07targets\x18\x03 \x03(\x0b\x32\x1a.cirq.google.api.v2.Target\"`\n\x0eTargetOrdering\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\r\n\tSYMMETRIC\x10\x01\x12\x12\n\nASYMMETRIC\x10\x02\x1a\x02\x08\x01\x12\x1a\n\x12SUBSET_PERMUTATION\x10\x03\x1a\x02\x08\x01\"\x15\n\x06Target\x12\x0b\n\x03ids\x18\x01 \x03(\tB.\n\x1d\x63om.google.cirq.google.api.v2B\x0b\x44\x65viceProtoP\x01\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1f\x63irq_google/api/v2/device.proto\x12\x12\x63irq.google.api.v2\"\xfa\x01\n\x13\x44\x65viceSpecification\x12\x38\n\x0fvalid_gate_sets\x18\x01 \x03(\x0b\x32\x1b.cirq.google.api.v2.GateSetB\x02\x18\x01\x12:\n\x0bvalid_gates\x18\x05 \x03(\x0b\x32%.cirq.google.api.v2.GateSpecification\x12\x14\n\x0cvalid_qubits\x18\x02 \x03(\t\x12\x34\n\rvalid_targets\x18\x03 \x03(\x0b\x32\x1d.cirq.google.api.v2.TargetSet\x12!\n\x19\x64\x65veloper_recommendations\x18\x04 \x01(\t\"\xfe\x08\n\x11GateSpecification\x12\x1b\n\x13gate_duration_picos\x18\x01 \x01(\x03\x12=\n\x03syc\x18\x02 \x01(\x0b\x32..cirq.google.api.v2.GateSpecification.SycamoreH\x00\x12\x45\n\nsqrt_iswap\x18\x03 \x01(\x0b\x32/.cirq.google.api.v2.GateSpecification.SqrtISwapH\x00\x12L\n\x0esqrt_iswap_inv\x18\x04 \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.SqrtISwapInvH\x00\x12\x36\n\x02\x63z\x18\x05 \x01(\x0b\x32(.cirq.google.api.v2.GateSpecification.CZH\x00\x12\x43\n\tphased_xz\x18\x06 \x01(\x0b\x32..cirq.google.api.v2.GateSpecification.PhasedXZH\x00\x12I\n\x0cvirtual_zpow\x18\x07 \x01(\x0b\x32\x31.cirq.google.api.v2.GateSpecification.VirtualZPowH\x00\x12K\n\rphysical_zpow\x18\x08 \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.PhysicalZPowH\x00\x12K\n\rcoupler_pulse\x18\t \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.CouplerPulseH\x00\x12\x41\n\x04meas\x18\n \x01(\x0b\x32\x31.cirq.google.api.v2.GateSpecification.MeasurementH\x00\x12:\n\x04wait\x18\x0b \x01(\x0b\x32*.cirq.google.api.v2.GateSpecification.WaitH\x00\x12L\n\x0e\x66sim_via_model\x18\x0c \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.FSimViaModelH\x00\x12\x46\n\x0b\x63z_pow_gate\x18\r \x01(\x0b\x32/.cirq.google.api.v2.GateSpecification.CZPowGateH\x00\x12K\n\rinternal_gate\x18\x0e \x01(\x0b\x32\x32.cirq.google.api.v2.GateSpecification.InternalGateH\x00\x1a\n\n\x08Sycamore\x1a\x0b\n\tSqrtISwap\x1a\x0e\n\x0cSqrtISwapInv\x1a\x04\n\x02\x43Z\x1a\n\n\x08PhasedXZ\x1a\r\n\x0bVirtualZPow\x1a\x0e\n\x0cPhysicalZPow\x1a\x0e\n\x0c\x43ouplerPulse\x1a\r\n\x0bMeasurement\x1a\x06\n\x04Wait\x1a\x0e\n\x0c\x46SimViaModel\x1a\x0b\n\tCZPowGate\x1a\x0e\n\x0cInternalGateB\x06\n\x04gate\"P\n\x07GateSet\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\x0bvalid_gates\x18\x02 \x03(\x0b\x32\".cirq.google.api.v2.GateDefinition\"\xa1\x01\n\x0eGateDefinition\x12\n\n\x02id\x18\x01 \x01(\t\x12\x18\n\x10number_of_qubits\x18\x02 \x01(\x05\x12\x35\n\nvalid_args\x18\x03 \x03(\x0b\x32!.cirq.google.api.v2.ArgDefinition\x12\x1b\n\x13gate_duration_picos\x18\x04 \x01(\x03\x12\x15\n\rvalid_targets\x18\x05 \x03(\t\"\xda\x01\n\rArgDefinition\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\x04type\x18\x02 \x01(\x0e\x32).cirq.google.api.v2.ArgDefinition.ArgType\x12\x39\n\x0e\x61llowed_ranges\x18\x03 \x03(\x0b\x32!.cirq.google.api.v2.ArgumentRange\"G\n\x07\x41rgType\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\t\n\x05\x46LOAT\x10\x01\x12\x14\n\x10REPEATED_BOOLEAN\x10\x02\x12\n\n\x06STRING\x10\x03\"=\n\rArgumentRange\x12\x15\n\rminimum_value\x18\x01 \x01(\x02\x12\x15\n\rmaximum_value\x18\x02 \x01(\x02\"\xef\x01\n\tTargetSet\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x45\n\x0ftarget_ordering\x18\x02 \x01(\x0e\x32,.cirq.google.api.v2.TargetSet.TargetOrdering\x12+\n\x07targets\x18\x03 \x03(\x0b\x32\x1a.cirq.google.api.v2.Target\"`\n\x0eTargetOrdering\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\r\n\tSYMMETRIC\x10\x01\x12\x12\n\nASYMMETRIC\x10\x02\x1a\x02\x08\x01\x12\x1a\n\x12SUBSET_PERMUTATION\x10\x03\x1a\x02\x08\x01\"\x15\n\x06Target\x12\x0b\n\x03ids\x18\x01 \x03(\tB.\n\x1d\x63om.google.cirq.google.api.v2B\x0b\x44\x65viceProtoP\x01\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -30,45 +30,47 @@ _globals['_DEVICESPECIFICATION']._serialized_start=56 _globals['_DEVICESPECIFICATION']._serialized_end=306 _globals['_GATESPECIFICATION']._serialized_start=309 - _globals['_GATESPECIFICATION']._serialized_end=1366 - _globals['_GATESPECIFICATION_SYCAMORE']._serialized_start=1202 - _globals['_GATESPECIFICATION_SYCAMORE']._serialized_end=1212 - _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_start=1214 - _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_end=1225 - _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_start=1227 - _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_end=1241 - _globals['_GATESPECIFICATION_CZ']._serialized_start=1243 - _globals['_GATESPECIFICATION_CZ']._serialized_end=1247 - _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_start=1249 - _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_end=1259 - _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_start=1261 - _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_end=1274 - _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_start=1276 - _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_end=1290 - _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_start=1292 - _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_end=1306 - _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_start=1308 - _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_end=1321 - _globals['_GATESPECIFICATION_WAIT']._serialized_start=1323 - _globals['_GATESPECIFICATION_WAIT']._serialized_end=1329 - _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_start=1331 - _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_end=1345 - _globals['_GATESPECIFICATION_CZPOWGATE']._serialized_start=1347 - _globals['_GATESPECIFICATION_CZPOWGATE']._serialized_end=1358 - _globals['_GATESET']._serialized_start=1368 - _globals['_GATESET']._serialized_end=1448 - _globals['_GATEDEFINITION']._serialized_start=1451 - _globals['_GATEDEFINITION']._serialized_end=1612 - _globals['_ARGDEFINITION']._serialized_start=1615 - _globals['_ARGDEFINITION']._serialized_end=1833 - _globals['_ARGDEFINITION_ARGTYPE']._serialized_start=1762 - _globals['_ARGDEFINITION_ARGTYPE']._serialized_end=1833 - _globals['_ARGUMENTRANGE']._serialized_start=1835 - _globals['_ARGUMENTRANGE']._serialized_end=1896 - _globals['_TARGETSET']._serialized_start=1899 - _globals['_TARGETSET']._serialized_end=2138 - _globals['_TARGETSET_TARGETORDERING']._serialized_start=2042 - _globals['_TARGETSET_TARGETORDERING']._serialized_end=2138 - _globals['_TARGET']._serialized_start=2140 - _globals['_TARGET']._serialized_end=2161 + _globals['_GATESPECIFICATION']._serialized_end=1459 + _globals['_GATESPECIFICATION_SYCAMORE']._serialized_start=1279 + _globals['_GATESPECIFICATION_SYCAMORE']._serialized_end=1289 + _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_start=1291 + _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_end=1302 + _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_start=1304 + _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_end=1318 + _globals['_GATESPECIFICATION_CZ']._serialized_start=1320 + _globals['_GATESPECIFICATION_CZ']._serialized_end=1324 + _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_start=1326 + _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_end=1336 + _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_start=1338 + _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_end=1351 + _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_start=1353 + _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_end=1367 + _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_start=1369 + _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_end=1383 + _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_start=1385 + _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_end=1398 + _globals['_GATESPECIFICATION_WAIT']._serialized_start=1400 + _globals['_GATESPECIFICATION_WAIT']._serialized_end=1406 + _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_start=1408 + _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_end=1422 + _globals['_GATESPECIFICATION_CZPOWGATE']._serialized_start=1424 + _globals['_GATESPECIFICATION_CZPOWGATE']._serialized_end=1435 + _globals['_GATESPECIFICATION_INTERNALGATE']._serialized_start=1437 + _globals['_GATESPECIFICATION_INTERNALGATE']._serialized_end=1451 + _globals['_GATESET']._serialized_start=1461 + _globals['_GATESET']._serialized_end=1541 + _globals['_GATEDEFINITION']._serialized_start=1544 + _globals['_GATEDEFINITION']._serialized_end=1705 + _globals['_ARGDEFINITION']._serialized_start=1708 + _globals['_ARGDEFINITION']._serialized_end=1926 + _globals['_ARGDEFINITION_ARGTYPE']._serialized_start=1855 + _globals['_ARGDEFINITION_ARGTYPE']._serialized_end=1926 + _globals['_ARGUMENTRANGE']._serialized_start=1928 + _globals['_ARGUMENTRANGE']._serialized_end=1989 + _globals['_TARGETSET']._serialized_start=1992 + _globals['_TARGETSET']._serialized_end=2231 + _globals['_TARGETSET_TARGETORDERING']._serialized_start=2135 + _globals['_TARGETSET_TARGETORDERING']._serialized_end=2231 + _globals['_TARGET']._serialized_start=2233 + _globals['_TARGET']._serialized_end=2254 # @@protoc_insertion_point(module_scope) diff --git a/cirq-google/cirq_google/api/v2/device_pb2.pyi b/cirq-google/cirq_google/api/v2/device_pb2.pyi index 800a39ec770..40a833175ff 100644 --- a/cirq-google/cirq_google/api/v2/device_pb2.pyi +++ b/cirq-google/cirq_google/api/v2/device_pb2.pyi @@ -183,6 +183,18 @@ class GateSpecification(google.protobuf.message.Message): self, ) -> None: ... + @typing_extensions.final + class InternalGate(google.protobuf.message.Message): + """This gate gets mapped to the internal representation corresponding + to . + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + GATE_DURATION_PICOS_FIELD_NUMBER: builtins.int SYC_FIELD_NUMBER: builtins.int SQRT_ISWAP_FIELD_NUMBER: builtins.int @@ -196,6 +208,7 @@ class GateSpecification(google.protobuf.message.Message): WAIT_FIELD_NUMBER: builtins.int FSIM_VIA_MODEL_FIELD_NUMBER: builtins.int CZ_POW_GATE_FIELD_NUMBER: builtins.int + INTERNAL_GATE_FIELD_NUMBER: builtins.int gate_duration_picos: builtins.int """This defines the approximate duration to run the gate on the device, specified as an integer number of picoseconds. @@ -224,6 +237,8 @@ class GateSpecification(google.protobuf.message.Message): def fsim_via_model(self) -> global___GateSpecification.FSimViaModel: ... @property def cz_pow_gate(self) -> global___GateSpecification.CZPowGate: ... + @property + def internal_gate(self) -> global___GateSpecification.InternalGate: ... def __init__( self, *, @@ -240,10 +255,11 @@ class GateSpecification(google.protobuf.message.Message): wait: global___GateSpecification.Wait | None = ..., fsim_via_model: global___GateSpecification.FSimViaModel | None = ..., cz_pow_gate: global___GateSpecification.CZPowGate | None = ..., + internal_gate: global___GateSpecification.InternalGate | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["coupler_pulse", b"coupler_pulse", "cz", b"cz", "cz_pow_gate", b"cz_pow_gate", "fsim_via_model", b"fsim_via_model", "gate", b"gate", "meas", b"meas", "phased_xz", b"phased_xz", "physical_zpow", b"physical_zpow", "sqrt_iswap", b"sqrt_iswap", "sqrt_iswap_inv", b"sqrt_iswap_inv", "syc", b"syc", "virtual_zpow", b"virtual_zpow", "wait", b"wait"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["coupler_pulse", b"coupler_pulse", "cz", b"cz", "cz_pow_gate", b"cz_pow_gate", "fsim_via_model", b"fsim_via_model", "gate", b"gate", "gate_duration_picos", b"gate_duration_picos", "meas", b"meas", "phased_xz", b"phased_xz", "physical_zpow", b"physical_zpow", "sqrt_iswap", b"sqrt_iswap", "sqrt_iswap_inv", b"sqrt_iswap_inv", "syc", b"syc", "virtual_zpow", b"virtual_zpow", "wait", b"wait"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["gate", b"gate"]) -> typing_extensions.Literal["syc", "sqrt_iswap", "sqrt_iswap_inv", "cz", "phased_xz", "virtual_zpow", "physical_zpow", "coupler_pulse", "meas", "wait", "fsim_via_model", "cz_pow_gate"] | None: ... + def HasField(self, field_name: typing_extensions.Literal["coupler_pulse", b"coupler_pulse", "cz", b"cz", "cz_pow_gate", b"cz_pow_gate", "fsim_via_model", b"fsim_via_model", "gate", b"gate", "internal_gate", b"internal_gate", "meas", b"meas", "phased_xz", b"phased_xz", "physical_zpow", b"physical_zpow", "sqrt_iswap", b"sqrt_iswap", "sqrt_iswap_inv", b"sqrt_iswap_inv", "syc", b"syc", "virtual_zpow", b"virtual_zpow", "wait", b"wait"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["coupler_pulse", b"coupler_pulse", "cz", b"cz", "cz_pow_gate", b"cz_pow_gate", "fsim_via_model", b"fsim_via_model", "gate", b"gate", "gate_duration_picos", b"gate_duration_picos", "internal_gate", b"internal_gate", "meas", b"meas", "phased_xz", b"phased_xz", "physical_zpow", b"physical_zpow", "sqrt_iswap", b"sqrt_iswap", "sqrt_iswap_inv", b"sqrt_iswap_inv", "syc", b"syc", "virtual_zpow", b"virtual_zpow", "wait", b"wait"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["gate", b"gate"]) -> typing_extensions.Literal["syc", "sqrt_iswap", "sqrt_iswap_inv", "cz", "phased_xz", "virtual_zpow", "physical_zpow", "coupler_pulse", "meas", "wait", "fsim_via_model", "cz_pow_gate", "internal_gate"] | None: ... global___GateSpecification = GateSpecification diff --git a/cirq-google/cirq_google/devices/grid_device.py b/cirq-google/cirq_google/devices/grid_device.py index 8bf823eac31..a9ebdc206bd 100644 --- a/cirq-google/cirq_google/devices/grid_device.py +++ b/cirq-google/cirq_google/devices/grid_device.py @@ -164,6 +164,9 @@ class _GateRepresentations: gate_spec_name='fsim_via_model', supported_gates=[cirq.GateFamily(cirq.FSimGate, tags_to_accept=[ops.FSimViaModelTag()])], ), + _GateRepresentations( + gate_spec_name='internal_gate', supported_gates=[cirq.GateFamily(ops.InternalGate)] + ), ] diff --git a/cirq-google/cirq_google/devices/grid_device_test.py b/cirq-google/cirq_google/devices/grid_device_test.py index eebee6fc6cb..e2284044e3f 100644 --- a/cirq-google/cirq_google/devices/grid_device_test.py +++ b/cirq-google/cirq_google/devices/grid_device_test.py @@ -79,6 +79,7 @@ def _create_device_spec_with_horizontal_couplings(): 'wait', 'fsim_via_model', 'cz_pow_gate', + 'internal_gate', ] gate_durations = [(n, i * 1000) for i, n in enumerate(gate_names)] for gate_name, duration in sorted(gate_durations): @@ -113,6 +114,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq.GateFamily(cirq.ops.wait_gate.WaitGate), cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), cirq.GateFamily(cirq.CZPowGate), + cirq.GateFamily(cirq_google.InternalGate), ) base_duration = cirq.Duration(picos=1_000) @@ -148,6 +150,7 @@ def _create_device_spec_with_horizontal_couplings(): ): base_duration * 10, cirq.GateFamily(cirq.CZPowGate): base_duration * 11, + cirq.GateFamily(cirq_google.InternalGate): base_duration * 12, } expected_target_gatesets = ( @@ -175,6 +178,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.experimental.ops.coupler_pulse.CouplerPulse, cirq.ops.wait_gate.WaitGate, cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + cirq.GateFamily(cirq_google.InternalGate), ] ), cirq_google.SycamoreTargetGateset(), @@ -202,6 +206,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.experimental.ops.coupler_pulse.CouplerPulse, cirq.ops.wait_gate.WaitGate, cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + cirq.GateFamily(cirq_google.InternalGate), ] ), cirq.CZTargetGateset( @@ -230,6 +235,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.experimental.ops.coupler_pulse.CouplerPulse, cirq.ops.wait_gate.WaitGate, cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + cirq.GateFamily(cirq_google.InternalGate), ], ), ) @@ -548,6 +554,7 @@ def test_device_from_device_information_equals_device_from_proto(): cirq.ops.measurement_gate.MeasurementGate, cirq.ops.wait_gate.WaitGate, cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + cirq.GateFamily(cirq_google.InternalGate), ) base_duration = cirq.Duration(picos=1_000) @@ -573,6 +580,7 @@ def test_device_from_device_information_equals_device_from_proto(): ): base_duration * 10, cirq.GateFamily(cirq.CZPowGate): base_duration * 11, + cirq.GateFamily(cirq_google.InternalGate): base_duration * 12, } device_from_information = cirq_google.GridDevice._from_device_information( @@ -680,6 +688,7 @@ def test_to_proto(): ): base_duration * 10, cirq.GateFamily(cirq.CZPowGate): base_duration * 11, + cirq.GateFamily(cirq_google.InternalGate): base_duration * 12, } spec = cirq_google.GridDevice._from_device_information(