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

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

Open
nonhermitian opened this issue Sep 18, 2024 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@nonhermitian
Copy link
Contributor

nonhermitian commented Sep 18, 2024

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 nonhermitian added the enhancement New feature or request label Sep 18, 2024
@nonhermitian
Copy link
Contributor Author

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

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

@jyu00
Copy link
Collaborator

jyu00 commented Sep 18, 2024

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.

@kt474
Copy link
Member

kt474 commented Nov 19, 2024

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants