Skip to content

Commit

Permalink
Add FSimViaModel Gate into device.proto (#6548)
Browse files Browse the repository at this point in the history
* Add FSimViaModel Gate

* Update the name

* Add serialization on grid device

* Fix the test
  • Loading branch information
BichengYing authored Apr 4, 2024
1 parent bc3f9ff commit b8f0663
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 41 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 @@ -56,6 +56,7 @@ message GateSpecification {
CouplerPulse coupler_pulse = 9;
Measurement meas = 10;
Wait wait = 11;
FSimViaModel fsim_via_model = 12;
}

// Gate types available to Google devices.
Expand All @@ -72,6 +73,7 @@ message GateSpecification {
message CouplerPulse {}
message Measurement {}
message Wait {}
message FSimViaModel {}
}

message GateSet {
Expand Down
78 changes: 40 additions & 38 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.

4 changes: 4 additions & 0 deletions cirq-google/cirq_google/devices/grid_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ class _GateRepresentations:
gate_spec_name='meas', supported_gates=[cirq.GateFamily(cirq.MeasurementGate)]
),
_GateRepresentations(gate_spec_name='wait', supported_gates=[cirq.GateFamily(cirq.WaitGate)]),
_GateRepresentations(
gate_spec_name='fsim_via_model',
supported_gates=[cirq.GateFamily(cirq.FSimGate, tags_to_accept=[ops.FSimViaModelTag()])],
),
]


Expand Down
17 changes: 17 additions & 0 deletions cirq-google/cirq_google/devices/grid_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _create_device_spec_with_horizontal_couplings():
'coupler_pulse',
'meas',
'wait',
'fsim_via_model',
]
gate_durations = [(n, i * 1000) for i, n in enumerate(gate_names)]
for gate_name, duration in sorted(gate_durations):
Expand Down Expand Up @@ -109,6 +110,7 @@ def _create_device_spec_with_horizontal_couplings():
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse),
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()]),
)

base_duration = cirq.Duration(picos=1_000)
Expand Down Expand Up @@ -139,6 +141,10 @@ def _create_device_spec_with_horizontal_couplings():
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
cirq.GateFamily(
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
): base_duration
* 10,
}

expected_target_gatesets = (
Expand All @@ -164,6 +170,7 @@ def _create_device_spec_with_horizontal_couplings():
),
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
cirq.ops.wait_gate.WaitGate,
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
]
),
cirq_google.SycamoreTargetGateset(),
Expand All @@ -189,6 +196,7 @@ def _create_device_spec_with_horizontal_couplings():
),
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
cirq.ops.wait_gate.WaitGate,
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
]
),
)
Expand Down Expand Up @@ -505,6 +513,7 @@ def test_device_from_device_information_equals_device_from_proto():
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
cirq.ops.measurement_gate.MeasurementGate,
cirq.ops.wait_gate.WaitGate,
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
)

base_duration = cirq.Duration(picos=1_000)
Expand All @@ -525,6 +534,10 @@ def test_device_from_device_information_equals_device_from_proto():
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
cirq.GateFamily(
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
): base_duration
* 10,
}

device_from_information = cirq_google.GridDevice._from_device_information(
Expand Down Expand Up @@ -627,6 +640,10 @@ def test_to_proto():
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
cirq.GateFamily(
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
): base_duration
* 10,
}

spec = cirq_google.GridDevice._from_device_information(
Expand Down

0 comments on commit b8f0663

Please sign in to comment.