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

QiskitRuntimeService.backends fails when a backend has a bad configuration #1924

Open
wshanks opened this issue Sep 16, 2024 · 1 comment · May be fixed by #2048
Open

QiskitRuntimeService.backends fails when a backend has a bad configuration #1924

wshanks opened this issue Sep 16, 2024 · 1 comment · May be fixed by #2048
Assignees
Labels
bug Something isn't working
Milestone

Comments

@wshanks
Copy link
Collaborator

wshanks commented Sep 16, 2024

Describe the bug

Sometimes the runtime service has a backend with bad data. Currently, an exception trying to load a backend object is allowed to bubble up to the caller of QiskitRuntimeService.backends().

Steps to reproduce

This bug is likely tricky to reproduce in production without mocking. It comes up more often in other runtime service instances. When there is bad configuration data in the service, it can be triggered by running service.backends().

Expected behavior

I expect that the caller of QiskitRuntimeService.backends() expects to get back a list of good backends. If there are badly configured backends, they could be warned about but I would not expect them to cause an error.

Suggested solutions

At this point:

if backend := self._create_backend_obj(backend_name, instance=hgp):
backends.append(backend)

the self._create_backend_obj() call could be put into a try block to guard against exceptions.

Additional Information

For the case most recently encountered, the exception that propagated up was of the form:

qiskit_ibm_runtime.api.exceptions.RequestsApiError: '404 Client Error: Not Found for url: https://api.quantum.ibm.com/runtime/backends/<misspelled_backend>/configuration

where <misspelled_backend> was the name of a private backend that had been added to the database somehow but misspelled and without any configuration data.

Another suggestion -- personally, I use backends to get a list of backends that the account I am using has access to. I really just need the list of names and don't need all the backends loaded. Maybe there could be a QiskitRuntimeService.backend_names property. That would not have issues with loading bad backends (that would be delayed until trying to load a backend).

  • qiskit-ibm-runtime version: 0.29.0
  • Python version: 3.11
  • Operating system: RHEL 8
@wshanks wshanks added the bug Something isn't working label Sep 16, 2024
@kt474
Copy link
Member

kt474 commented Sep 17, 2024

Following up on a slack conversation:

We already have a try/except check for invalid backend configurations here. The API error that happened in this case only happened because of a misspelled backend name.

Adding another try/except in _create_backend_obj may be worthwhile but these types of data entry errors shouldn't happen in the first place.

@kt474 kt474 self-assigned this Nov 20, 2024
@kt474 kt474 linked a pull request Nov 20, 2024 that will close this issue
@kt474 kt474 added this to the 0.34.0 milestone Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants