Skip to content

Commit

Permalink
Guides pages for OBP (#2248)
Browse files Browse the repository at this point in the history
Closes #2107 and closes #2108 

I'll include the files in the toc and satiate CI once #2148 is merged to
avoid dealing with conflicts.

---------

Co-authored-by: Caleb Johnson <[email protected]>
Co-authored-by: abbycross <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent b5dbc23 commit 8e335ea
Show file tree
Hide file tree
Showing 9 changed files with 610 additions and 1 deletion.
13 changes: 13 additions & 0 deletions docs/guides/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,19 @@
"url": "/guides/qiskit-addons-sqd-get-started"
}
]
},
{
"title": "Operator backpropagation (OBP)",
"children": [
{
"title": "OBP addon overview",
"url": "/guides/qiskit-addons-obp"
},
{
"title": "Getting started with OBP",
"url": "/guides/qiskit-addons-obp-get-started"
}
]
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion docs/guides/optimize-for-hardware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ can be run on IBM&reg; hardware using IBM Qiskit Runtime.
- [IBM Circuit function](/guides/ibm-circuit-function)
- [Algorithmiq Tensor-network error mitigation](/guides/algorithmiq-tem)
- [Q-CTRL Performance Management](/guides/q-ctrl-performance-management)
- [QEDMA QESEM](/guides/qedma-qesem)
- [QEDMA QESEM](/guides/qedma-qesem)

### Qiskit Addons
* [Operator Backpropagation (OBP)](./qiskit-addons-obp)
* [Getting started with OBP](./qiskit-addons-obp-get-started)
486 changes: 486 additions & 0 deletions docs/guides/qiskit-addons-obp-get-started.ipynb

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions docs/guides/qiskit-addons-obp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: Operator backpropagation (OBP)
description: Learn about the operator backpropagation addon to reduce the depth of quantum circuits
---

# Operator backpropagation (OBP)

Operator backpropagation (OBP) is a technique to reduce circuit depth by trimming operations from its end at the cost of more operator measurements. There are a number of ways in which operator backpropagation can be performed, and this package uses a method based on Clifford perturbation theory.

As one propagates an operator further through a circuit, the size of the observable to measure grows exponentially. This results in both a classical and quantum resource overhead. However, for some circuits, the resulting distribution of additional Pauli observables is more concentrated than the worst-case exponential scaling. This implies that some terms in an observable with small coefficients can be truncated to reduce the quantum overhead. The error incurred by doing so can be controlled to find a suitable tradeoff between precision and efficiency.

## Installation

You can install the OBP package in one of two ways: via PyPI or building from source. Consider installing these packages in a [virtual environment](https://docs.python.org/3.10/tutorial/venv.html) to ensure separation between package dependencies.

### Install from PyPI

The most straightforward way to install the `qiskit-addon-obp` package is via PyPI.

```bash
pip install qiskit-addon-obp
```

### Build from source

Users who wish to contribute to this package or who want to install it manually may do so by first cloning the repository:

```bash
git clone [email protected]:Qiskit/qiskit-addon-obp.git
```_
and install the package via `pip`. The repository also contains example notebooks. If you plan on developing in the repository, install the `dev` dependencies.
Adjust the options to suit your needs:
```bash
pip install tox notebook -e '.[notebook-dependencies, dev]'
```

## Theoretical background

When using the Estimator primitive, the output of a quantum workload is the estimation of one or more expectation values $\langle O \rangle$ with respect to some state prepared using a QPU. This section summarizes the procedure.

First, start by writing the expectation value measurement of an observable $O$ in terms of some initial state $|\psi\rangle$ and a quantum circuit $U_Q$:

$$ \langle O \rangle_{U|\psi\rangle} = \langle\psi | U^\dagger O U |\psi \rangle. $$

To distribute this problem across both classical and quantum resources, split the circuit $U$ into two subcircuits, $U_C$ and $U_Q$, classically simulate the circuit $U_C$, then execute the circuit $U_Q$ on quantum hardware and use the results of the classical simulation to reconstruct the measurement of the observable $O$.

![OBP diagram depicting splitting a circuit into two subcircuits, classically computing one of the subcircuits, then measuring the other circuit using quantum hardware](/images/guides/qiskit-addons/obp-diagram.png)


The subcircuit $U_C$ should be selected to be classically simulable and will compute the expectation value

$$ \langle O' \rangle \equiv U_C^\dagger O U_C, $$

which is the version of the initial operator $O$ evolved through the circuit $U_C$. Once $O'$ has been determined, the quantum workload is prepared wherein the state $|\psi\rangle$ is initiated, has the circuit $U_Q$ applied to it, and then measures the expectation value $O'$. You can show that this is equivalent to measuring $\langle O \rangle$ by writing:

$$ \langle \psi | U_Q^\dagger O' U_Q \psi \rangle = \langle \psi | U_Q^\dagger U_C^\dagger O U_CU_Q \psi \rangle = \langle\psi | U^\dagger O U |\psi \rangle = \langle O \rangle_{U|\psi\rangle}$$


Lastly, in order to measure the expectation value $\langle O' \rangle$, we must require it to be decomposable into a sum of Pauli strings

$$ O' = \sum_P c_P P, $$

where $c_P$ are real coefficients of the decomposition and $P$ is some Pauli string composed of $I$, $X$, $Y$, and $Z$ operators. This ensures that you can reconstruct the expectation value of $O$ by

$$ \langle \psi | U_Q^\dagger O' |\psi \rangle = \sum_P c_P \langle \psi | U_Q^\dagger P U_Q | \psi \rangle. $$


### Truncating terms

This scheme offers a tradeoff between the required circuit depth of $U_Q$, the number of circuit executions on quantum hardware, and the amount of classical computing resources needed to compute $O'$. In general, as you choose to backpropagate further through a circuit, the number of Pauli strings to measure as well as the error-mitigation overhead both grow exponentially (alongside the classical resources needed to simulate $U_C$).

Fortunately, the decomposition of $O'$ can often contain coefficients that are quite small and can be truncated from the final measurements used to reconstruct $O$ without incurring much error. The `qiskit-addon-obp` package possesses functionality to specify an error budget, which can automatically search for terms that can be truncated, to within some error tolerance.


### Clifford perturbation theory

Lastly, the `qiskit-addon-obp` package approaches operator backpropagation based on Clifford perturbation theory. This method has the benefit that the overhead incurred by backpropagating various gates scales with the non-Cliffordness of $U_C$ (i.e. how much of U C is comprised of non-Clifford instructions).

This approach to OBP begins by splitting the simulated circuit, $U_C$, into *slices*:

$$ U_C = \prod_{s=1}^S \mathcal{U}_s = \mathcal{U}_S...\mathcal{U}_2\mathcal{U}_1, $$

where $S$ represents the total number of slices and $\mathcal{U}_s$ denotes a single slice of the circuit $U_C$. Each of these slices are then analytically applied in sequence to measure the back propagated operator $O'$ and may or may not contribute to the overall size of the sum, depending on if the slice is a Clifford vs non-Clifford operation. If an [error budget](../api/qiskit-addon-obp/utils-truncating#setup_budget) is allocated, truncation will then occur between the application of each slice.



## Next steps

<Admonition type="tip" title="Recommendations">
- [Get started with OBP.](/guides/qiskit-addons-obp-get-started)
- Become familiar with the [error mitigation techniques](/guides/error-mitigation-and-suppression-techniques) available in Qiskit Runtime.
</Admonition>
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 @@ -147,6 +147,10 @@ notifications:
"docs/guides/processor-types":
- "`@lerongil`"
- "@abbycross"
"docs/guides/qiskit-addons-obp":
- "@kaelynj"
"docs/guides/qiskit-addons-obp-get-started":
- "@kaelynj"
"docs/guides/qiskit-code-assistant":
- "cbjuan"
- "@abbycross"
Expand Down
1 change: 1 addition & 0 deletions scripts/config/notebook-testing.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ notebooks_normal_test = [
"docs/guides/serverless-first-program.ipynb",
"docs/guides/serverless-run-first-workload.ipynb",
"docs/guides/specify-observables-pauli.ipynb",
"docs/guides/qiskit-addons-obp-get-started.ipynb",
]

# Don't test the following notebooks (this section can include glob patterns)
Expand Down
4 changes: 4 additions & 0 deletions scripts/js/commands/checkPatternsIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const ALLOWLIST_MISSING_FROM_INDEX: Set<string> = new Set([
"/guides/qiskit-code-assistant-vscode",
"/guides/addons",
"/guides/addons/qiskit-addons-sqd-get-started",
"/guides/qiskit-addons-obp",
"/guides/qiskit-addons-obp-get-started",
]);

// URLs that show up in the INDEX_PAGES, but are not in the left ToC under
Expand All @@ -38,6 +40,8 @@ const ALLOWLIST_MISSING_FROM_TOC: Set<string> = new Set([
"/guides/q-ctrl-optimization-solver",
"/guides/qunasys-quri-chemistry",
"/guides/circuit-library",
"/guides/qiskit-addons-obp",
"/guides/qiskit-addons-obp-get-started",
]);

const INDEX_PAGES = [
Expand Down
2 changes: 2 additions & 0 deletions scripts/nb-tester/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ qiskit-ibm-runtime~=0.33.2
qiskit-serverless~=0.17.1
qiskit-ibm-catalog~=0.1
qiskit-addon-sqd~=0.7.0
qiskit-addon-utils~=0.1.0
qiskit-addon-obp~=0.1.0
pyscf~=2.7.0

0 comments on commit 8e335ea

Please sign in to comment.