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

It should be easier to get a backend instance from a Batch or Session

Open nonhermitian opened this issue 1 year ago • 3 comments

What is the expected feature or enhancement? It appears there is no way to get a backend instance from a Batch or Session. But they do have service instances. So if I want to get the backend associated with the Batch or Session I must write:

backend = batch.service.backend(batch.backend())

There should be a better way then this.

Acceptance criteria It is easier for an user to get a backend instance from a Batch or Session.

nonhermitian avatar Sep 18 '24 19:09 nonhermitian

If I go down to the sampler or estimator level it gets messier:

backend = sampler.mode.service.backend(sampler.mode.backend())

nonhermitian avatar Sep 18 '24 19:09 nonhermitian

Given passing a backend name to Session/Batch constructor is deprecated, we should change session.backend() to return a backend instance. How to make this transition backward compatible is going to be tricky though.

jyu00 avatar Sep 18 '24 22:09 jyu00

Yeah it's a bit unfortunate session.backend() returns a string. We could add a backend_name() method, go through a deprecation period, and then change backend() to return the instance.

For now, to get the backend instance you could just do session._backend. For the primitives: sampler.backend() or estimator.backend()

kt474 avatar Nov 19 '24 20:11 kt474