backpropagate

backpropagate(observables, slices, *, truncation_error_budget=None, operator_budget=None, max_seconds=None)[source]

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 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 to the truncation_error_budget argument. Refer to the setup_budget() documentation for more details.

Warning

The max_seconds argument is not available on Windows!

Parameters:
  • observables (SparsePauliOp | list[SparsePauliOp]) – The observable(s) onto which the circuit is backpropagated.

  • slices (Sequence[QuantumCircuit]) – 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 to slice a single QuantumCircuit.

  • truncation_error_budget (TruncationErrorBudget | None) – The error budget used for truncating Pauli terms. Refer to the how-to guide for a detailed discussion on truncating terms from the output operator and bounding the incurred error.

  • operator_budget (OperatorBudget | None) – Constraints on how large the operator may grow during backpropagation. If None, a default instance of OperatorBudget will be used, and no constraints will be placed on the output operator size.

  • max_seconds (int | 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 – If the max_seconds argument is attempted to be used on Windows.

  • ValueError – All observables and slices must act on equivalent numbers of qubits.

  • ValueError – An input observable is larger than the constraints specified by operator_budget.

  • ValueErroroperator_budget.max_paulis or operator_budget.max_qwc_groups is less than 1.

Return type:

tuple[list[SparsePauliOp], Sequence[QuantumCircuit], OBPMetadata]