Update tutorial template and details, remove serverless#5033
Update tutorial template and details, remove serverless#5033vrpascuzzi wants to merge 7 commits into
Conversation
This commit update the tutorial to use the latest template. Additionally, we add details about the training dataset and reference to further background for the inquisitive reader so as to not overwhelm the text with group theory. This addition is to address Qiskit#4929. Finally, we remove the bit on serverless for two primary reasons: 1. the workload is small and can be easily performed on a laptop, 2. serverless nodes appear to not have the necessary modules installed (e.g., pandas) It is suggested to include serverless in an SQD-type tutorial or standalone. Closes Qiskit#4929.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
One or more of the following people are relevant to this code:
|
|
|
henryzou50
left a comment
There was a problem hiding this comment.
@vrpascuzzi Thanks for porting this to the new tutorial template and great work so far! A few things to address before merging.
Structural
1. Restructure to match the tutorial template's small/large-scale layout
The template organizes tutorials around two top-level sections — ## Small-scale example and ## Large-scale example — with the four pattern steps nested under each as ### headings (e.g., ### Step 1: Map classical inputs to a quantum problem). This PR currently uses ## for the steps and has a single hardware example without that framing.
Could you restructure it to:
- Wrap the existing hardware example under
## Small-scale example(it's fine for the small-scale section to run on hardware rather than a simulator if that's the natural fit here), and demote the four steps from##to###. - Add a
## Large-scale examplesection for the large-scale hardware example or explain why a larger hardware run isn't included or is tricky to demonstrate here (e.g., kernel matrix construction scales as O(N²) circuits, hardware time/cost, fidelity at depth, etc.), so readers understand the scope is intentional and know what would change at scale.
This keeps the tutorial aligned with the template structure even though we're only shipping the small-scale run.
Code
2. Remove the named service credential
In Step 2:
service = QiskitRuntimeService(name="solutions_demo_premium")3. Fix job_tags format
In Step 3:
sampler.options.environment.job_tags = ["quantum-kernel-training-demo"]This doesn't match the convention used across the other tutorials. It should be the short TUT_* tag:
sampler.options.environment.job_tags = ["TUT_QKT"]4. !wget is not portable
In the Setup cell:
!wget https://raw.githubusercontent.com/qiskit-community/prototype-quantum-kernel-training/main/data/dataset_graph7.csv
wget is not installed by default on macOS (only curl is), so this cell will fail for any reader on Mac with zsh:1: command not found: wget. Consider either:
- Switching to
!curl -O <url>(works on macOS and Linux out of the box), or - Using Python's
urllib.request.urlretrieve(...)for full portability.
If we keep wget, we should at least add a note telling macOS readers to install it (brew install wget) or use curl instead.
5. qiskit-ibm-catalog is listed but never used
The Requirements section lists Qiskit IBM Catalog v0.14.0 or later, but I don't see qiskit_ibm_catalog imported or used anywhere in the notebook. Either remove it from Requirements, or add the missing usage.
Content / consistency issues
6. Stray paragraph in the Background that the tutorial doesn't actually deliver on
The Background ends with:
In this lesson we will examine the depths of pre-coded encoding circuits that use substantial entanglement and compare those to depths of circuits we code by hand. This is not to advocate for one method over another. You may find that pre-coded circuits are too deep, and that the entanglement in the custom-built circuit is insufficient to be useful. Again, these are shown only to enable your exploration.
The notebook never actually compares pre-coded vs. hand-coded encoding circuit depths. This paragraph appears to be left over from a different version and should be removed (or the comparison should be added).
7. Step 2 description references an "observable" that isn't produced
Step 2 says:
Output: Target circuit and observable, optimized for the selected QPU
But the step only produces a transpiled circuit; there's no "observable". Drop "and observable" so the I/O matches the code.
8. Step 3 references a commented-out alternative block that doesn't exist
Step 3 markdown says:
To run on
qiskitstatevector-based primitives, replace the block of code using Qiskit IBM® Runtime primitives with the commented block.
…but there is no commented block in the following code cell. Either add the statevector alternative as commented code, or remove this sentence.
|
@vrpascuzzi Also when you get the chance, can you sign the CLA? |
Structure
- Wrap existing pattern under `## Small-scale simulator example` using
`StatevectorSampler` from `qiskit.primitives`, demoting the four step
headings to `###` and renaming them to the template wording
("Map classical inputs to a quantum problem",
"Optimize problem for quantum hardware execution",
"Execute using Qiskit primitives",
"Post-process and return result in desired classical format").
- Add `## Large-scale hardware example` that reruns the same 7-qubit
instance on a real QPU, with an explanation of why we don't scale
further (O(N^2) kernel-matrix entries, depth growth from
`unitary_overlap`, fidelity at depth, total QPU time). Compress
Steps 1-4 into a single
- Reformat `## Next steps` with the
`<Admonition type="tip" title="Recommendations">` wrapper used across
recent tutorials.
Code
- Drop the named credential: `QiskitRuntimeService(name="solutions_demo_premium")`
-> `QiskitRuntimeServic
- Set `sampler.options.environment.job_tags = ["TUT_QKT"]` per the
TUT-XYZ tagging convent
- Replace `!wget` with `urllib.request.urlretrieve(...)` so setup works
on macOS without `brew install wget`.
Content
- Remove the stray Backgrd vs. hand-coded
encoding circuits (the comparison was never performed).
- Remove `Qiskit IBM Catalog v0.14.0 or later` from Requirements (unused).
- Drop "and observable" from the Step 2 Output description (only a
transpiled circuit is produced).
|
Applied the suggestions from the feedback i mentioned earlier and made a simulator example in the small scale example, and for the large-scale example, I used hardware but the same size for now. |
There was a problem hiding this comment.
Fixed the issues above, and LGTM! @abbycross and @nathanearnestnoble can you take a look at this once you get the chance?
|
I did a copyedit, and directly committed small fixes related to IBM Style, link paths, and a typo - hope that's ok. Looks like GitHub isn't recognizing @vrpascuzzi 's email so you'll need to sign the CLA. Thanks! |
|
Thanks for the review @abbycross! LGTM |
abbycross
left a comment
There was a problem hiding this comment.
Thanks! FYI @nathanearnestnoble
This commit update the tutorial to use the latest template.
Additionally, we add details about the training dataset and reference to further background for the inquisitive reader so as to not overwhelm the text with group theory. This addition is to address #4929.
Finally, we remove the bit on serverless for two primary reasons:
pandas)It is suggested to include serverless in an SQD-type tutorial or standalone.
Closes #4929.