Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newly serializable gates to supported grid device gates #6499

Merged
merged 9 commits into from
Mar 20, 2024
15 changes: 13 additions & 2 deletions cirq-google/cirq_google/devices/grid_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Just cirq.I would be good, to be consistent with the other deserialized_forms. These are what we want to display in the gateset object, so here we keep it as simple as possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cirq.I is an object (an instance of cirq.IdentityGate), the others are classes. when I use cirq.I the code breaks because it assumes classes.

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(
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions cirq-google/cirq_google/devices/grid_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -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()]
Expand All @@ -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()]
Expand All @@ -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()]
Expand Down