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

Test the safe parts of notebooks that run on hardware in every CI run #1173

Closed
Eric-Arellano opened this issue Apr 12, 2024 · 3 comments
Closed

Comments

@Eric-Arellano
Copy link
Collaborator

We cannot easily test notebooks that run on hardware in CI for every PR because a) there is often a queue and b) it costs actual resources. So, we currently skip those notebooks in PR runs:

NOTEBOOKS_THAT_SUBMIT_JOBS = [
"docs/start/hello-world.ipynb",
"docs/analyze/saving-and-retrieving.ipynb",
"tutorials/build-repitition-codes/notebook.ipynb",
"tutorials/chsh-inequality/notebook.ipynb",
"tutorials/grovers-algorithm/notebook.ipynb",
"tutorials/quantum-approximate-optimization-algorithm/notebook.ipynb",
"tutorials/repeat-until-success/notebook.ipynb",
"tutorials/submitting-transpiled-circuits/notebook.ipynb",
"tutorials/variational-quantum-eigensolver/notebook.ipynb",
]

We then run those notebooks every two weeks in a cron job with GH Actions.

However, we can actually run part of the notebooks safely! We can run every code cell up until the point when we call Estimator.run() and Sampler.run(), or do some other slow thing with Qiskit Runtime. All the code up to that point is safe to run.

We can add a Jupyter notebook tag like submits-job to the code cells that use hardware. Then teach nb-tester to only run up to that code block, but stop there. We wouldn't run any subsequent code blocks since they may depend on the tagged code block.

github-merge-queue bot pushed a commit that referenced this issue May 2, 2024
This uses the approach discussed in #1174 to test notebooks that submit
jobs to IBM Quantum.

The script behaviour has changed a bit:
* We now have a list of `notebooks_no_mock`, these could include
notebooks with large circuits or that demonstrate features not available
on the fake backend. Future work could partially test these using the
approach in
[#1173](#1173).
* By default, it runs all notebooks except `notebooks_no_mock`, with the
patched package.
* `--submit-jobs` will run **all** notebooks, without the patched
package.
* `--only-unmockable` will run only `notebooks_no_mock`, without the
patched package.

The following notebooks do **not** work with this patch, but some of
them might not have worked anyway.
* `tutorials/variational-quantum-eigensolver/notebook.ipynb`
* `tutorials/submitting-transpiled-circuits/notebook.ipynb`
* `tutorials/build-repitition-codes/notebook.ipynb`

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
frankharkins added a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
This uses the approach discussed in Qiskit#1174 to test notebooks that submit
jobs to IBM Quantum.

The script behaviour has changed a bit:
* We now have a list of `notebooks_no_mock`, these could include
notebooks with large circuits or that demonstrate features not available
on the fake backend. Future work could partially test these using the
approach in
[Qiskit#1173](Qiskit#1173).
* By default, it runs all notebooks except `notebooks_no_mock`, with the
patched package.
* `--submit-jobs` will run **all** notebooks, without the patched
package.
* `--only-unmockable` will run only `notebooks_no_mock`, without the
patched package.

The following notebooks do **not** work with this patch, but some of
them might not have worked anyway.
* `tutorials/variational-quantum-eigensolver/notebook.ipynb`
* `tutorials/submitting-transpiled-circuits/notebook.ipynb`
* `tutorials/build-repitition-codes/notebook.ipynb`

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
@Eric-Arellano
Copy link
Collaborator Author

@frankharkins think we should close this as not worth the complexity? In hello world, we would only be able to test about 25% of the notebook with this strategy, which isn't that big of a win.

Removing tutorials changed the value, imo. This is what would be impacted:

notebooks_no_mock = [
"docs/guides/hello-world.ipynb",
"docs/guides/serverless-first-program.ipynb",
"docs/guides/serverless-manage-resources.ipynb",
"docs/guides/serverless-run-first-workload.ipynb",
"docs/guides/noise-learning.ipynb"
]

I lean towards closing this as not worth it. The cron job does a good job as is.

@frankharkins
Copy link
Member

Yeah I agree

@johannesgreiner
Copy link
Contributor

an idea is to have the notebooks modified such that our test_* backends will be used for pipeline testing wherever possible

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

No branches or pull requests

3 participants