diff --git a/qiskit_ibm_provider/ibm_backend_service.py b/qiskit_ibm_provider/ibm_backend_service.py index df218a786..ce8a621b6 100644 --- a/qiskit_ibm_provider/ibm_backend_service.py +++ b/qiskit_ibm_provider/ibm_backend_service.py @@ -109,6 +109,7 @@ def backends( min_num_qubits: Optional[int] = None, input_allowed: Optional[Union[str, List[str]]] = None, instance: Optional[str] = None, + dynamic_circuits: Optional[bool] = None, **kwargs: Any, ) -> List[IBMBackend]: """Return all backends accessible via this account, subject to optional filtering. @@ -127,6 +128,7 @@ def backends( that support Qiskit Runtime. If a list is given, the backend must support all types specified in the list. instance: The provider in the hub/group/project format. + dynamic_circuits: Filter by whether the backend supports dynamic circuits. **kwargs: Simple filters that specify a ``True``/``False`` criteria in the backend configuration, backends status, or provider credentials. An example to get the operational backends with 5 qubits:: @@ -166,6 +168,17 @@ def backends( backends, ) ) + if dynamic_circuits is not None: + backends = list( + filter( + lambda b: ( + "qasm3" in getattr(b.configuration(), "supported_features", []) + ) + == dynamic_circuits, + backends, + ) + ) + return filter_backends(backends, filters=filters, **kwargs) def jobs( diff --git a/releasenotes/notes/qasm-filter-f9a5d66c28a21318.yaml b/releasenotes/notes/qasm-filter-f9a5d66c28a21318.yaml new file mode 100644 index 000000000..f4bb813b5 --- /dev/null +++ b/releasenotes/notes/qasm-filter-f9a5d66c28a21318.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + You can now use the ``dynamic_circuits`` parameter in + :meth:`qiskit_ibm_provider.ibm_backend_service.IBMBackendService.backends` + to find backends that support dynamic circuits. diff --git a/test/integration/test_filter_backends.py b/test/integration/test_filter_backends.py index 8c4abd535..645063b6b 100644 --- a/test/integration/test_filter_backends.py +++ b/test/integration/test_filter_backends.py @@ -139,3 +139,9 @@ def test_filter_input_allowed(self): self.assertTrue( set(input_type) <= set(backend.configuration().input_allowed) ) + + def test_filter_dynamic_circuits(self): + """Test filtering by dynamic ciruits.""" + filtered = self.dependencies.provider.backends(dynamic_circuits=True) + for backend in filtered: + self.assertTrue("qasm3" in backend.configuration().supported_features)