Skip to content

Commit b8f0663

Browse files
authored
Add FSimViaModel Gate into device.proto (#6548)
* Add FSimViaModel Gate * Update the name * Add serialization on grid device * Fix the test
1 parent bc3f9ff commit b8f0663

File tree

5 files changed

+78
-41
lines changed

5 files changed

+78
-41
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ message GateSpecification {
5656
CouplerPulse coupler_pulse = 9;
5757
Measurement meas = 10;
5858
Wait wait = 11;
59+
FSimViaModel fsim_via_model = 12;
5960
}
6061

6162
// Gate types available to Google devices.
@@ -72,6 +73,7 @@ message GateSpecification {
7273
message CouplerPulse {}
7374
message Measurement {}
7475
message Wait {}
76+
message FSimViaModel {}
7577
}
7678

7779
message GateSet {

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

+40-38
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

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ class _GateRepresentations:
156156
gate_spec_name='meas', supported_gates=[cirq.GateFamily(cirq.MeasurementGate)]
157157
),
158158
_GateRepresentations(gate_spec_name='wait', supported_gates=[cirq.GateFamily(cirq.WaitGate)]),
159+
_GateRepresentations(
160+
gate_spec_name='fsim_via_model',
161+
supported_gates=[cirq.GateFamily(cirq.FSimGate, tags_to_accept=[ops.FSimViaModelTag()])],
162+
),
159163
]
160164

161165

cirq-google/cirq_google/devices/grid_device_test.py

+17
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def _create_device_spec_with_horizontal_couplings():
7777
'coupler_pulse',
7878
'meas',
7979
'wait',
80+
'fsim_via_model',
8081
]
8182
gate_durations = [(n, i * 1000) for i, n in enumerate(gate_names)]
8283
for gate_name, duration in sorted(gate_durations):
@@ -109,6 +110,7 @@ def _create_device_spec_with_horizontal_couplings():
109110
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse),
110111
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate),
111112
cirq.GateFamily(cirq.ops.wait_gate.WaitGate),
113+
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
112114
)
113115

114116
base_duration = cirq.Duration(picos=1_000)
@@ -139,6 +141,10 @@ def _create_device_spec_with_horizontal_couplings():
139141
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
140142
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
141143
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
144+
cirq.GateFamily(
145+
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
146+
): base_duration
147+
* 10,
142148
}
143149

144150
expected_target_gatesets = (
@@ -164,6 +170,7 @@ def _create_device_spec_with_horizontal_couplings():
164170
),
165171
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
166172
cirq.ops.wait_gate.WaitGate,
173+
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
167174
]
168175
),
169176
cirq_google.SycamoreTargetGateset(),
@@ -189,6 +196,7 @@ def _create_device_spec_with_horizontal_couplings():
189196
),
190197
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
191198
cirq.ops.wait_gate.WaitGate,
199+
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
192200
]
193201
),
194202
)
@@ -505,6 +513,7 @@ def test_device_from_device_information_equals_device_from_proto():
505513
cirq_google.experimental.ops.coupler_pulse.CouplerPulse,
506514
cirq.ops.measurement_gate.MeasurementGate,
507515
cirq.ops.wait_gate.WaitGate,
516+
cirq.GateFamily(cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]),
508517
)
509518

510519
base_duration = cirq.Duration(picos=1_000)
@@ -525,6 +534,10 @@ def test_device_from_device_information_equals_device_from_proto():
525534
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
526535
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
527536
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
537+
cirq.GateFamily(
538+
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
539+
): base_duration
540+
* 10,
528541
}
529542

530543
device_from_information = cirq_google.GridDevice._from_device_information(
@@ -627,6 +640,10 @@ def test_to_proto():
627640
cirq.GateFamily(cirq_google.experimental.ops.coupler_pulse.CouplerPulse): base_duration * 7,
628641
cirq.GateFamily(cirq.ops.measurement_gate.MeasurementGate): base_duration * 8,
629642
cirq.GateFamily(cirq.ops.wait_gate.WaitGate): base_duration * 9,
643+
cirq.GateFamily(
644+
cirq.ops.FSimGate, tags_to_accept=[cirq_google.FSimViaModelTag()]
645+
): base_duration
646+
* 10,
630647
}
631648

632649
spec = cirq_google.GridDevice._from_device_information(

0 commit comments

Comments
 (0)