pygsti.errorgenpropagation.errorpropagator.ErrorGeneratorPropagator#
- class ErrorGeneratorPropagator(model=None, fixed_errorgen_layer=None, state_space_labels=None)#
Bases:
objectInitialize an instance of ErrorGeneratorPropagator. This class is instantiated with a noise model and manages operations related to propagating error generators through circuits, and constructing effective end-of-circuit error generators.
- Parameters:
model (OpModel, optional (default None)) – This model is used to construct error generators for each layer of a circuit through which error generators are to be propagated. Cannot be specified in conjunction with fixed_errorgen_layer.
fixed_errorgen_layer (dict, optional (default None)) – A dictionary corresponding to a fixed per-layer elementary error generator to use as the noise channel for each circuit layer. Keys that are `ElementaryErrorgenLabel`s and values are floats for the corresponding rates.
state_space_labels (list or int, optional (default None)) – Complete list of qubit state space labels. Used only in conjunction with fixed_errorgen_layer, and only when the keys for the error generator labels are `GlobalElementaryErrorgenLabel`s (and thus need to be cast to `LocalStimErrorgenLabel`s prior to propagation. When an integer the qubit labels are given by the range [0,state_space_labels).
Methods
__init__([model, fixed_errorgen_layer, ...])Initialize an instance of ErrorGeneratorPropagator.
construct_errorgen_layers(circuit, num_qubits)Construct a list of dictionaries corresponding to the error generators for each circuit layer.
construct_propagation_layers(stim_layers)Construct a list of stim Tableau objects corresponding to the Clifford operation each error generator will be propagated through.
construct_stim_layers(circuit[, ...])Converts a Circuit to a list of stim Tableau objects corresponding to each gate layer.
eoc_error_channel(circuit[, include_spam, ...])Propagate all of the error generators for each circuit layer to the end of the circuit and return the result of exponentiating these error generators, and if necessary taking their products, to return the end of circuit error channel.
errorgen_layer_dict_to_errorgen(errorgen_layer)Helper method for converting from an error generator dictionary in the format utilized in the errorgenpropagation module into a numpy array.
errorgen_transform_map(circuit[, ...])Construct a map giving the relationship between input error generators and their final value following propagation through the circuit.
errorgen_transform_maps(circuit[, ...])Construct a list of maps giving the relationship between input error generators and their final value following propagation through the circuit on an input-layer-by-input-layer basis.
propagate_errorgens(circuit[, include_spam, ...])Propagate all of the error generators for each circuit layer to the end without any recombinations or averaging.
propagate_errorgens_bch(circuit[, ...])Propagate all of the error generators for each circuit to the end, performing approximation/recombination using the BCH approximation.
- construct_errorgen_layers(circuit, num_qubits, include_spam=True, include_circuit_time=False, fixed_rate=None)#
Construct a list of dictionaries corresponding to the error generators for each circuit layer.
- Parameters:
circuit (Circuit) – Circuit to construct the error generator layers for.
num_qubits (int) – Total number of qubits, used for padding out error generator coefficient labels.
include_spam (bool, optional (default True)) – If True then include the error generators for state preparation and measurement.
include_circuit_time (bool, optional (default False)) – If True then include as part of the error generator coefficient labels the circuit time from which that error generator arose.
fixed_rate (float, optional (default None)) – If specified this rate is used for all of the error generator coefficients, overriding the value currently found in the model.
- Returns:
List of dictionaries, each one containing the error generator coefficients and rates for a circuit layer,
with the error generator coefficients now represented using LocalStimErrorgenLabel.
- construct_propagation_layers(stim_layers)#
Construct a list of stim Tableau objects corresponding to the Clifford operation each error generator will be propagated through. This corresponds to a list of cumulative products of the ideal operations, but in reverse. I.e. the initial entry corresponds to the product (in matrix multiplication order) of all elements of stim_layers, the second entry is the product of the elements of stim_layers[1:], then stim_layers[2:] and so on until the last entry which is stim_layers[-1].
- Parameters:
stim_layers (list of stim.Tableau) – The list of stim.Tableau objects corresponding to a set of ideal Clifford operation for each circuit layer through which we will be propagating error generators.
- Returns:
propagation_layers – A list of stim.Tableau objects, each corresponding to a cumulative product of ideal Clifford operations for a set of circuit layers, each corresponding to a layer of operations which we will be propagating error generators through.
- Return type:
list of stim.Tableau
- construct_stim_layers(circuit, drop_first_layer=True, circuit_conversion_kwargs=None)#
Converts a Circuit to a list of stim Tableau objects corresponding to each gate layer.
- Parameters:
circuit (Circuit) – Circuit to convert.
drop_first_layer (bool, optional (default True)) – If True the first Tableau for the first gate layer is dropped in the returned output. This default setting is what is primarily used in the context of error generator propagation.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.
- Returns:
stim_layers – A list of stim.Tableau objects, each corresponding to the ideal Clifford operation for each layer of the input pygsti Circuit, with the first layer optionally dropped.
- Return type:
list of stim.Tableau
- eoc_error_channel(circuit, include_spam=True, use_bch=False, bch_kwargs=None, mx_basis='pp', circuit_conversion_kwargs=None)#
Propagate all of the error generators for each circuit layer to the end of the circuit and return the result of exponentiating these error generators, and if necessary taking their products, to return the end of circuit error channel.
- Parameters:
circuit (Circuit) – Circuit to construct a set of post gate error generators for.
include_spam (bool, optional (default True)) – If True then we include in the propagation the error generators associated with state preparation and measurement.
use_bch (bool, optional (default False)) – If True use the BCH approximation as part of the propagation algorithm.
bch_kwarg (dict, optional (default None)) – Only used is use_bch is True, this dictionary contains a set of BCH-specific kwargs which are passed to propagate_errorgens_bch.
mx_basis (Basis or str, optional (default 'pp')) – Either a Basis object, or a string which can be cast to a Basis, specifying the basis in which to return the process matrix for the error channel.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.
bch_kwargs (dict)
- Returns:
eoc_error_channel – A numpy array corresponding to the end-of-circuit error channel resulting from the propagated error generators.
- Return type:
numpy.ndarray
- errorgen_layer_dict_to_errorgen(errorgen_layer, mx_basis='pp')#
Helper method for converting from an error generator dictionary in the format utilized in the errorgenpropagation module into a numpy array.
- Parameters:
errorgen_layer (dict) – A dictionary containing the error generator coefficients and rates for a circuit layer, with the error generator coefficients labels represented using LocalStimErrorgenLabel.
mx_basis (Basis or str, optional (default 'pp')) – Either a Basis object, or a string which can be cast to a Basis, specifying the basis in which to return the error generator.
return_dense (bool, optional (default False)) – If True return the error generator as a dense numpy array.
- Returns:
errorgen – Error generator corresponding to input errorgen_layer dictionary as a numpy array.
- Return type:
numpy.ndarray
- errorgen_transform_map(circuit, include_spam=True, circuit_conversion_kwargs=None)#
Construct a map giving the relationship between input error generators and their final value following propagation through the circuit.
- Parameters:
circuit (Circuit) – Circuit to construct error generator transform map for.
include_spam (bool, optional (default True)) – If True then we include in the propagation the error generators associated with state preparation and measurement.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.
- Return type:
dict[tuple[_LSE, int], tuple[_LSE, complex]]
- errorgen_transform_maps(circuit, include_spam=True, circuit_conversion_kwargs=None)#
Construct a list of maps giving the relationship between input error generators and their final value following propagation through the circuit on an input-layer-by-input-layer basis.
- Parameters:
circuit (Circuit) – Circuit to construct error generator transform map for.
include_spam (bool, optional (default True)) – If True then we include in the propagation the error generators associated with state preparation and measurement.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.
- Returns:
A list of dictionaries whose keys are tuples consisting of input error generators and circuit layer indices and whose values are tuples of output error generators and the corresponding accumulated phase.
- Return type:
list of dicts
- propagate_errorgens(circuit, include_spam=True, circuit_conversion_kwargs=None)#
Propagate all of the error generators for each circuit layer to the end without any recombinations or averaging.
- Parameters:
circuit (Circuit) – Circuit to construct a set of post gate error generators for.
include_spam (bool, optional (default True)) – If True then we include in the propagation the error generators associated with state preparation and measurement.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.
- Returns:
propagated_errorgen_layers – A list of lists of dictionaries, each corresponding to the result of propagating an error generator layer through to the end of the circuit.
- Return type:
list of lists of dictionaries
- propagate_errorgens_bch(circuit, bch_order=1, include_spam=True, truncation_threshold=1e-14, mode='magnus', circuit_conversion_kwargs=None)#
Propagate all of the error generators for each circuit to the end, performing approximation/recombination using the BCH approximation.
- Parameters:
circuit (Circuit) – Circuit to construct a set of post gate error generators for.
bch_order (int, optional (default 1)) – Order of the BCH approximation to use. A maximum value of 4 is currently supported.
include_spam (bool, optional (default True)) – If True then we include in the propagation the error generators associated with state preparation and measurement.
truncation_threshold (float, optional (default 1e-14)) – Threshold below which any error generators with magnitudes below this value are truncated during the BCH approximation.
mode (str, optional ('magnus' default)) – This specifies whether to apply the BCH approximation using a given order of the Magnus expansion (default mode of ‘magnus’) or via repeated application of the pairwise BCH of the given order ‘pairwise’. ‘magnus’ mode supports up to the third-order Magnus expansion, while ‘pairwise’ supports up to fifth-order in the BCH approximation.
circuit_conversion_kwargs (dict, optional (default None)) – A set of optional kwargs which will be passed into the convert_to_stim_tableau_layers method of the Circuit class to control the behavior of the conversion. Please see the documentation for this method for additional information on supported arguments and values.