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

Add nb-tester patch to only select open plan backends #2455

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/config/notebook-testing.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci = { timeout = 300 }
# For notebooks to be tested in CI "normally" (no mocking)
[groups.normal]
test-strategies.ci = {}
test-strategies.hardware = {}
test-strategies.hardware = { patch="qiskit-ibm-runtime-open" }
notebooks = [
"docs/guides/build-noise-models.ipynb",
"docs/guides/circuit-library.ipynb",
Expand Down Expand Up @@ -47,7 +47,7 @@ notebooks = [
# The following notebooks submit jobs that can be mocked with a simulator
[groups.mockable]
test-strategies.ci = { patch="qiskit-fake-provider", num_qubits=6 }
test-strategies.hardware = {}
test-strategies.hardware = { patch="qiskit-ibm-runtime-open" }
notebooks = [
"docs/guides/debug-qiskit-runtime-jobs.ipynb",
"docs/guides/primitive-input-output.ipynb",
Expand All @@ -57,7 +57,7 @@ notebooks = [
# A job is "too big" if a cell can't run in under 5 mins, or we run out of
# memory on a reasonable device.
[groups.cron-job-only]
test-strategies.hardware = {}
test-strategies.hardware = { patch="qiskit-ibm-runtime-open" }
notebooks = [
"docs/guides/get-started-with-primitives.ipynb",
"docs/guides/hello-world.ipynb",
Expand Down
10 changes: 10 additions & 0 deletions scripts/nb-tester/patches/qiskit-ibm-runtime-open
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Only select backends available on the open plan
from qiskit_ibm_runtime import QiskitRuntimeService

QiskitRuntimeService._original_least_busy = QiskitRuntimeService.least_busy

def patched_least_busy(self, *args, **kwargs):
open_backends = [b.name for b in self.backends(instance="ibm-q/open/main")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could parametrize the "instance" variable to make this patch more reusable

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I did consider that, but I couldn't think of a scenario where we'd want to select from a different instance. I'm gonna leave it as-is for now, but happy to add that feature whenever the need arises.

return self._original_least_busy(filters=lambda backend: backend.name in open_backends)

QiskitRuntimeService.least_busy = patched_least_busy
Loading