13
13
# limitations under the License.
14
14
"""Metadata subtype for 2D Homogenous devices."""
15
15
16
- from typing import TYPE_CHECKING , Optional , FrozenSet , Iterable , Tuple , Dict
16
+ from typing import TYPE_CHECKING , cast , Optional , FrozenSet , Iterable , Tuple , Dict
17
17
18
18
import networkx as nx
19
19
from cirq import value
@@ -29,21 +29,21 @@ class GridDeviceMetadata(device.DeviceMetadata):
29
29
30
30
def __init__ (
31
31
self ,
32
- qubit_pairs : Iterable [Tuple ['cirq.Qid ' , 'cirq.Qid ' ]],
32
+ qubit_pairs : Iterable [Tuple ['cirq.GridQubit ' , 'cirq.GridQubit ' ]],
33
33
gateset : 'cirq.Gateset' ,
34
34
gate_durations : Optional [Dict ['cirq.GateFamily' , 'cirq.Duration' ]] = None ,
35
- all_qubits : Optional [Iterable ['cirq.Qid ' ]] = None ,
35
+ all_qubits : Optional [Iterable ['cirq.GridQubit ' ]] = None ,
36
36
compilation_target_gatesets : Iterable ['cirq.CompilationTargetGateset' ] = (),
37
37
):
38
38
"""Create a GridDeviceMetadata object.
39
39
40
- Create a GridDevice which has a well defined set of couplable
40
+ Create a grid device which has a well defined set of couplable
41
41
qubit pairs that have the same two qubit gates available in
42
42
both coupling directions. Gate times (if provided) are expected
43
43
to be uniform across all qubits on the device.
44
44
45
45
Args:
46
- qubit_pairs: Iterable of pairs of `cirq.Qid `s representing
46
+ qubit_pairs: Iterable of pairs of `cirq.GridQubit `s representing
47
47
bi-directional couplings.
48
48
gateset: `cirq.Gateset` indicating gates supported
49
49
everywhere on the device.
@@ -114,7 +114,16 @@ def __init__(
114
114
self ._gate_durations = gate_durations
115
115
116
116
@property
117
- def qubit_pairs (self ) -> FrozenSet [FrozenSet ['cirq.Qid' ]]:
117
+ def qubit_set (self ) -> FrozenSet ['cirq.GridQubit' ]:
118
+ """Returns the set of grid qubits on the device.
119
+
120
+ Returns:
121
+ Frozenset of qubits on device.
122
+ """
123
+ return cast (FrozenSet ['cirq.GridQubit' ], super ().qubit_set )
124
+
125
+ @property
126
+ def qubit_pairs (self ) -> FrozenSet [FrozenSet ['cirq.GridQubit' ]]:
118
127
"""Returns the set of all couple-able qubits on the device.
119
128
120
129
Each element in the outer frozenset is a 2-element frozenset representing a bidirectional
@@ -123,7 +132,7 @@ def qubit_pairs(self) -> FrozenSet[FrozenSet['cirq.Qid']]:
123
132
return self ._qubit_pairs
124
133
125
134
@property
126
- def isolated_qubits (self ) -> FrozenSet ['cirq.Qid ' ]:
135
+ def isolated_qubits (self ) -> FrozenSet ['cirq.GridQubit ' ]:
127
136
"""Returns the set of all isolated qubits on the device (if appliable)."""
128
137
return self ._isolated_qubits
129
138
0 commit comments