Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic circuits backend filter #1291

Merged
merged 3 commits into from
Jan 2, 2024
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
11 changes: 11 additions & 0 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ def backends(
name: Optional[str] = None,
min_num_qubits: Optional[int] = None,
instance: Optional[str] = None,
dynamic_circuits: Optional[bool] = None,
filters: Optional[Callable[[List["ibm_backend.IBMBackend"]], bool]] = None,
**kwargs: Any,
) -> List["ibm_backend.IBMBackend"]:
Expand All @@ -548,6 +549,7 @@ def backends(
min_num_qubits: Minimum number of qubits the backend has to have.
instance: This is only supported for ``ibm_quantum`` runtime and is in the
hub/group/project format.
dynamic_circuits: Filter by whether the backend supports dynamic circuits.
filters: More complex filters, such as lambda functions.
For example::

Expand Down Expand Up @@ -630,6 +632,15 @@ def backends(
backends = list(
filter(lambda b: b.configuration().n_qubits >= min_num_qubits, 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 _set_backend_config(self, backend_name: str, instance: Optional[str] = None) -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
Added a new parameter, `dynamic_circuits` to :meth:`~qiskit_ibm_runtime.QiskitRuntimeService.backends`
to allow filtering of backends that support dynamic circuits.
Loading