TruncationErrorBudget

class TruncationErrorBudget(per_slice_budget=<factory>, max_error_total=0.0, p_norm=1)[source]

Bases: object

A class for storing the constants that determine the truncation error budget.

Refer to the how-to guide for a detailed discussion on truncating operator terms during backpropagation and bounding the incurred error.

Attributes

max_error_total: float = 0.0

The maximum total truncation error to allow for each observable during the entire backpropagation. This value may be numpy.inf, for example when the maximum error was left unspecified during setup_budget().

p_norm: int = 1

Indicates which Lp-norm is used for calculating truncation errors.

Refer to the how-to guide for a detailed conversation on bounding truncation error using higher Lp-norms.

per_slice_budget: list[float]

The maximum amount of truncation error to allow per backpropagated slice. This list will be looped over during the backpropagation of the circuit slices.

Methods

is_active()[source]

Return whether the truncation is active, i.e. whether the budget is non-zero.

Return type:

bool