Skip to content

Commit d3b90cb

Browse files
committed
Do not serialize additional_gates if it's missing
1 parent ceb9dbd commit d3b90cb

11 files changed

+17
-146
lines changed

cirq-core/cirq/protocols/json_test_data/GridDeviceMetadata.json

+2-24
Original file line numberDiff line numberDiff line change
@@ -277,35 +277,13 @@
277277
{
278278
"cirq_type": "CZTargetGateset",
279279
"atol": 1e-08,
280-
"allow_partial_czs": false,
281-
"additional_gates": [
282-
{
283-
"cirq_type": "GateFamily",
284-
"gate": "GlobalPhaseGate",
285-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
286-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
287-
"ignore_global_phase": true,
288-
"tags_to_accept": [],
289-
"tags_to_ignore": []
290-
}
291-
]
280+
"allow_partial_czs": false
292281
},
293282
{
294283
"cirq_type": "SqrtIswapTargetGateset",
295284
"atol": 1e-08,
296285
"required_sqrt_iswap_count": null,
297-
"use_sqrt_iswap_inv": false,
298-
"additional_gates": [
299-
{
300-
"cirq_type": "GateFamily",
301-
"gate": "GlobalPhaseGate",
302-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
303-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
304-
"ignore_global_phase": true,
305-
"tags_to_accept": [],
306-
"tags_to_ignore": []
307-
}
308-
]
286+
"use_sqrt_iswap_inv": false
309287
}
310288
]
311289
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cirq.GridDeviceMetadata(frozenset({(cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 1), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), (cirq.GridQubit(0, 2), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 1), cirq.GridQubit(0, 2))}), cirq.Gateset(cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.ZPowGate, cirq.CZ, (cirq.ISWAP**0.5), unroll_circuit_op = True), {cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(nanos=1), cirq.GateFamily(gate=cirq.ops.common_gates.YPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.ops.common_gates.ZPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.CZ, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=500), cirq.GateFamily(gate=(cirq.ISWAP**0.5), ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=600)}, frozenset({cirq.GridQubit(1, 0), cirq.GridQubit(0, 2), cirq.GridQubit(9, 9), cirq.GridQubit(10, 10), cirq.GridQubit(0, 1), cirq.GridQubit(1, 1), cirq.GridQubit(0, 0), cirq.GridQubit(1, 2)}), (cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False, additional_gates=[cirq.ops.global_phase_op.GlobalPhaseGate]), cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False, additional_gates=[cirq.ops.global_phase_op.GlobalPhaseGate])))
1+
cirq.GridDeviceMetadata(frozenset({(cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 1), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), (cirq.GridQubit(0, 2), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 1), cirq.GridQubit(0, 2))}), cirq.Gateset(cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.ZPowGate, cirq.CZ, (cirq.ISWAP**0.5), unroll_circuit_op = True), {cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(nanos=1), cirq.GateFamily(gate=cirq.ops.common_gates.YPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.ops.common_gates.ZPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.CZ, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=500), cirq.GateFamily(gate=(cirq.ISWAP**0.5), ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=600)}, frozenset({cirq.GridQubit(1, 0), cirq.GridQubit(0, 2), cirq.GridQubit(9, 9), cirq.GridQubit(10, 10), cirq.GridQubit(0, 1), cirq.GridQubit(1, 1), cirq.GridQubit(0, 0), cirq.GridQubit(1, 2)}), (cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False), cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False)))

cirq-core/cirq/protocols/json_test_data/SqrtIswapTargetGateset.json

+3-36
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,19 @@
33
"cirq_type": "SqrtIswapTargetGateset",
44
"atol": 1e-08,
55
"required_sqrt_iswap_count": null,
6-
"use_sqrt_iswap_inv": false,
7-
"additional_gates": [
8-
{
9-
"cirq_type": "GateFamily",
10-
"gate": "GlobalPhaseGate",
11-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
12-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
13-
"ignore_global_phase": true,
14-
"tags_to_accept": [],
15-
"tags_to_ignore": []
16-
}
17-
]
6+
"use_sqrt_iswap_inv": false
187
},
198
{
209
"cirq_type": "SqrtIswapTargetGateset",
2110
"atol": 1e-08,
2211
"required_sqrt_iswap_count": 1,
23-
"use_sqrt_iswap_inv": false,
24-
"additional_gates": [
25-
{
26-
"cirq_type": "GateFamily",
27-
"gate": "GlobalPhaseGate",
28-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
29-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
30-
"ignore_global_phase": true,
31-
"tags_to_accept": [],
32-
"tags_to_ignore": []
33-
}
34-
]
12+
"use_sqrt_iswap_inv": false
3513
},
3614
{
3715
"cirq_type": "SqrtIswapTargetGateset",
3816
"atol": 1e-06,
3917
"required_sqrt_iswap_count": 2,
40-
"use_sqrt_iswap_inv": true,
41-
"additional_gates": [
42-
{
43-
"cirq_type": "GateFamily",
44-
"gate": "GlobalPhaseGate",
45-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
46-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
47-
"ignore_global_phase": true,
48-
"tags_to_accept": [],
49-
"tags_to_ignore": []
50-
}
51-
]
18+
"use_sqrt_iswap_inv": true
5219
},
5320
{
5421
"cirq_type": "SqrtIswapTargetGateset",

cirq-core/cirq/protocols/json_test_data/SqrtIswapTargetGateset.repr

+3-33
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
11
[
22
cirq.SqrtIswapTargetGateset(
3-
atol=1e-08,
4-
required_sqrt_iswap_count=None,
5-
use_sqrt_iswap_inv=False,
6-
additional_gates=[
7-
cirq.GateFamily(
8-
gate=cirq.ops.global_phase_op.GlobalPhaseGate,
9-
ignore_global_phase=True,
10-
tags_to_accept=frozenset(),
11-
tags_to_ignore=frozenset(),
12-
)
13-
],
3+
atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False, additional_gates=[]
144
),
155
cirq.SqrtIswapTargetGateset(
16-
atol=1e-08,
17-
required_sqrt_iswap_count=1,
18-
use_sqrt_iswap_inv=False,
19-
additional_gates=[
20-
cirq.GateFamily(
21-
gate=cirq.ops.global_phase_op.GlobalPhaseGate,
22-
ignore_global_phase=True,
23-
tags_to_accept=frozenset(),
24-
tags_to_ignore=frozenset(),
25-
)
26-
],
6+
atol=1e-08, required_sqrt_iswap_count=1, use_sqrt_iswap_inv=False, additional_gates=[]
277
),
288
cirq.SqrtIswapTargetGateset(
29-
atol=1e-06,
30-
required_sqrt_iswap_count=2,
31-
use_sqrt_iswap_inv=True,
32-
additional_gates=[
33-
cirq.GateFamily(
34-
gate=cirq.ops.global_phase_op.GlobalPhaseGate,
35-
ignore_global_phase=True,
36-
tags_to_accept=frozenset(),
37-
tags_to_ignore=frozenset(),
38-
)
39-
],
9+
atol=1e-06, required_sqrt_iswap_count=2, use_sqrt_iswap_inv=True, additional_gates=[]
4010
),
4111
cirq.SqrtIswapTargetGateset(
4212
atol=1e-08,

cirq-core/cirq/transformers/target_gatesets/sqrt_iswap_gateset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __repr__(self) -> str:
110110
f'cirq.SqrtIswapTargetGateset('
111111
f'atol={self.atol}, '
112112
f'required_sqrt_iswap_count={self.required_sqrt_iswap_count}, '
113-
f'use_sqrt_iswap_inv={self.use_sqrt_iswap_inv},'
113+
f'use_sqrt_iswap_inv={self.use_sqrt_iswap_inv}, '
114114
f'additional_gates=[{self._additional_gates_repr_str}]'
115115
f')'
116116
)

cirq-google/cirq_google/json_test_data/GridDevice.json

+2-24
Original file line numberDiff line numberDiff line change
@@ -279,35 +279,13 @@
279279
{
280280
"cirq_type": "CZTargetGateset",
281281
"atol": 1e-08,
282-
"allow_partial_czs": false,
283-
"additional_gates": [
284-
{
285-
"cirq_type": "GateFamily",
286-
"gate": "GlobalPhaseGate",
287-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
288-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
289-
"ignore_global_phase": true,
290-
"tags_to_accept": [],
291-
"tags_to_ignore": []
292-
}
293-
]
282+
"allow_partial_czs": false
294283
},
295284
{
296285
"cirq_type": "SqrtIswapTargetGateset",
297286
"atol": 1e-08,
298287
"required_sqrt_iswap_count": null,
299-
"use_sqrt_iswap_inv": false,
300-
"additional_gates": [
301-
{
302-
"cirq_type": "GateFamily",
303-
"gate": "GlobalPhaseGate",
304-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
305-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
306-
"ignore_global_phase": true,
307-
"tags_to_accept": [],
308-
"tags_to_ignore": []
309-
}
310-
]
288+
"use_sqrt_iswap_inv": false
311289
}
312290
]
313291
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cirq_google.GridDevice(cirq.GridDeviceMetadata(frozenset({(cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(0, 1), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), (cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 2), cirq.GridQubit(1, 2))}), cirq.Gateset(cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.ZPowGate, cirq.CZ, (cirq.ISWAP**0.5), unroll_circuit_op = True), {cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(nanos=1), cirq.GateFamily(gate=cirq.ops.common_gates.YPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.ops.common_gates.ZPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.CZ, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=500), cirq.GateFamily(gate=(cirq.ISWAP**0.5), ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=600)}, frozenset({cirq.GridQubit(9, 9), cirq.GridQubit(0, 1), cirq.GridQubit(1, 1), cirq.GridQubit(0, 0), cirq.GridQubit(1, 2), cirq.GridQubit(10, 10), cirq.GridQubit(1, 0), cirq.GridQubit(0, 2)}), (cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False, additional_gates=[cirq.ops.global_phase_op.GlobalPhaseGate]), cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False, additional_gates=[cirq.ops.global_phase_op.GlobalPhaseGate]))))
1+
cirq_google.GridDevice(cirq.GridDeviceMetadata(frozenset({(cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(0, 1), cirq.GridQubit(1, 1)), (cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)), (cirq.GridQubit(1, 1), cirq.GridQubit(1, 2)), (cirq.GridQubit(0, 2), cirq.GridQubit(1, 2))}), cirq.Gateset(cirq.ops.common_gates.XPowGate, cirq.ops.common_gates.YPowGate, cirq.ops.common_gates.ZPowGate, cirq.CZ, (cirq.ISWAP**0.5), unroll_circuit_op = True), {cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(nanos=1), cirq.GateFamily(gate=cirq.ops.common_gates.YPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.ops.common_gates.ZPowGate, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=1), cirq.GateFamily(gate=cirq.CZ, ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=500), cirq.GateFamily(gate=(cirq.ISWAP**0.5), ignore_global_phase=True, tags_to_accept=frozenset(), tags_to_ignore=frozenset()): cirq.Duration(picos=600)}, frozenset({cirq.GridQubit(9, 9), cirq.GridQubit(0, 1), cirq.GridQubit(1, 1), cirq.GridQubit(0, 0), cirq.GridQubit(1, 2), cirq.GridQubit(10, 10), cirq.GridQubit(1, 0), cirq.GridQubit(0, 2)}), (cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False), cirq.SqrtIswapTargetGateset(atol=1e-08, required_sqrt_iswap_count=None, use_sqrt_iswap_inv=False))))

cirq-google/cirq_google/json_test_data/cirq.google.ExecutableGroupResult.json

+1-12
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@
1515
"target_gateset": {
1616
"cirq_type": "CZTargetGateset",
1717
"atol": 1e-08,
18-
"allow_partial_czs": false,
19-
"additional_gates": [
20-
{
21-
"cirq_type": "GateFamily",
22-
"gate": "GlobalPhaseGate",
23-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
24-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
25-
"ignore_global_phase": true,
26-
"tags_to_accept": [],
27-
"tags_to_ignore": []
28-
}
29-
]
18+
"allow_partial_czs": false
3019
}
3120
},
3221
"shared_runtime_info": {

cirq-google/cirq_google/json_test_data/cirq.google.ExecutableGroupResult.repr

+1-1
Large diffs are not rendered by default.

cirq-google/cirq_google/json_test_data/cirq.google.QuantumRuntimeConfiguration.json

+1-12
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@
1313
"target_gateset": {
1414
"cirq_type": "CZTargetGateset",
1515
"atol": 1e-08,
16-
"allow_partial_czs": false,
17-
"additional_gates": [
18-
{
19-
"cirq_type": "GateFamily",
20-
"gate": "GlobalPhaseGate",
21-
"name": "Type GateFamily: cirq.ops.global_phase_op.GlobalPhaseGate",
22-
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.global_phase_op.GlobalPhaseGate)`",
23-
"ignore_global_phase": true,
24-
"tags_to_accept": [],
25-
"tags_to_ignore": []
26-
}
27-
]
16+
"allow_partial_czs": false
2817
}
2918
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cirq_google.QuantumRuntimeConfiguration(processor_record=cirq_google.SimulatedProcessorRecord(processor_id='rainbow', noise_strength=0), run_id='unit-test', random_seed=None, qubit_placer=cirq_google.NaiveQubitPlacer(), target_gateset=cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False, additional_gates=[cirq.ops.global_phase_op.GlobalPhaseGate]))
1+
cirq_google.QuantumRuntimeConfiguration(processor_record=cirq_google.SimulatedProcessorRecord(processor_id='rainbow', noise_strength=0), run_id='unit-test', random_seed=None, qubit_placer=cirq_google.NaiveQubitPlacer(), target_gateset=cirq.CZTargetGateset(atol=1e-08, allow_partial_czs=False))

0 commit comments

Comments
 (0)