From 527af7735eb9bb4691dee8fb28e9e4d935b4a317 Mon Sep 17 00:00:00 2001 From: Noureldin Date: Wed, 20 Mar 2024 13:55:24 -0700 Subject: [PATCH] Add newly serializable gates to supported grid device gates (#6499) --- cirq-google/cirq_google/devices/grid_device.py | 15 +++++++++++++-- .../cirq_google/devices/grid_device_test.py | 12 ++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cirq-google/cirq_google/devices/grid_device.py b/cirq-google/cirq_google/devices/grid_device.py index 702e8698a07..7fc89f6c85e 100644 --- a/cirq-google/cirq_google/devices/grid_device.py +++ b/cirq-google/cirq_google/devices/grid_device.py @@ -112,12 +112,24 @@ class _GateRepresentations: ), _GateRepresentations( gate_spec_name='phased_xz', - deserialized_forms=[cirq.PhasedXZGate, cirq.XPowGate, cirq.YPowGate, cirq.PhasedXPowGate], + deserialized_forms=[ + cirq.PhasedXZGate, + cirq.XPowGate, + cirq.YPowGate, + cirq.PhasedXPowGate, + cirq.HPowGate, + cirq.GateFamily(cirq.I), + cirq.ops.SingleQubitCliffordGate, + ], serializable_forms=[ + # TODO: Extend support to cirq.IdentityGate. + cirq.GateFamily(cirq.I), cirq.GateFamily(cirq.PhasedXZGate), cirq.GateFamily(cirq.XPowGate), cirq.GateFamily(cirq.YPowGate), + cirq.GateFamily(cirq.HPowGate), cirq.GateFamily(cirq.PhasedXPowGate), + cirq.GateFamily(cirq.ops.SingleQubitCliffordGate), ], ), _GateRepresentations( @@ -263,7 +275,6 @@ def _deserialize_gateset_and_gate_durations( g = cirq.GateFamily(g) gate_durations[g] = cirq.Duration(picos=gate_spec.gate_duration_picos) - # TODO(#4833) Add identity gate support # TODO(#5050) Add GlobalPhaseGate support return cirq.Gateset(*gates_list), gate_durations diff --git a/cirq-google/cirq_google/devices/grid_device_test.py b/cirq-google/cirq_google/devices/grid_device_test.py index 560af1a373a..4367a7864d4 100644 --- a/cirq-google/cirq_google/devices/grid_device_test.py +++ b/cirq-google/cirq_google/devices/grid_device_test.py @@ -92,6 +92,9 @@ def _create_device_spec_with_horizontal_couplings(): cirq.ops.phased_x_z_gate.PhasedXZGate, cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, + cirq.GateFamily(cirq.I), + cirq.ops.SingleQubitCliffordGate, + cirq.ops.HPowGate, cirq.ops.phased_x_gate.PhasedXPowGate, cirq.GateFamily( cirq.ops.common_gates.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()] @@ -113,6 +116,9 @@ def _create_device_spec_with_horizontal_couplings(): cirq.GateFamily(cirq.ops.phased_x_z_gate.PhasedXZGate): base_duration * 4, cirq.GateFamily(cirq.ops.common_gates.XPowGate): base_duration * 4, cirq.GateFamily(cirq.ops.common_gates.YPowGate): base_duration * 4, + cirq.GateFamily(cirq.ops.common_gates.HPowGate): base_duration * 4, + cirq.GateFamily(cirq.I): base_duration * 4, + cirq.GateFamily(cirq.ops.SingleQubitCliffordGate): base_duration * 4, cirq.GateFamily(cirq.ops.phased_x_gate.PhasedXPowGate): base_duration * 4, cirq.GateFamily( cirq.ops.common_gates.ZPowGate, tags_to_ignore=[cirq_google.PhysicalZTag()] @@ -135,6 +141,9 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.FSimGateFamily(gates_to_accept=[cirq.SQRT_ISWAP_INV]), 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()] @@ -154,6 +163,9 @@ def _create_device_spec_with_horizontal_couplings(): cirq_google.FSimGateFamily(gates_to_accept=[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()]