Skip to content

Allow setting qpu mode in device - #92

Open
david-pl wants to merge 2 commits into
mainfrom
david/91-qpu-mode
Open

Allow setting qpu mode in device#92
david-pl wants to merge 2 commits into
mainfrom
david/91-qpu-mode

Conversation

@david-pl

Copy link
Copy Markdown
Contributor

Closes #91.

Can now do

device = Device(context_name="my-context", qpu_mode="some-mode")

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/bloqade-core/pr-preview/pr-92/

Built to branch gh-pages at 2026-07-21 09:26 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

☂️ Code Coverage

current status: ✅

Overall Coverage

Statements Covered Coverage Threshold Status
1591 1489 94% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/bloqade/core/device/device.py 100% 🟢
src/bloqade/core/device/future.py 98% 🟢
src/bloqade/core/device/mixins.py 87% 🟢
src/bloqade/core/device/task.py 87% 🟢
TOTAL 93% 🟢

updated for commit: 8f9f1f6 by action🐍

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for explicitly setting a qpu_mode on Device (and downstream task/future objects) so callers can select a backend QPU mode without creating a separate qlam context per mode.

Changes:

  • Introduces qpu_mode: str | None on AuthMixin, making it available on Device, TaskABC, and Future.
  • Plumbs qpu_mode through task submission and future backend calls (create/get/cancel/results fetch).
  • Adds/updates tests and demo usage to validate and illustrate the new behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/bloqade/core/device/mixins.py Adds qpu_mode field to the shared auth/context mixin.
src/bloqade/core/device/device.py Passes qpu_mode from Device into all created task shapes.
src/bloqade/core/device/task.py Includes qpu_mode when creating tasks and attaches it to returned futures.
src/bloqade/core/device/future.py Passes qpu_mode through all backend API calls and preserves it in constructors/classmethods.
test/device/fixtures/remote.py Updates fake API clients to accept/record optional qpu_mode.
test/device/test_task.py Adds coverage that task submission forwards explicit qpu_mode.
test/device/test_future.py Adds coverage that futures preserve/forward explicit qpu_mode on backend calls.
test/device/test_device.py Adds coverage that Device propagates qpu_mode into all task builders.
demo/qasm_single_task_simpler_serialization.py Demonstrates setting qpu_mode on a device.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kylequera

Copy link
Copy Markdown

note here @david-pl / @tahoe-quera as i want to make sure this gets added in the right place. A qpu mode is not part of auth -- i see its added to "AuthMixin"? Auth is separate and unrelated to qpu mode. You authenticate first from the "context". Then you go to make a request to a qpu mode. You can make requests to any qpu mode on that machine with the same auth token, so the qpu_mode should be set somewhere on the request object i think. I am not sure if there is a separate type for that, but we may expose it already from qlam-core. I will have to check on this.

@david-pl

Copy link
Copy Markdown
Contributor Author

@kylequera thanks for checking in! It's somewhat separate from authentication, AuthMixin was just the convenient place to put it, as all classes that need the qpu_mode keyword already use it. But now the class name is no longer really accurate. I could just make it a separate mixin if that makes it clearer.

@kylequera

Copy link
Copy Markdown

@kylequera thanks for checking in! It's somewhat separate from authentication, AuthMixin was just the convenient place to put it, as all classes that need the qpu_mode keyword already use it. But now the class name is no longer really accurate. I could just make it a separate mixin if that makes it clearer.

Ok - follow up question. There may be a request from the aist team to allow ENV overrides of the configuration. We are planning to do something at the qlam-core layer, but i think we may need the ability to do that from bloqade as well to pass it down. We can follow up on this when looking into it. Just want to make sure we have the ability to pass different parts of the configuration through bloqade to qlam-core.

@david-pl

Copy link
Copy Markdown
Contributor Author

I see. Well, right now there's just the options of setting qpu-mode and context name, since those are the APIs qlam-core offers to set things.

I could split out a ConfigMixin which can then hold all future config toggles. Right now it would just allow setting qpu_mode and context_name. Does that make sense? I'm not sure what the config override will look like. Do you think this would be flexible enough?

that can be dry-run or submitted asynchronously.

Attributes:
qpu_mode (str | None): Explicit qlam QPU mode used by tasks created

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of passing a single qpu_mode in here, would it make sense to pass the full ConfigMixin for future proofing passing config around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable setting qpu-mode

4 participants