Skip to content

Commit

Permalink
Add Quantum Engine support for cirq.CZPowGate (#6562)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eliottrosenberg authored Apr 15, 2024
1 parent 7b7c93d commit 2eb6d63
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 43 deletions.
2 changes: 2 additions & 0 deletions cirq-google/cirq_google/api/v2/device.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -74,6 +75,7 @@ message GateSpecification {
message Measurement {}
message Wait {}
message FSimViaModel {}
message CZPowGate {}
}

message GateSet {
Expand Down
82 changes: 42 additions & 40 deletions cirq-google/cirq_google/api/v2/device_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions cirq-google/cirq_google/api/v2/device_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions cirq-google/cirq_google/devices/grid_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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=[
Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 2eb6d63

Please sign in to comment.