pygsti.errorgenpropagation.errorpropagator

Module Contents

Classes

ErrorGeneratorPropagator

Initialize an instance of ErrorGeneratorPropagator. This class is instantiated with a noise model

Attributes

msg

pygsti.errorgenpropagation.errorpropagator.msg = "'Stim is required for use of the error generator propagation module, and it does not appear to..."
class pygsti.errorgenpropagation.errorpropagator.ErrorGeneratorPropagator(model)

Initialize 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

This model is used to construct error generators for each layer of a circuit through which error generators are to be propagated.

model
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
circuitCircuit

Circuit to construct a set of post gate error generators for.

include_spambool, optional (default True)

If True then we include in the propagation the error generators associated with state preparation and measurement.

use_bchbool, optional (default False)

If True use the BCH approximation as part of the propagation algorithm.

bch_kwargdict, 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_basisBasis 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_kwargsdict, 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
eoc_error_channelnumpy.ndarray

A numpy array corresponding to the end-of-circuit error channel resulting from the propagated error generators. This is

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
circuitCircuit

Circuit to construct a set of post gate error generators for.

include_spambool, optional (default True)

If True then we include in the propagation the error generators associated with state preparation and measurement.

circuit_conversion_kwargsdict, 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_layerslist of lists of dictionaries

A list of lists of dictionaries, each corresponding to the result of propagating an error generator layer through to the end of the circuit.

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
circuitCircuit

Circuit to construct a set of post gate error generators for.

bch_orderint, optional (default 1)

Order of the BCH approximation to use. A maximum value of 4 is currently supported.

include_spambool, optional (default True)

If True then we include in the propagation the error generators associated with state preparation and measurement.

truncation_thresholdfloat, optional (default 1e-14)

Threshold below which any error generators with magnitudes below this value are truncated during the BCH approximation.

modestr, 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_kwargsdict, 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.

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
circuitCircuit

Circuit to construct error generator transform map for.

include_spambool, optional (default True)

If True then we include in the propagation the error generators associated with state preparation and measurement.

circuit_conversion_kwargsdict, 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.

errorgen_gate_contributors(errorgen, circuit, layer_idx, include_spam=True)

Walks through the gates in the specified circuit layer and query the parent model to figure out which gates could have given rise to a particular error generator in a layer.

Parameters
errorgenElementaryErrorgenLabel

Error generator layer to find instance of.

circuitCircuit

Circuit to identify potential gates in.

layer_idxint

Index of circuit layer.

include_spambool, optional (default True)

If True include the spam circuit layers at the beginning and end of the circuit.

Returns
label_list_for_errorgenlist of Label

A list of gate labels contained within this circuit layer that could have contributed this error generator.

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
circuitCircuit

Circuit to convert.

drop_first_layerbool, 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_kwargsdict, 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_layerslist of stim.Tableau

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.

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_layerslist 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_layerslist of stim.Tableau

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.

construct_errorgen_layers(circuit, num_qubits, include_spam=True, include_circuit_time=False, fixed_rate=None)

Construct a nested list of lists of dictionaries corresponding to the error generators for each circuit layer. This is currently (as implemented) only well defined for ExplicitOpModels where each layer corresponds to a single ‘gate’. This should also in principle work for crosstalk-free ImplicitOpModels, but is not configured to do so just yet. The entries of the top-level list correspond to circuit layers, while the entries of the second level (i.e. the dictionaries at each layer) correspond to different orders of the BCH approximation.

Parameters
circuitCircuit

Circuit to construct the error generator layers for.

num_qubitsint

Total number of qubits, used for padding out error generator coefficient labels.

include_spambool, optional (default True)

If True then include the error generators for state preparation and measurement.

include_circuit_timebool, 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_ratefloat, 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.

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_layerdict

A dictionary containing the error generator coefficients and rates for a circuit layer, with the error generator coefficients labels represented using LocalStimErrorgenLabel.

mx_basisBasis 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_densebool, optional (default False)

If True return the error generator as a dense numpy array.

Returns
errorgennumpy.ndarray

Error generator corresponding to input errorgen_layer dictionary as a numpy array.