qiskit-ibm-runtime icon indicating copy to clipboard operation
qiskit-ibm-runtime copied to clipboard

Suggest raise error if QiskitRuntimeService.backend() has to pick from multiple backends

Open mriedem opened this issue 1 year ago • 0 comments

What is the expected feature or enhancement?

I was testing an ibm_cloud channel scenario where it's acceptable to submit a job without a specific backend. However, while testing that, my job was getting submitted with a backend which I didn't expect. This was because I was calling QiskitRuntimeService.backend(None) so nothing was filtered, multiple backends would come back, and it picks the first:

https://github.com/Qiskit/qiskit-ibm-runtime/blob/0.12.2/qiskit_ibm_runtime/qiskit_runtime_service.py#L792

@jyu00 pointed out that https://github.com/Qiskit/qiskit/blob/dbc3e328bcd2937c5be36f99dd55e05b2bb42b38/qiskit/providers/provider.py#L37-L57 will raise an error if a backend name isn't specified for filtering and there are multiple backends to choose from. If QiskitRuntimeService.backend() behaved the same way it would have been obvious to me what was wrong with my code.

Obviously there would be a behavior change here and so I suppose if this were implemented a deprecation or user warning would need to be emitted in the case that a backend name isn't specified and there are multiple backends available.

Acceptance criteria

Raise an error from QuantumRuntimeService.backend() if no backend name is specified and there are multiple backends available, rather than just return the first.

mriedem avatar Oct 13 '23 13:10 mriedem