Skip to content

Commit ae64988

Browse files
Add metadata property to device. (quantumlib#4868)
Adds metadata property default to None to all devices. I'm going to leave this open to vendors to add to this as they see fit. Part of quantumlib#4743 . Note that if in the process of deprecating other things for quantumlib#4744 , I will pull vendor devices onto using metadata to keep behavior working.
1 parent d163723 commit ae64988

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cirq-core/cirq/devices/device.py

+9
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ def decompose_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE':
105105
"""
106106
return operation
107107

108+
@property
109+
def metadata(self) -> Optional['DeviceMetadata']:
110+
"""Returns the associated Metadata with the device if applicable.
111+
112+
Returns:
113+
`cirq.DeviceMetadata` if specified by the device otherwise None.
114+
"""
115+
return None
116+
108117
def validate_operation(self, operation: 'cirq.Operation') -> None:
109118
"""Raises an exception if an operation is not valid.
110119

cirq-core/cirq/devices/device_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def test_qid_pair():
7878
cirq.SymmetricalQidPair(q0, q0)
7979

8080

81+
def test_device_metadata():
82+
class RawDevice(cirq.Device):
83+
pass
84+
85+
assert RawDevice().metadata is None
86+
87+
8188
def test_metadata():
8289
qubits = cirq.LineQubit.range(4)
8390
graph = nx.star_graph(3)

0 commit comments

Comments
 (0)