Skip to content

Commit 2eb6d63

Browse files
Add Quantum Engine support for cirq.CZPowGate (#6562)
* Add Quantum Engine support for cirq.CZPowGate * build protos * update test * update test * add _CZ_POWER_GATE_FAMILY and keep _CZ_GATE_FAMILY * small revert to original * black * update test * update test * update test * add _CZ_POWER_TARGET_GATES * update target gateset * update test * update gatesets * update gatesets * update gatesets * update test * update test * update test * POW instead of POWER * POW instead of POWER
1 parent 7b7c93d commit 2eb6d63

File tree

5 files changed

+106
-43
lines changed

5 files changed

+106
-43
lines changed

cirq-google/cirq_google/api/v2/device.proto

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ message GateSpecification {
5757
Measurement meas = 10;
5858
Wait wait = 11;
5959
FSimViaModel fsim_via_model = 12;
60+
CZPowGate cz_pow_gate = 13;
6061
}
6162

6263
// Gate types available to Google devices.
@@ -74,6 +75,7 @@ message GateSpecification {
7475
message Measurement {}
7576
message Wait {}
7677
message FSimViaModel {}
78+
message CZPowGate {}
7779
}
7880

7981
message GateSet {

cirq-google/cirq_google/api/v2/device_pb2.py

+42-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cirq-google/cirq_google/api/v2/device_pb2.pyi

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cirq-google/cirq_google/devices/grid_device.py

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
_SQRT_ISWAP_GATE_FAMILY = cirq.GateFamily(cirq.SQRT_ISWAP)
5454
_SQRT_ISWAP_INV_GATE_FAMILY = cirq.GateFamily(cirq.SQRT_ISWAP_INV)
5555
_CZ_GATE_FAMILY = cirq.GateFamily(cirq.CZ)
56+
_CZ_POW_GATE_FAMILY = cirq.GateFamily(cirq.CZPowGate)
5657

5758

5859
# TODO(#5050) Add GlobalPhaseGate
@@ -63,6 +64,8 @@
6364
_PHASED_XZ_GATE_FAMILY,
6465
_MEASUREMENT_GATE_FAMILY,
6566
]
67+
# Target gates of cirq.CZTargetGateset with allow_partial_czs=True.
68+
_CZ_POW_TARGET_GATES = [_CZ_POW_GATE_FAMILY, _PHASED_XZ_GATE_FAMILY, _MEASUREMENT_GATE_FAMILY]
6669
# Target gates of `cirq_google.SycamoreTargetGateset`.
6770
_SYC_TARGET_GATES = [
6871
_SYC_FSIM_GATE_FAMILY,
@@ -127,6 +130,7 @@ class _GateRepresentations:
127130
_GateRepresentations(
128131
gate_spec_name='cz', supported_gates=[_CZ_FSIM_GATE_FAMILY, _CZ_GATE_FAMILY]
129132
),
133+
_GateRepresentations(gate_spec_name='cz_pow_gate', supported_gates=[_CZ_POW_GATE_FAMILY]),
130134
_GateRepresentations(
131135
gate_spec_name='phased_xz',
132136
supported_gates=[
@@ -306,6 +310,13 @@ def _build_compilation_target_gatesets(
306310
additional_gates=list(gateset.gates - set(_SQRT_ISWAP_TARGET_GATES))
307311
)
308312
)
313+
if all(gate_family in gateset.gates for gate_family in _CZ_POW_TARGET_GATES):
314+
target_gatesets.append(
315+
cirq.CZTargetGateset(
316+
allow_partial_czs=True,
317+
additional_gates=list(gateset.gates - set(_CZ_POW_TARGET_GATES)),
318+
)
319+
)
309320

310321
return tuple(target_gatesets)
311322

0 commit comments

Comments
 (0)