Neutron Scattering Tutorial Function + AQC Function Template - #5510
Neutron Scattering Tutorial Function + AQC Function Template#5510henryzou50 wants to merge 26 commits into
Conversation
|
One or more of the following people are relevant to this code:
|
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Thanks @pdd23001, thanks for the changes and this is in great shape. The tutorial<->template contract is fully consistent, the numbers in the commentary all trace to actual outputs, and the physics framing checks out. Overall, looks good, but here are some suggestions I have:
Suggestions
Tutorial (simulate-neutron-scattering-with-a-serverless-workflow.ipynb)
- "Hamiltonian-agnostic" is inaccurate (cells 3 and 31). The function only accepts 1D nearest-neighbor Pauli Hamiltonians and rejects anything else with a
ServerlessError(see the guide's Function reference), so a reader who takes this claim to their own 2D or long-rangeSparsePauliOphits a validation error the tutorial said couldn't happen. We can change cell 31 to "the function accepts any 1D nearest-neighborSparsePauliOp, so a different chain Hamiltonian, initial state, or set of observables runs the same pipeline," and cell 3 to "drives other 1D dynamics experiments." - I believe "IBM Quantum Serverless" should be "Qiskit Serverless". Correct me if I am wrong here.
- Pick one display name for the template for consistency. Currently we have "AQC Dynamics Function" (cell 3), "AQC Dynamics Template" (cell 31; guide cells 2, 13), and "AQC Dynamics Function Template Github" (guide cell 28). "AQC Dynamics Template" is most used.
- Reconnect admonition vs. placeholder mismatch (cell 24 vs 25). The admonition says the reconnect cell "carries the job id from our own run," but cell 25 has
"<your job id>". Either include the real ID or reword to the guide's phrasing ("Paste your saved job ID over the placeholder..."). Also "Paste yours over there" is informal and should be changed; and "job id" -> "job ID" throughout both notebooks. - Appendix names the wrong noise mechanism (cell 30). "Longer chains mean deeper circuits, so noise accumulates", but all three appendix runs use the same 20 Trotter steps, and a nearest-neighbor chain's brickwork circuit gets wider with chain length, not deeper (each Trotter layer just holds more parallel gates, with no routing overhead on the heavy-hex line). What grows is the qubit and gate count. We can change to something like : "longer chains mean more qubits and gates per circuit, so errors accumulate, contrast fades, and spurious weight leaks outside the bounds." Also state the
gs_layersused for the 10- and 20-site runs, since the text claims "every other input held fixed." - "below"/"above" as page locations (house style; both notebooks -- tutorial cells 3, 4, 5, 8, 17, 20, 24, 30; guide cells 4, 13, 14, 15, 19, 24). Prefer "the following"/"preceding" per the style guide. (Mathematical "bounded below/above" in cell 3 is fine.)
Guide (function-template-aqc-trotter.ipynb)
- Cell 22 undersells what changes at scale: "Only the chain length, the number of Trotter steps, and the backend differ", the compression plan also differs (
[{4,1},{2,2}]->[{3,1},{3,2}]) and the simulator call passesaqc_options={"max_bond": 32}while the hardware call omits it. Add "and the compression plan," or make them identical. - Cell 10 (
serverless.upload(fn)) has no output. The sibling template guides both show theQiskitFunction(...)execute result for their upload cells. - Cell 7 blockquote ->
<Admonition type="note">, matching how notes are formatted elsewhere. While there: "[extras]are honored -- ... is what dragsquimb/jaxin here" -> "The[extras]syntax is honored:qiskit-addon-aqc-tensor[quimb-jax]is what installsquimbandjax.", and the fake-backend bullet is missing its period. - Cell 16 output schema shows integer dict keys (
"aqc_fidelities": {1: ...}) but real outputs have string keys after the JSON round-trip ({'1': 1.0, ...}in cell 21 and tutorial cells 16/27). We should have them be consistent - Cell 5: "This will allow you to locally instantiate..." -> drop the future tense, e.g. "With these credentials you can instantiate the serverless client locally...".
- Cell 28: "Github" -> "GitHub"
- Three small guide fixes:
- Cell 1: delete the empty markdown cell after the title.
- Cell 15, "Execution backends" table: the Credentials column is inconsistent -- the
statevectorandfakerows answer which credentials are needed ("Serverless account only"), but theruntimerow just says "Yes", which doesn't tell the reader what's needed beyond the Serverless account. Replace "Yes" with the parallel answer, e.g. "Serverless account + an instance with QPU access". (The prose right under the table already explains the simulator rows, so only theruntimecell needs fixing.) - Cell 16 code comments: "e.g." -> "for example" per house style (
# e.g. ["Z_0", "ZZ_0_1"]-># for example: ["Z_0", "ZZ_0_1"], and "non-fatal notices, e.g. a cotengrust fallback" -> "non-fatal notices; for example, a cotengrust fallback").
Minor changes
- Tutorial cell 26's status comment (
OPTIMIZING_FOR_HARDWARE -> ...) drops theQUEUED -> INITIALIZING -> RUNNING:prefix that guide cell 19 documents; matching the literal strings avoids confusing users comparing theirstatus()output. - "Segments" vs. "steps" (tutorial cells 19, 30): "3 + 2 = 5" and "6 one-layer plus 4 two-layer segments" count steps, not segments (there are 2 segments). Suggest "AQC-compressed steps".
- "Appendix: How the workflow scales" -> sentence case after the colon; last Requirements bullet (cell 4) is missing its period; "state prep" -> "state preparation" (guide cell 19).
Note one item I've already fixed on the branch: the tutorial was the only notebook in docs/tutorials/ missing the hours/qpuSeconds usage metadata, so I pushed a commit adding "hours": 4, "qpuSeconds": 1080 (from the notebook's own ~4-hour wall-clock and 18-minute QPU estimate), let me know if those values should be tuned.
Co-authored-by: abbycross <across@us.ibm.com>
Co-authored-by: abbycross <across@us.ibm.com>
Co-authored-by: abbycross <across@us.ibm.com>
…dware Result cells now print the expectation-value array shape with its axis order, the first and last rows, and the 2-qubit depth saved by AQC, instead of only labels, times, and fidelities. The hardware example passes explicit estimator options (100 randomizations at 200 shots) rather than inheriting the 1000-randomization default, which submits ~11,000 circuit instances and can exceed a device's control-system instruction memory (error 6073). The section now explains the tradeoff and links Job limits and TwirlingOptions.
Captures the results for both examples: expectation-value shape and rows, AQC fidelities, the 2-qubit depth comparison, and the QPU time from the hardware run.
Tutorial: apply the remaining review suggestions, correct the claim that the function is Hamiltonian-agnostic (it accepts 1D nearest-neighbor Pauli Hamiltonians only), trim the appendix to the figures and a caption noting the parameters are shared across sizes and can be tuned, and standardize on "AQC Dynamics Template" as the display name. Guide: convert the dependency note to an Admonition, correct the output schema to the string dict keys the JSON round-trip actually produces, name the credentials needed for the runtime backend, mirror aqc_options across the simulator and hardware calls, and drop the future tense in the authentication section. Both: "job id" -> "job ID", replace "above"/"below" as page references with "preceding"/"following" per the style guide, and fix "e.g.", stray naming, and punctuation nits.
…n step The PRE/FUNCTION/POST diagram was ASCII art inside a code fence, so HTML rendered a diagram as source code. Both notebooks now use a three-column table, one column per stage, which also lets the math render instead of sitting as plain text. Workflow step 4 dropped the italics on "is" and states the point directly: the per-site magnetization is exactly the retarded Green's function, so no conversion is needed before the Fourier transform.
|
Hey @henryzou50 fork branch is ready for a fast-forward sync: pdd23001:aqc-trotter-neutron-scattering @ 19b10bb That's five commits sitting on top of ef040b4, so it should be a plain Thanks for committing @abbycross guide suggestions through the UI. Please don't do I've done all of your suggestions except two, which I think are better left as
Both of Abby's discussion threads are closed in these commits too — the italics We can keep your time metadata values. Only thing left on my side is the usage estimate in the guide but the others like hamiltonian simulation and chemistry did not have it so I am not sure if we need to do that. Please could you confirm once? |
|
@pdd23001 Synced and pushed, hanks for the clean handoff. A few notes:
I'll resolve Abby's threads now since they're all addressed at this tip. Overall, looks good to me now, and thanks @abbycross for the thorough pass! |
abbycross
left a comment
There was a problem hiding this comment.
Thanks for these additions!
|
A quick summary of the latest commit (ee95acc), which is a small cleanup pass with two fixes worth noting:
|
Adds the input to the Function reference table and the circuits key to the output dict, noting it is present only when the flag is set and that circuits[i] corresponds to times[i + 1]. Depends on qiskit-community/qiskit-function-templates#43 — do not merge this commit before that one. Until it lands, return_circuits is not an input on the template that this guide tells readers to download, and passing it raises a ServerlessError (code 4615) because the input model forbids unknown fields.
|
Pushed The commit documents For context, |
Summary
Adds the neutron scattering tutorial (AQC + Trotter dynamics Serverless workflow) and the AQC function template guide. All content authored by @pdd23001, see #5501 for the full original PR description and review discussion.
Why this PR exists
#5501 was opened from a fork, so CI could not deploy a docs preview (the preview workflow needs push access to
gh-pages, which fork PRs don't have). I've pushed the same branch (same commits, tipdb3d4cd) into this repo so we get a shareable preview link and canreview the rendered pages.This PR supersedes #5501, which I'll close, and review will continue here. @pdd23001 will finish the remaining work on this PR (hardware example outputs for the template notebook are still pending; see the original description).