60 lines
5.8 KiB
Plaintext
60 lines
5.8 KiB
Plaintext
---
|
||
title: qiskit_addon_obp (v0.1)
|
||
description: API reference for qiskit_addon_obp in qiskit-addon-obp v0.1
|
||
in_page_toc_min_heading_level: 2
|
||
python_api_type: module
|
||
python_api_name: qiskit_addon_obp
|
||
---
|
||
|
||
<span id="module-qiskit_addon_obp" />
|
||
|
||
<span id="operator-backpropagation-qiskit-addon-obp" />
|
||
|
||
# Operator backpropagation
|
||
|
||
`qiskit_addon_obp`
|
||
|
||
Main operator backpropagation functionality.
|
||
|
||
### backpropagate
|
||
|
||
<Function id="qiskit_addon_obp.backpropagate" github="https://github.com/Qiskit/qiskit-addon-obp/tree/stable/0.1/qiskit_addon_obp/backpropagation.py#L47-L288" signature="backpropagate(observables, slices, *, truncation_error_budget=None, operator_budget=None, max_seconds=None)">
|
||
Backpropagate slices of quantum circuit operations onto the provided observables.
|
||
|
||
This function takes a (list of) observable(s) and backpropagates the provided quantum circuit slices **in reverse order** onto the observable(s) until one of the stopping criteria is reached.
|
||
|
||
The stopping criteria are values which constrain how large the observable may grow during backpropagation. These may be specified via the `operator_budget` optional argument. Refer to the [`OperatorBudget`](utils-simplify#operatorbudget "qiskit_addon_obp.utils.simplify.OperatorBudget") class for more details.
|
||
|
||
During backpropagation, users may truncate low-weight terms from the output observables, potentially reducing the number of experiments needed to run on the QPU. Truncating observable terms results in expectation value error proportional to the weights of the truncated terms. Users may specify how aggressively to truncate by providing a [`TruncationErrorBudget`](utils-truncating#truncationerrorbudget "qiskit_addon_obp.utils.truncating.TruncationErrorBudget") to the `truncation_error_budget` argument. Refer to the [`setup_budget()`](utils-truncating#setup_budget "qiskit_addon_obp.utils.truncating.setup_budget") documentation for more details.
|
||
|
||
<Admonition title="Warning" type="caution">
|
||
The `max_seconds` argument is not available on Windows!
|
||
</Admonition>
|
||
|
||
**Parameters**
|
||
|
||
* **observables** ([*SparsePauliOp*](/api/qiskit/qiskit.quantum_info.SparsePauliOp "(in Qiskit v1.3)") *|*[*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")*\[*[*SparsePauliOp*](/api/qiskit/qiskit.quantum_info.SparsePauliOp "(in Qiskit v1.3)")*]*) – The observable(s) onto which the circuit is backpropagated.
|
||
* **slices** ([*Sequence*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.13)")*\[*[*QuantumCircuit*](/api/qiskit/qiskit.circuit.QuantumCircuit "(in Qiskit v1.3)")*]*) – A sequence of `QuantumCircuit` objects representing a single circuit which has been separated into partitions spanning all qubits. **These “slices” will be backpropagated in reverse order.** Each slice must span all qubits. One may use the tools provided in [`qiskit_addon_utils.slicing`](https://qiskit.github.io/qiskit-addon-utils/apidocs/qiskit_addon_utils.slicing.html#module-qiskit_addon_utils.slicing "(in Qiskit addon utilities)") to slice a single [`QuantumCircuit`](/api/qiskit/qiskit.circuit.QuantumCircuit "(in Qiskit v1.3)").
|
||
* **truncation\_error\_budget** ([*TruncationErrorBudget*](utils-truncating#truncationerrorbudget "qiskit_addon_obp.utils.truncating.TruncationErrorBudget") *| None*) – The error budget used for truncating Pauli terms. Refer to the [how-to guide](https://qiskit.github.io/qiskit-addon-obp/how_tos/truncate_operator_terms.html) for a detailed discussion on truncating terms from the output operator and bounding the incurred error.
|
||
* **operator\_budget** ([*OperatorBudget*](utils-simplify#operatorbudget "qiskit_addon_obp.utils.simplify.OperatorBudget") *| None*) – Constraints on how large the operator may grow during backpropagation. If `None`, a default instance of [`OperatorBudget`](utils-simplify#operatorbudget "qiskit_addon_obp.utils.simplify.OperatorBudget") will be used, and no constraints will be placed on the output operator size.
|
||
* **max\_seconds** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – The maximum number of seconds to run the backpropagation. If this timeout is triggered before the function returns, the metadata of that moment will be returned. Note, that this metadata may contain only partial information for the last slice being backpropagated.
|
||
|
||
**Returns**
|
||
|
||
* The backpropagated observables.
|
||
* The slices which were not absorbed into the observable during backpropagation.
|
||
* A metadata container.
|
||
|
||
**Raises**
|
||
|
||
* [**RuntimeError**](https://docs.python.org/3/library/exceptions.html#RuntimeError "(in Python v3.13)") – If the `max_seconds` argument is attempted to be used on Windows.
|
||
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)") – All observables and slices must act on equivalent numbers of qubits.
|
||
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)") – An input observable is larger than the constraints specified by `operator_budget`.
|
||
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.13)") – `operator_budget.max_paulis` or `operator_budget.max_qwc_groups` is less than 1.
|
||
|
||
**Return type**
|
||
|
||
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.13)")\[[*SparsePauliOp*](/api/qiskit/qiskit.quantum_info.SparsePauliOp "(in Qiskit v1.3)")], [*Sequence*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.13)")\[[*QuantumCircuit*](/api/qiskit/qiskit.circuit.QuantumCircuit "(in Qiskit v1.3)")], [*OBPMetadata*](utils-metadata-obp-metadata "qiskit_addon_obp.utils.metadata.OBPMetadata")]
|
||
</Function>
|
||
|