From 64402f5a2e3a913e6edf011b07c9c591d2b1c4e2 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Sat, 3 Feb 2024 13:02:09 -0500 Subject: [PATCH] Deprecate BackendData.is_simulator No code in qiskit-experiments depends on `is_simulator` already and `BackendV2` does not provide a standard way to check if a backend uses a simulator. The code currently tries checking if a backend is a subclass of some known fake backend classes from qiskit and qiskit-ibm-runtime, but this code is awkward and seems to be doing something awkward for little benefit. --- qiskit_experiments/framework/backend_data.py | 11 +++++++++++ .../deprecate-is-simulator-c101197a126e456f.yaml | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 releasenotes/notes/deprecate-is-simulator-c101197a126e456f.yaml diff --git a/qiskit_experiments/framework/backend_data.py b/qiskit_experiments/framework/backend_data.py index 3d4e91eb92..c306e97edf 100644 --- a/qiskit_experiments/framework/backend_data.py +++ b/qiskit_experiments/framework/backend_data.py @@ -19,6 +19,7 @@ class unifies data access for various data fields. from qiskit.providers import BackendV1, BackendV2 from qiskit.providers.fake_provider import FakeBackend from qiskit.providers.fake_provider.fake_backend import FakeBackendV2 +from qiskit.utils.deprecation import deprecate_func try: # Removed in Qiskit 1.0. Different from the other FakeBackendV2's @@ -274,6 +275,16 @@ def num_qubits(self): return None @property + @deprecate_func( + is_property=True, + since="0.6", + additional_msg=( + "is_simulator is deprecated because BackendV2 does not provide a " + "standard way for checking this property. Calling code must " + "determine if a backend uses a simulator from context." + ), + package_name="qiskit-experiments", + ) # Note: remove all FakeBackend imports when removing this code def is_simulator(self): """Returns True given an indication the backend is a simulator diff --git a/releasenotes/notes/deprecate-is-simulator-c101197a126e456f.yaml b/releasenotes/notes/deprecate-is-simulator-c101197a126e456f.yaml new file mode 100644 index 0000000000..104ce61aaf --- /dev/null +++ b/releasenotes/notes/deprecate-is-simulator-c101197a126e456f.yaml @@ -0,0 +1,9 @@ +--- +deprecations: + - | + :attr:`.BackendData.is_simulator` has been deprecated. + :class:`~qiskit.providers.BackendV2` does not provide a standard interface + for determining if a backend uses a simulator. Calling code must determine + if a backend uses a simulator through some other means. Qiskit Experiments + does not treat simulator-backed backends differently from hardware backed + ones.