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

Give session/batch cm higher precedence than backend #1727

Open
1 of 3 tasks
jyu00 opened this issue Jun 3, 2024 · 0 comments · May be fixed by #2027
Open
1 of 3 tasks

Give session/batch cm higher precedence than backend #1727

jyu00 opened this issue Jun 3, 2024 · 0 comments · May be fixed by #2027
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jyu00
Copy link
Collaborator

jyu00 commented Jun 3, 2024

What is the expected feature or enhancement?

Today if someone does

sampler1 = SamplerV2(backend=backend)

with Session(backend=backend):
    sampler2 = SamplerV2(backend=backend)
    sampler1.run(...)
    sampler2.run(...)

Both sampler1.run() and sampler2.run() will actually run in job mode, not session, even though session mode is more likely what they want, given .run() is invoked under the Session context manager. While this is technically a user error, it's not intuitive that specifying the backend keyword would negate the Session context (although it'd help when the backend parameter is dropped in favor of mode).

We should make it so that if run() is called inside a Session or Batch context, session/batch is used. Although this is a breaking change so we'd need to do some warning first.

Acceptance criteria

  • Issue a deprecation warning if a job inside a session/batch context will actually run in job mode. The warning message should say the job will run in job mode, and the behavior will change to session/batch mode in the near future.
  • After the deprecation period, make the job to actually run in session/batch mode if it's inside a session/batch context
  • If a backend is specified for both the primitive and session/batch, raises an error, e.g.
    with Session(backend=bar):
        sampler = SamplerV2(backend=foo)
        sampler.run()  # <-- this should raise an error since we don't know if `foo` or `bar` should be used as the backend
@jyu00 jyu00 added the enhancement New feature or request label Jun 3, 2024
@kt474 kt474 self-assigned this Jul 16, 2024
@kt474 kt474 added this to the 0.26.0 milestone Jul 23, 2024
@kt474 kt474 linked a pull request Nov 14, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants