Skip to content

Commit 058e93e

Browse files
authored
Suppress warning from qiskit-ibm-runtime about max_circuits (#1535)
In qiskit-ibm-runtime 0.37, the `max_circuits` property of the package's backends now issues a deprecation warning. Experiments uses `max_circuits` to split jobs preemptively. Whether `max_circuits` is reported as finite or as `None` jobs should still work okay as long as they don't exceed other service limits. We don't want this `max_circuits` warning issued on every experiment run so we suppress internally.
1 parent a9a1ff5 commit 058e93e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

qiskit_experiments/framework/backend_data.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,22 @@ def max_circuits(self):
101101
if self._v1:
102102
return getattr(self._backend.configuration(), "max_experiments", None)
103103
elif self._v2:
104-
return self._backend.max_circuits
104+
with warnings.catch_warnings():
105+
# qiskit-ibm-runtime deprecated max_circuits:
106+
# https://github.com/Qiskit/qiskit-ibm-runtime/pull/2166
107+
# Suppress the warning so that we don't trigger it for the user
108+
# on every experiment run.
109+
#
110+
# Remove this warning filter if qiskit-ibm-runtime backends
111+
# change to reporting max_circuits as None without a warning.
112+
warnings.filterwarnings(
113+
"ignore",
114+
message=".*qiskit-ibm-runtime.*",
115+
category=DeprecationWarning,
116+
)
117+
max_circuits = getattr(self._backend, "max_circuits", None)
118+
119+
return max_circuits
105120
return None
106121

107122
@property

0 commit comments

Comments
 (0)