Skip to content

Commit

Permalink
MPF Intro and getting started (#2367)
Browse files Browse the repository at this point in the history
Closes #2109 and closes #2111

---------

Co-authored-by: abbycross <[email protected]>
  • Loading branch information
kaelynj and abbycross authored Dec 10, 2024
1 parent f0d3a69 commit d08bff6
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 2 deletions.
13 changes: 13 additions & 0 deletions docs/guides/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,19 @@
"url": "/guides/qiskit-addons-obp-get-started"
}
]
},
{
"title": "Multi-product formulas (MPF)",
"children":[
{
"title": "MPF addon overview",
"url": "/guides/qiskit-addons-mpf"
},
{
"title": "Get started with MPFs",
"url": "/guides/qiskit-addons-mpf-get-started"
}
]
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion docs/guides/map-problem-to-circuits.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ The output of this step in a Qiskit pattern is normally a collection of circuits
* [OpenQASM 2 and the Qiskit SDK](./interoperate-qiskit-qasm2)
* [OpenQASM 3 and the Qiskit SDK](./interoperate-qiskit-qasm3)
* [OpenQASM 3 feature table](./qasm-feature-table)
* [OpenQASM 3.x live specification](https://openqasm.com/)
* [OpenQASM 3.x live specification](https://openqasm.com/)
* [MPF Qiskit Addon](/guides/qiskit-addons-mpf)
* [Get started with MPF](/guides/qiskit-addons-mpf-get-started)
371 changes: 371 additions & 0 deletions docs/guides/qiskit-addons-mpf-get-started.ipynb

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions docs/guides/qiskit-addons-mpf.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "67e54fee-28ed-4ebe-bcb8-715aa06721a1",
"metadata": {},
"source": [
"# Multi-product formulas (MPF)\n",
"\n",
"Multi-product formulas (MPF) can be used to more accurately simulate the dynamics of a quantum system, at the cost of increased circuit executions. This is a post-processing technique that mitigates the error of expectation values for time-evolved states.\n",
"\n",
"Classical computing is used to solve a system of linear equations that provides coefficients to a weighted combination of several circuit executions. Using this weighted combination can reduce the error associated with simulating time evolution, given a good selection of Trotter steps. The MPF tool will ingest a selection of data --- including the number of Trotter steps and the order of the Trotter approximation --- to prepare and solve (or approximate the solution of) the associated system of linear equations, which you can then use to post-process expectation value measurements of a time-evolved state."
]
},
{
"cell_type": "markdown",
"id": "1a2f529c-4983-447d-9923-a423b34e7215",
"metadata": {},
"source": [
"## Install the MPF package\n",
"\n",
"There are two ways to install the MPF package: via PyPI and building from source. It is recommended to install in a [virtual environment](https://docs.python.org/3.10/tutorial/venv.html) to ensure separation between package dependencies.\n",
"\n",
"### Install from PyPI\n",
"\n",
"The most straightforward way to install the `qiskit-addon-mpf` package is via PyPI.\n",
"```bash\n",
"pip install qiskit-addon-mpf\n",
"```\n",
"\n",
"### Build from source\n",
"Users who wish to develop in the repository or who want to install it manually may do so by first cloning the repository:\n",
"```bash\n",
"git clone [email protected]:Qiskit/qiskit-addon-mpf.git\n",
"```\n",
"\n",
"and install the package via `pip`. The repository also contains a number of optional dependencies that enable certain features.\n",
"\n",
"Adjust the options to suit your needs.\n",
"```bash\n",
"pip install tox notebook -e '.[notebook-dependencies,dev]'\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "7ac19afa-954c-4c1d-b3b1-7871db85e8b4",
"metadata": {},
"source": [
"## Theoretical background\n",
"\n",
"MPFs can reduce the Trotter approximation error associated with simulating the dynamics of quantum systems through a weighted combination of several circuit executions. This weighted sum is defined as:\n",
"\n",
"$$ \\mu(t) = \\sum_j x_j\\rho_j^{k_j}\\left(\\frac{t}{k_j}\\right) + \\text{some remaining Trotter error}, $$\n",
"\n",
"where $x_j$ are the weighting coefficients, $\\rho_j^{k_j}$ is the density matrix that corresponds to the pure state obtained by evolving the initial state via a product formula $S^{k_j}$ approximating the time-evolution operator using $k_j$ Trotter steps, and $j$ indexes each product formula used in the sum.\n",
"\n",
"![Several circuits with a varying number of Trotter steps are used to compute the target observable](/images/guides/qiskit-addons/mpf-diagram.png)\n",
"\n",
"Generally, however, the goal of simulating quantum dynamics is to measure some observable $\\mathcal{O}(t)$, which is a function of time. When using MPFs, multiple circuits -- each using $k_j$ Trotter steps -- are executed to obtain several measurements of the target observable $\\mathcal{O}_{k_j}(t)$. The measurement of the target observable is then obtained by computing:\n",
"\n",
"$$ \\langle \\mathcal{O}(t) \\rangle = \\sum_j x_j(t) \\langle \\mathcal{O}_{k_j}(t) \\rangle. $$\n",
"\n",
"In essence, you can reduce the overall Trotter error by approximating the time-evolution operator using several product formulas with a variable number of Trotter steps instead of a single product formula. You construct a circuit for each term in the weighted sum, which evolves the system according to each of the $k_j$ number of Trotter steps. Each circuit is then executed separately on a QPU to reconstruct the results in a post-processing step. The utility of this technique can be viewed from two perspectives:\n",
"1. For a fixed number of Trotter steps that you execute, you can obtain results with a Trotter error that is smaller in total.\n",
"2. For a number of Trotter steps that result in deep circuits, you can use MPF to find several shorter-depth circuits to run, which results in a similar Trotter approximation error.\n",
"\n",
"\n",
"\n",
"## Determine MPF coefficients\n",
"\n",
"The core functionality of the `qiskit-addon-mpf` package lies in determining the MPF coefficients $x_j(t)$ (which may be time-dependent). The process to obtain each $x_j(t)$ involves solving a system of linear equations $Ax=b$ where $x$ is the vector of coefficients to be determined, $A$ is a matrix that depends on each of the $k_j$ and the product formula used $S$ (as in, the approximation order and number of Trotter steps), and $b$ is a vector of constraints. This system of equations can be solved either exactly or with an approximate model that minimizes the 1-norm of the coefficients. Additionally, the choice for each $k_j$ is a heuristic process, but can be bounded by the following constraints:\n",
"\n",
"1. The **largest** $k_j$ value is bounded by the highest depth of circuit that can be reliably executed\n",
"2. The **smallest** $k_j$ should satisfy $dt = t/k_j < 1$ since that is where the Trotter error is most well behaved\n",
"3. None of the coefficients $x_j$ should be close to $0$ since this would imply they don't contribute much to the MPF\n",
"4. Similarly, the coefficient associated with the largest $k_j$ value should not dominate, since this implies that you are using a single product formula\n",
"5. Lastly, the norm of the coefficients $x_j$ obtained should be small, as this indicates a well-conditioned MPF [1](#references)\n",
"\n",
"## Next steps\n",
"\n",
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
" - Read the page on [getting started with MPF](/guides/qiskit-addons-mpf-get-started).\n",
"</Admonition>\n",
"\n",
"## References\n",
"\n",
"1. A. Carrera Vazquez, D. J. Egger, D. Ochsner, and S. Wörner, [\"Well-conditioned multi-product formulas for hardware-friendly Hamiltonian simulation\"](https://quantum-journal.org/papers/q-2023-07-25-1067/), Quantum 7, 1067 (2023).\n",
"2. S. Zhuk, N. Robertson, and S. Bravyi, [\"Trotter error bounds and dynamic multi-product formulas for Hamiltonian simulation\"](https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.6.033309), Phys. Rev. Research 6, 033309 (2024).\n",
"3. N. Robertson, et al. [\"Tensor Network enhanced Dynamic Multiproduct Formulas\"](https://arxiv.org/abs/2407.17405v2), arXiv:2407.17405v2 [quant-ph]."
]
}
],
"metadata": {
"description": "Overview page of the qiskit addon that generates multi-product formulas (MPF)",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3"
},
"title": "Multi-product formulas (MPF)"
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions qiskit_bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,7 @@ notifications:
- "@kaelynj"
"docs/guides/qiskit-addons-aqc-get-started":
- "@kaelynj"
"docs/guides/qiskit-addons-mpf":
- "@kaelynj"
"docs/guides/qiskit-addons-mpf-get-started":
- "@kaelynj"
3 changes: 3 additions & 0 deletions scripts/config/cspell/dictionaries/people.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Nannicini
Nesterov’s
Neumann
Niall
Ochsner
Ourense
Paik
Paulis
Expand Down Expand Up @@ -101,5 +102,7 @@ Viudes
Watrous
Weyl
Woerner
Wörner
Yufei
Zhuk
Zoufal
3 changes: 2 additions & 1 deletion scripts/config/notebook-testing.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ notebooks = [
"docs/guides/plot-quantum-states.ipynb",
"docs/guides/pulse.ipynb",
"docs/guides/qiskit-addons-aqc-get-started.ipynb",
"docs/guides/qiskit-addons-mpf-get-started.ipynb",
"docs/guides/represent-quantum-computers.ipynb",
"docs/guides/save-circuits.ipynb",
"docs/guides/save-jobs.ipynb",
Expand Down Expand Up @@ -79,6 +80,6 @@ notebooks = [
"docs/guides/q-ctrl-performance-management.ipynb",
"docs/guides/qedma-qesem.ipynb",
"docs/guides/qiskit-addons-sqd-get-started.ipynb",
"docs/guides/qiskit-addons-mpf.ipynb",
"docs/guides/qunasys-quri-chemistry.ipynb",
]

2 changes: 2 additions & 0 deletions scripts/nb-tester/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ qiskit-serverless~=0.18.0
qiskit-ibm-catalog~=0.2
qiskit-addon-sqd~=0.8.1
qiskit-addon-utils~=0.1.0
qiskit-addon-mpf~=0.2.0
scipy~=1.14.1
qiskit-addon-aqc-tensor~=0.1.2
qiskit-addon-obp~=0.1.0
scipy~=1.14.1
Expand Down

0 comments on commit d08bff6

Please sign in to comment.