Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions qiskit_ibm_provider/ibm_backend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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::
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/qasm-filter-f9a5d66c28a21318.yaml
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions test/integration/test_filter_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)