Add Julia tutorial for simulating time evolution of the Ising model#5254
Add Julia tutorial for simulating time evolution of the Ising model#5254haimeng-zhang wants to merge 16 commits into
Conversation
|
Thanks for contributing to Qiskit documentation! Before your PR can be merged, it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. Thanks! 🙌 |
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Before I forget ... the runtime client has a pending rename, which will be complete once JuliaRegistries/General#158556 merges. |
| @@ -0,0 +1,10 @@ | |||
| [deps] | |||
There was a problem hiding this comment.
Is it possible to remove both the toml files? These files won't render on the site and readers won't be able to see their contents. I would say if it's not critical to have the exact package versions installed you could just list these as packages the user should install. If it is, I would add the contents of Project.toml into the notebook through an accordion object.
There was a problem hiding this comment.
Another option that would make this easier to pass through our CI checks would be to convert this file to markdown. This would bypass our notebook/lint checker which, for this particular case, I think is fine to do.
There was a problem hiding this comment.
I am doing the conversion locally and will upload as soon as I've compared the two versions to make sure they are identical. I will also move the file outside of the /time-evolution/ directory (right now the URL would be /docs/tutorials/time-evolution/time-evolution)
There was a problem hiding this comment.
Haimeng messaged me yesterday about the linter. Bumping squeaky from 0.7.0 to 0.7.1 in these two places should fix it:
There was a problem hiding this comment.
Hm, I updated squeaky (one was already done) but I'm still getting errors. Should we convert to markdown after all, @kaelynj?
There was a problem hiding this comment.
I think we should still. My understanding is that ruff doesn't support Julia and we would have to set up a new linting pipeline in CI for this notebook.
Eventually we should find a solution for if we start adding more content in different languages, but for now I think it's fine to convert this to markdown. (Or have ruff ignore the file).
There was a problem hiding this comment.
Should we convert to markdown after all [...] ?
Is the idea to convert it to markdown just to satisfy the linter? Might it make more sense to add this notebook to the linters' ignore list? Keeping it in notebook form has a few advantages that I can think of, namely that users could download it and execute, and also that we could then ourselves download it and manually execute it at a later date, to ensure that the instructions still work with the latest version of Qiskit.jl. Sure, manual testing is not as reliable as automated testing, but keeping it as a notebook still provides a path to testing it easily.
There was a problem hiding this comment.
@abbycross you still have the bad metadata from before the squeaky upgrade, you need to revert 9eba3cf then re-run ./fix
There was a problem hiding this comment.
Should we convert to markdown after all [...] ?
Is the idea to convert it to markdown just to satisfy the linter? Might it make more sense to add this notebook to the linters' ignore list? Keeping it in notebook form has a few advantages that I can think of, namely that users could download it and execute, and also that we could then ourselves download it and manually execute it at a later date, to ensure that the instructions still work with the latest version of Qiskit.jl. Sure, manual testing is not as reliable as automated testing, but keeping it as a notebook still provides a path to testing it easily.
Yeah it's mostly to satisfy the linter. I'd be fine with just adding it to the ignore list and keeping it as a notebook.
@haimeng-zhang you should be able to do this by adding this line to the docs/ruff.toml file
extend-exclude = ['tutorials/time-evolution/time-evolution.ipynb
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "using Qiskit\n", |
There was a problem hiding this comment.
After some discussion with other Qiskit developers, I think it will be better to use the idiomatic Julia API to construct a circuit, described at https://github.com/Qiskit/Qiskit.jl#idiomatic-julia-interface-qiskitoperations
| "using Qiskit\n", | |
| "using Qiskit\n", | |
| "using Qiskit.Operations\n", |
| "\n", | ||
| " # Neel state initialization\n", | ||
| " for i in 1:2:n\n", | ||
| " qc.x(i)\n", |
There was a problem hiding this comment.
Here's an example of what a corresponding change would look like. Throughout, all mutating operations starting with qc. should be replaced with the corresponding method ending with a !.
| " qc.x(i)\n", | |
| " x!(qc, i)\n", |
Summary
Julia is a dynamic language designed for high-performance numerical and scientific computing, making it a natural fit for quantum simulation workflows. The tutorial shows how Julia is used for both classical pre- and post-processing (e.g., building Hamiltonians, running ODE solvers, computing expectation values) and for orchestrating quantum hardware jobs, eliminating the need to switch between languages or environments. The example used in this tutorial is simulating time evolution of the transverse-field Ising model.
To interface with IBM Quantum hardware from Julia, this tutorial uses two packages from the Qiskit ecosystem:
Qiskit.jlwraps the Qiskit C API and provides circuit construction and transpilation functionality in Julia;QiskitIBMRuntime.jlconnects to IBM Quantum hardware through the Qiskit IBM Runtime service, enabling job submission and result retrieval directly from Julia.Files
The PR adds the following files:
docs/tutorials/time-evolution/time-evolution.ipynbdocs/tutorials/time-evolution/Project.tomlanddocs/tutorials/time-evolution/Manifest.toml, which are needed to set up the Julia environment and install the dependencies to run the notebook.