diff --git a/cirq-core/cirq/devices/device.py b/cirq-core/cirq/devices/device.py index e6a4b8ae96f..73ccdfe2baa 100644 --- a/cirq-core/cirq/devices/device.py +++ b/cirq-core/cirq/devices/device.py @@ -105,6 +105,15 @@ def decompose_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE': """ return operation + @property + def metadata(self) -> Optional['DeviceMetadata']: + """Returns the associated Metadata with the device if applicable. + + Returns: + `cirq.DeviceMetadata` if specified by the device otherwise None. + """ + return None + def validate_operation(self, operation: 'cirq.Operation') -> None: """Raises an exception if an operation is not valid. diff --git a/cirq-core/cirq/devices/device_test.py b/cirq-core/cirq/devices/device_test.py index 9601eb26c9a..542bfd860aa 100644 --- a/cirq-core/cirq/devices/device_test.py +++ b/cirq-core/cirq/devices/device_test.py @@ -78,6 +78,13 @@ def test_qid_pair(): cirq.SymmetricalQidPair(q0, q0) +def test_device_metadata(): + class RawDevice(cirq.Device): + pass + + assert RawDevice().metadata is None + + def test_metadata(): qubits = cirq.LineQubit.range(4) graph = nx.star_graph(3)