OBPMetadata¶
- class OBPMetadata(truncation_error_budget, num_slices, operator_budget, backpropagation_history, num_backpropagated_slices)[source]¶
Bases:
object
A container for metadata generated during the
backpropagate()
method.Attributes
- Parameters:
truncation_error_budget (TruncationErrorBudget)
num_slices (int | None)
operator_budget (OperatorBudget)
backpropagation_history (list[SliceMetadata])
num_backpropagated_slices (int)
- truncation_error_budget: TruncationErrorBudget¶
Values specifying the observable truncation strategy.
- operator_budget: OperatorBudget¶
Values specifying how large the operator may grow.
- backpropagation_history: list[SliceMetadata]¶
A sequence of metadata objects to track the progression of the backpropagation.
- num_backpropagated_slices: int¶
The number of backpropagated slices.
Note
This value can differ from
len(backpropagation_history)
in cases where a stopping criterion such asoperator_budget.max_paulis
oroperator_budget.max_qwc_groups
caused the backpropagation to terminate. Then, this value should be equal tolen(backpropagation_history) - 1
because the last slice caused the thresholds to be exceeded. However, for convenience these values are still recorded for the end-user to inspect them.
Methods
- accumulated_error(observable_idx, slice_idx=None)[source]¶
Compute the accumulated error for a given observable at a given “time”.
This method computes the accumulated error for a given observable index at a given “time” during the course of the backpropagation. In this context, “time” is to be understood as the discrete steps of already backpropagated slices.
The accumulated error is computed as the sum of the individual
SliceMetadata.slice_errors
. These in turn may be computed within a specifiedTruncationErrorBudget.p_norm
. Thus, the computed accumulated error is an upper bound to the real accumulated error as given by the Minkowski inequality (the generalization of the triangle inequality for Lp-norms other thanp=2
).Note
Since a general Lp-norm (other than
p=2
) is not an inner product norm, it does not satisfy the parallelogram law. Hence, we must use the Minkowski inequality as the upper bound of the accumulated error.- Parameters:
observable_idx (int) – the index of the observable whose accumulated error to compute.
slice_idx (int | None) – the index of the slice (the discrete “time” step) up to which to compute the accumulated error. If this is
None
, it will default toself.num_backpropagated_slices
which is equivalent to computing the accumulated error of an observable at the latest point in time which has not surpassed any stopping criteria in the algorithm
- Returns:
The accumulated error computed per the explanations above.
- Return type:
- classmethod from_json(json_file)[source]¶
Load a metadata from a json file.
- Parameters:
json_file (str) – the path to the file to be loaded.
- Returns:
The loaded metadata.
- Return type:
- left_over_error_budget(observable_idx, slice_idx=None)[source]¶
Compute the left-over error budget for a given observable at a given “time”.
This method computes the left-over error budget for a given observable index at a given “time” during the course of the backpropagation. In this context, “time” is to be understood as the discrete steps of already backpropagated slices.
The left-over error budget is computed as the remainder of the total budget minus the sum of the individual
SliceMetadata.slice_errors
. These in turn may be computed within a specifiedTruncationErrorBudget.p_norm
.Note
See also the explanations in
accumulated_error()
for more details on how the individual slice errors are summed up to form an upper bound to the real error via the Minkowski inequality.Note
The left-over error budget is relative to the value of
self.truncation_error_budget.max_error_total
which may benumpy.inf
in which case the returned value of this method will benumpy.inf
, too.- Parameters:
observable_idx (int) – the index of the observable whose left-over error budget to compute.
slice_idx (int | None) – the index of the slice (the discrete “time” step) up to which to compute the left-over error budget. If this is
None
, it will default toself.num_backpropagated_slices
which is equivalent to computing the left-over error budget of an observable at the latest point in time which has not surpassed any stopping criteria in the algorithm
- Returns:
The left-over error budget computed per the explanations above.
- Return type: