diff --git a/cirq-google/cirq_google/api/v2/device.proto b/cirq-google/cirq_google/api/v2/device.proto index da9d3dec147..65b779e7046 100644 --- a/cirq-google/cirq_google/api/v2/device.proto +++ b/cirq-google/cirq_google/api/v2/device.proto @@ -57,6 +57,7 @@ message GateSpecification { Measurement meas = 10; Wait wait = 11; FSimViaModel fsim_via_model = 12; + CZPowGate cz_pow_gate = 13; } // Gate types available to Google devices. @@ -74,6 +75,7 @@ message GateSpecification { message Measurement {} message Wait {} message FSimViaModel {} + message CZPowGate {} } 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 df2635bba60..ccb0820f439 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\"\xcc\x07\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\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\x46SimViaModelB\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\"\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') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -31,43 +31,45 @@ _globals['_DEVICESPECIFICATION']._serialized_start=56 _globals['_DEVICESPECIFICATION']._serialized_end=306 _globals['_GATESPECIFICATION']._serialized_start=309 - _globals['_GATESPECIFICATION']._serialized_end=1281 - _globals['_GATESPECIFICATION_SYCAMORE']._serialized_start=1130 - _globals['_GATESPECIFICATION_SYCAMORE']._serialized_end=1140 - _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_start=1142 - _globals['_GATESPECIFICATION_SQRTISWAP']._serialized_end=1153 - _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_start=1155 - _globals['_GATESPECIFICATION_SQRTISWAPINV']._serialized_end=1169 - _globals['_GATESPECIFICATION_CZ']._serialized_start=1171 - _globals['_GATESPECIFICATION_CZ']._serialized_end=1175 - _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_start=1177 - _globals['_GATESPECIFICATION_PHASEDXZ']._serialized_end=1187 - _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_start=1189 - _globals['_GATESPECIFICATION_VIRTUALZPOW']._serialized_end=1202 - _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_start=1204 - _globals['_GATESPECIFICATION_PHYSICALZPOW']._serialized_end=1218 - _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_start=1220 - _globals['_GATESPECIFICATION_COUPLERPULSE']._serialized_end=1234 - _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_start=1236 - _globals['_GATESPECIFICATION_MEASUREMENT']._serialized_end=1249 - _globals['_GATESPECIFICATION_WAIT']._serialized_start=1251 - _globals['_GATESPECIFICATION_WAIT']._serialized_end=1257 - _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_start=1259 - _globals['_GATESPECIFICATION_FSIMVIAMODEL']._serialized_end=1273 - _globals['_GATESET']._serialized_start=1283 - _globals['_GATESET']._serialized_end=1363 - _globals['_GATEDEFINITION']._serialized_start=1366 - _globals['_GATEDEFINITION']._serialized_end=1527 - _globals['_ARGDEFINITION']._serialized_start=1530 - _globals['_ARGDEFINITION']._serialized_end=1748 - _globals['_ARGDEFINITION_ARGTYPE']._serialized_start=1677 - _globals['_ARGDEFINITION_ARGTYPE']._serialized_end=1748 - _globals['_ARGUMENTRANGE']._serialized_start=1750 - _globals['_ARGUMENTRANGE']._serialized_end=1811 - _globals['_TARGETSET']._serialized_start=1814 - _globals['_TARGETSET']._serialized_end=2053 - _globals['_TARGETSET_TARGETORDERING']._serialized_start=1957 - _globals['_TARGETSET_TARGETORDERING']._serialized_end=2053 - _globals['_TARGET']._serialized_start=2055 - _globals['_TARGET']._serialized_end=2076 + _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 # @@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 df4cfd5c783..800a39ec770 100644 --- a/cirq-google/cirq_google/api/v2/device_pb2.pyi +++ b/cirq-google/cirq_google/api/v2/device_pb2.pyi @@ -175,6 +175,14 @@ class GateSpecification(google.protobuf.message.Message): self, ) -> None: ... + @typing_extensions.final + class CZPowGate(google.protobuf.message.Message): + 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 @@ -187,6 +195,7 @@ class GateSpecification(google.protobuf.message.Message): MEAS_FIELD_NUMBER: builtins.int WAIT_FIELD_NUMBER: builtins.int FSIM_VIA_MODEL_FIELD_NUMBER: builtins.int + CZ_POW_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. @@ -213,6 +222,8 @@ class GateSpecification(google.protobuf.message.Message): def wait(self) -> global___GateSpecification.Wait: ... @property def fsim_via_model(self) -> global___GateSpecification.FSimViaModel: ... + @property + def cz_pow_gate(self) -> global___GateSpecification.CZPowGate: ... def __init__( self, *, @@ -228,10 +239,11 @@ class GateSpecification(google.protobuf.message.Message): meas: global___GateSpecification.Measurement | None = ..., wait: global___GateSpecification.Wait | None = ..., fsim_via_model: global___GateSpecification.FSimViaModel | None = ..., + cz_pow_gate: global___GateSpecification.CZPowGate | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["coupler_pulse", b"coupler_pulse", "cz", b"cz", "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", "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"] | 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: ... global___GateSpecification = GateSpecification diff --git a/cirq-google/cirq_google/devices/grid_device.py b/cirq-google/cirq_google/devices/grid_device.py index 2d80f4d3aff..8bf823eac31 100644 --- a/cirq-google/cirq_google/devices/grid_device.py +++ b/cirq-google/cirq_google/devices/grid_device.py @@ -53,6 +53,7 @@ _SQRT_ISWAP_GATE_FAMILY = cirq.GateFamily(cirq.SQRT_ISWAP) _SQRT_ISWAP_INV_GATE_FAMILY = cirq.GateFamily(cirq.SQRT_ISWAP_INV) _CZ_GATE_FAMILY = cirq.GateFamily(cirq.CZ) +_CZ_POW_GATE_FAMILY = cirq.GateFamily(cirq.CZPowGate) # TODO(#5050) Add GlobalPhaseGate @@ -63,6 +64,8 @@ _PHASED_XZ_GATE_FAMILY, _MEASUREMENT_GATE_FAMILY, ] +# Target gates of cirq.CZTargetGateset with allow_partial_czs=True. +_CZ_POW_TARGET_GATES = [_CZ_POW_GATE_FAMILY, _PHASED_XZ_GATE_FAMILY, _MEASUREMENT_GATE_FAMILY] # Target gates of `cirq_google.SycamoreTargetGateset`. _SYC_TARGET_GATES = [ _SYC_FSIM_GATE_FAMILY, @@ -127,6 +130,7 @@ class _GateRepresentations: _GateRepresentations( gate_spec_name='cz', supported_gates=[_CZ_FSIM_GATE_FAMILY, _CZ_GATE_FAMILY] ), + _GateRepresentations(gate_spec_name='cz_pow_gate', supported_gates=[_CZ_POW_GATE_FAMILY]), _GateRepresentations( gate_spec_name='phased_xz', supported_gates=[ @@ -306,6 +310,13 @@ def _build_compilation_target_gatesets( additional_gates=list(gateset.gates - set(_SQRT_ISWAP_TARGET_GATES)) ) ) + if all(gate_family in gateset.gates for gate_family in _CZ_POW_TARGET_GATES): + target_gatesets.append( + cirq.CZTargetGateset( + allow_partial_czs=True, + additional_gates=list(gateset.gates - set(_CZ_POW_TARGET_GATES)), + ) + ) return tuple(target_gatesets) diff --git a/cirq-google/cirq_google/devices/grid_device_test.py b/cirq-google/cirq_google/devices/grid_device_test.py index 7fb1fe7dfa6..eebee6fc6cb 100644 --- a/cirq-google/cirq_google/devices/grid_device_test.py +++ b/cirq-google/cirq_google/devices/grid_device_test.py @@ -78,6 +78,7 @@ def _create_device_spec_with_horizontal_couplings(): 'meas', 'wait', 'fsim_via_model', + 'cz_pow_gate', ] gate_durations = [(n, i * 1000) for i, n in enumerate(gate_names)] for gate_name, duration in sorted(gate_durations): @@ -111,6 +112,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate), cirq.GateFamily(cirq.ops.wait_gate.WaitGate), cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + cirq.GateFamily(cirq.CZPowGate), ) base_duration = cirq.Duration(picos=1_000) @@ -145,6 +147,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()] ): base_duration * 10, + cirq.GateFamily(cirq.CZPowGate): base_duration * 11, } expected_target_gatesets = ( @@ -156,6 +159,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq.GateFamily(cirq_google.SYC), cirq.GateFamily(cirq.SQRT_ISWAP), cirq.GateFamily(cirq.SQRT_ISWAP_INV), + cirq.GateFamily(cirq.CZPowGate), cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.HPowGate, @@ -181,6 +185,7 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.FSimGateFamily(gates_to_accept=[cirq.CZ]), cirq.GateFamily(cirq_google.SYC), cirq.GateFamily(cirq.SQRT_ISWAP_INV), + cirq.GateFamily(cirq.CZPowGate), cirq.GateFamily(cirq.CZ), cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, @@ -199,6 +204,34 @@ def _create_device_spec_with_horizontal_couplings(): cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), ] ), + cirq.CZTargetGateset( + allow_partial_czs=True, + additional_gates=[ + cirq_google.FSimGateFamily(gates_to_accept=[cirq_google.SYC]), + cirq_google.FSimGateFamily(gates_to_accept=[cirq.SQRT_ISWAP]), + cirq_google.FSimGateFamily(gates_to_accept=[cirq.SQRT_ISWAP_INV]), + cirq_google.FSimGateFamily(gates_to_accept=[cirq.CZ]), + cirq.GateFamily(cirq_google.SYC), + cirq.GateFamily(cirq.SQRT_ISWAP), + cirq.GateFamily(cirq.SQRT_ISWAP_INV), + cirq.GateFamily(cirq.CZ), + cirq.ops.common_gates.XPowGate, + cirq.ops.common_gates.YPowGate, + cirq.ops.common_gates.HPowGate, + cirq.GateFamily(cirq.I), + cirq.ops.SingleQubitCliffordGate, + cirq.ops.phased_x_gate.PhasedXPowGate, + cirq.GateFamily( + cirq.ops.common_gates.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()] + ), + cirq.GateFamily( + cirq.ops.common_gates.ZPowGate, tags_to_accept=[cirq_google.PhysicalZTag()] + ), + cirq_google.experimental.ops.coupler_pulse.CouplerPulse, + cirq.ops.wait_gate.WaitGate, + cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]), + ], + ), ) return ( @@ -503,6 +536,7 @@ def test_device_from_device_information_equals_device_from_proto(): cirq.SQRT_ISWAP, cirq.SQRT_ISWAP_INV, cirq.CZ, + cirq.GateFamily(cirq.CZPowGate), cirq.ops.phased_x_z_gate.PhasedXZGate, cirq.GateFamily( cirq.ops.common_gates.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()] @@ -538,6 +572,7 @@ def test_device_from_device_information_equals_device_from_proto(): cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()] ): base_duration * 10, + cirq.GateFamily(cirq.CZPowGate): base_duration * 11, } device_from_information = cirq_google.GridDevice._from_device_information( @@ -644,6 +679,7 @@ def test_to_proto(): cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()] ): base_duration * 10, + cirq.GateFamily(cirq.CZPowGate): base_duration * 11, } spec = cirq_google.GridDevice._from_device_information(