pygsti.tools.errgenproptools
Tools for the propagation of error generators through circuits.
Module Contents
Functions
Converts an input GlobalElementaryErrorgenLabel to a tuple of stim.PauliString |
|
|
Apply the BCH approximation at the given order to combine the input dictionaries |
|
Function for computing the nth-order magnus expansion for a set of error generator layers. |
|
Returns the commutator of two error generators. I.e. [errorgen_1, errorgen_2]. |
|
Returns the composition of two error generators. I.e. errorgen_1[errorgen_2[cdot]]. |
|
|
|
|
|
|
|
Returns true if pauli1 is less than pauli lexicographically. |
|
Apply the specified error generator to a given Pauli operator. |
|
Converts an iterable over error generator coefficients and rates into the corresponding |
|
Iteratively compute error generator compositions. Each error generator |
|
Numerically compute the commutator of the two specified elementary error generators. |
|
Numerically compute the composition of the two specified elementary error generators. |
|
Iteratively compute effective error generator layer produced by applying the BCH approximation |
|
Helper function for doing the numerical BCH in a pairwise fashion. Note this function is primarily intended |
|
Compute effective error generator layer produced by applying the magnus expansions |
|
Apply the specified error generator to a given Pauli operator. This implementation |
|
Iteratively compute error generator compositions. The function computes a dense representation of this composition |
|
Compute the number of bits over which the stabilizer state corresponding to this stim tableau |
|
Calculate the fidelity between the stabilizer states corresponding to the given stim |
|
Map a computational basis bit string into a corresponding Tableau which maps the all zero |
|
Get the amplitude of a particular computational basis state for given |
|
Takes as input a pauli and a bit string and computes the output bitstring |
|
This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators. |
|
This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators. |
|
First-order error generator sensitivity function for probability. |
|
First-order error generator sensitivity function for probability. This implementation calculates |
|
First-order error generator sensitivity function for pauli expectations. |
|
First-order error generator sensitivity function for pauli expectatons. This implementation calculates |
|
Compute the kth-order correction to the probability of the specified bit string. |
|
Compute the kth-order correction to the expectation value of the specified pauli. |
Compute the kth-order correction to the expectation value of the specified pauli. |
|
|
Calculate the output probability for the specifed output bitstring. |
|
Calculate the output probability for the specifed output bitstring. |
|
Calculate the approximate probability of a desired bit string using an nth-order taylor series approximation. |
|
Calculate the approximate probability of a desired bit string using a first-order approximation. |
Calculate the approximate probability of a desired bit string using a first-order approximation. |
|
|
Calculate the approximate probability distribution over all bitstrings using a first-order approximation. |
|
Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input |
|
Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input |
Attributes
- pygsti.tools.errgenproptools.msg = "'Stim is required for use of the error generator propagation tools module, and it does not..."
- pygsti.tools.errgenproptools.errgen_coeff_label_to_stim_pauli_strs(err_gen_coeff_label, num_qubits)
Converts an input GlobalElementaryErrorgenLabel to a tuple of stim.PauliString objects, padded with an appropriate number of identities.
Parameters
- err_gen_coeff_labelGlobalElementaryErrorgenLabel or LocalElementaryErrorgenLabel
The error generator coefficient label to construct the tuple of pauli strings for.
- num_qubitsint
Number of total qubits to use for the Pauli strings. Used to determine the number of identities added when padding.
Returns
- tuple of stim.PauliString
A tuple of either length 1 (for H and S) or length 2 (for C and A) whose entries are stim.PauliString representations of the indices for the input error generator label, padded with an appropriate number of identities given the support of the error generator label.
- pygsti.tools.errgenproptools.bch_approximation(errgen_layer_1, errgen_layer_2, bch_order=1, truncation_threshold=1e-14)
Apply the BCH approximation at the given order to combine the input dictionaries of error generator rates.
Parameters
- errgen_layer_1dict
Dictionary of the error generator coefficients and rates for a circuit layer. The error generator coefficients are represented using LocalStimErrorgenLabel.
- errgen_layer_2list of dicts
See errgen_layer_1.
- bch_orderint, optional (default 1)
Order of the BCH approximation to use. Currently support for up to fifth order.
- truncation_thresholdfloat, optional (default 1e-14)
Threshold for which any error generators with magnitudes below this value are truncated.
Returns
- combined_errgen_layerdict
A dictionary with the same general structure as errgen_layer_1 and errgen_layer_2, but with the rates combined according to the selected order of the BCH approximation.
- pygsti.tools.errgenproptools.magnus_expansion(errorgen_layers: list[dict[pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, float]], magnus_order: Literal[1, 2, 3] = 1, truncation_threshold: float = 1e-14) dict[pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, float]
Function for computing the nth-order magnus expansion for a set of error generator layers. Please see https://arxiv.org/abs/0810.5488 or https://en.wikipedia.org/wiki/Magnus_expansion for more information on this approximation.
Parameters
- errorgen_layerslist of dicts
List of dictionaries of the error generator coefficients and rates for a circuit layer. The error generator coefficients are represented using LocalStimErrorgenLabel.
- errorgen_transform_mapsdict
Map giving the relationship between input error generators and their final value following propagation through the circuit. Needed to track any sign updates for terms with zero mean but nontrivial covariance.
- cov_func :
A function which maps tuples of elementary error generator labels at multiple times to a scalar quantity corresponding to the value of the covariance for that pair.
- magnus_orderint, optional (default 1)
Order of the magnus expansion to apply. Currently supports up to third order.
- truncation_thresholdfloat, optional (default 1e-14)
Threshold for which any error generators with magnitudes below this value are truncated.
Returns
- magnus_expansion_dictdict
A dictionary with the same general structure as those in errorgen_layers, but with the rates combined according to the selected order of the magnus expansion.
- pygsti.tools.errgenproptools.error_generator_commutator(errorgen_1, errorgen_2, flip_weight=False, weight=1.0, identity=None)
Returns the commutator of two error generators. I.e. [errorgen_1, errorgen_2].
Parameters
- errorgen1LocalStimErrorgenLabel
First error generator.
- errorgen2LocalStimErrorgenLabel
Second error generator
- flip_weightbool, optional (default False)
If True flip the sign of the input value of weight kwarg.
- weightfloat, optional (default 1.0)
An optional weighting value to apply to the value of the commutator.
- identitystim.PauliString, optional (default None)
An optional stim.PauliString to use for comparisons to the identity. Passing in this kwarg isn’t necessary, but can allow for reduced stim.PauliString creation when calling this function many times for improved efficiency.
Returns
list of LocalStimErrorgenLabel`s corresponding to the commutator of the two input error generators, weighted by the specified value of `weight.
- pygsti.tools.errgenproptools.error_generator_composition(errorgen_1, errorgen_2, weight=1.0, identity=None)
Returns the composition of two error generators. I.e. errorgen_1[errorgen_2[cdot]].
Parameters
- errorgen1LocalStimErrorgenLabel
First error generator.
- errorgen2LocalStimErrorgenLabel
Second error generator
- weightfloat, optional (default 1.0)
An optional weighting value to apply to the value of the composition.
- identitystim.PauliString, optional (default None)
An optional stim.PauliString to use for comparisons to the identity. Passing in this kwarg isn’t necessary, but can allow for reduced stim.PauliString creation when calling this function many times for improved efficiency.
Returns
list of tuples. The first element of each tuple is a LocalStimErrorgenLabel`s corresponding to a component of the composition of the two input error generators. The second element is the weight of that term, additionally weighted by the specified value of `weight.
- pygsti.tools.errgenproptools.com(P1, P2)
- pygsti.tools.errgenproptools.acom(P1, P2)
- pygsti.tools.errgenproptools.pauli_product(P1, P2)
- pygsti.tools.errgenproptools.stim_pauli_string_less_than(pauli1, pauli2)
Returns true if pauli1 is less than pauli lexicographically.
Parameters
- pauli1, pauli2stim.PauliString
Paulis to compare.
- pygsti.tools.errgenproptools.errorgen_pauli_action(errorgen: pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, pauli: stim.PauliString) tuple[float, stim.PauliString]
Apply the specified error generator to a given Pauli operator.
Parameters
- errorgenLocalStimErrorgenLabel
A label specifying the error generator which should be applied to the specified Pauli operator.
- paulistim.PauliString
The pauli operator to apply the error generator to
Returns:
A tuple whose first value is the (generally complex) weight of the resulting pauli operator, and whose second value is the unsigned Pauli operator itself.
If the specified error generator annihilates the given pauli then this instead returns None.
- pygsti.tools.errgenproptools.errorgen_layer_to_matrix(errorgen_layer, num_qubits, errorgen_matrix_dict=None, sslbls=None)
Converts an iterable over error generator coefficients and rates into the corresponding dense numpy array representation.
Parameters
- errorgen_layerlist, tuple or dict
An iterable over error generator coefficient and rates. If a list or a tuple the elements should correspond to two-element tuples, the first value being an ElementaryErrorgenLabel and the second value the rate. If a dictionary the keys should be ElementaryErrorgenLabel and the values the rates.
- num_qubitsint
Number of qubits for the error generator matrix being constructed.
- errorgen_matrix_dictdict, optional (default None)
An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit.
- sslblslist or tuple, optional (default None)
A tuple or list of state space labels corresponding to the qubits upon which the error generators can supported. Only required when passing in a value of errorgen_matrix_dict with GlobalElementaryErrogenLabel keys in conjunction with an errorgen_layer with labels which are LocalElementaryErrorgenLabel (or vice-versa).
Returns
- errorgen_matndarray
ndarray for the dense representation of the specified error generator in the standard basis.
- pygsti.tools.errgenproptools.iterative_error_generator_composition(errorgen_labels, rates)
Iteratively compute error generator compositions. Each error generator composition in general returns a list of multiple new error generators, so this function manages the distribution and recursive application of the compositions for two-or-more error generator labels.
Parameters
- errorgen_labelstuple of LocalStimErrorgenLabel
A tuple of the elementary error generator labels to be composed.
- ratestuple of float
A tuple of corresponding error generator rates of the same length as the tuple of error generator labels.
Returns
List of tuples, the first element of each tuple is a LocalStimErrorgenLabel. The second element of each tuple is the final rate for that term.
- pygsti.tools.errgenproptools.error_generator_commutator_numerical(errorgen1, errorgen2, errorgen_matrix_dict=None, num_qubits=None)
Numerically compute the commutator of the two specified elementary error generators.
Parameters
- errorgen1LocalElementaryErrorgenLabel or LocalStimErrorgenLabel
First error generator.
- errorgen2ElementaryErrorgenLabel or LocalStimErrorgenLabel
Second error generator.
- errorgen_matrix_dictdict, optional (default None)
An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit.
- num_qubitsint, optional (default None)
Number of qubits for the error generator commutator being computed. Only required if errorgen_matrix_dict is None.
Returns
- ndarray
Numpy array corresponding to the dense representation of the commutator of the input error generators in the standard basis.
- pygsti.tools.errgenproptools.error_generator_composition_numerical(errorgen1, errorgen2, errorgen_matrix_dict=None, num_qubits=None)
Numerically compute the composition of the two specified elementary error generators.
Parameters
- errorgen1LocalElementaryErrorgenLabel or LocalStimErrorgenLabel
First error generator.
- errorgen2ElementaryErrorgenLabel or LocalStimErrorgenLabel
Second error generator.
- errorgen_matrix_dictdict, optional (default None)
An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit.
- num_qubitsint, optional (default None)
Number of qubits for the error generator commutator being computed. Only required if errorgen_matrix_dict is None.
Returns
- ndarray
Numpy array corresponding to the dense representation of the composition of the input error generators in the standard basis.
- pygsti.tools.errgenproptools.bch_numerical(propagated_errorgen_layers, error_propagator, bch_order=1)
Iteratively compute effective error generator layer produced by applying the BCH approximation to the list of input error generator matrices. Note this is primarily intended as part of testing and validation infrastructure.
Parameters
- propagated_errorgen_layerslist of numpy.ndarrays
List of the error generator layers to combine using the BCH approximation (in circuit ordering)
- error_propagatorErrorGeneratorPropagator
An ErrorGeneratorPropagator instance to use as part of the BCH calculation.
- bch_orderint, optional (default 1)
Order of the BCH approximation to apply (up to 5 is supported currently).
Returns
- numpy.ndarray
A dense numpy array corresponding to the result of the iterative application of the BCH approximation.
- pygsti.tools.errgenproptools.pairwise_bch_numerical(mat1, mat2, order=1)
Helper function for doing the numerical BCH in a pairwise fashion. Note this function is primarily intended for numerical validations as part of testing infrastructure.
- pygsti.tools.errgenproptools.magnus_numerical(propagated_errorgen_layers: list[dict[pygsti.baseobjs.errorgenlabel.ElementaryErrorgenLabel, float]], error_propagator: pygsti.errorgenpropagation.errorpropagator.ErrorGeneratorPropagator, magnus_order: Literal[1, 2, 3] = 1) numpy.ndarray
Compute effective error generator layer produced by applying the magnus expansions to the list of input error generator matrices. Note this is primarily intended as part of testing and validation infrastructure.
Parameters
- propagated_errorgen_layerslist of dictionaries
List of the error generator layers (in circuit ordering) in the form of dictionaries whose keys are elementary error generator labels and whose values are their corresponding rates. These dictionaries are in the format produced by the ErrorGeneratorPropagator class’s propagate_errorgens method.
- error_propagatorErrorGeneratorPropagator
An ErrorGeneratorPropagator instance to use as part of the Magnus calculation.
- magnus_orderint, optional (default 1)
Order of the Magnus expansion to apply (up to 3 is supported currently).
Returns
- numpy.ndarray
A dense numpy array corresponding to the result of Magnus expansion.
- pygsti.tools.errgenproptools.errorgen_pauli_action_numerical(errorgen: pygsti.baseobjs.errorgenlabel.ElementaryErrorgenLabel, pauli: stim.PauliString) numpy.ndarray
Apply the specified error generator to a given Pauli operator. This implementation performs the application of the error generator numerically and is primarily intended for use in testing.
Parameters
- errorgenElementaryErrorgenLabel or numpy.ndarray
A label specifying the error generator which should be applied to the specified Pauli operator or else a dense numpy array for the error generator (in the standard basis).
- paulistim.PauliString
The pauli operator to apply the error generator to.
Returns:
- numpy.ndarray
Dense representation of the weighted pauli operator resulting from the application of the specified error generator to the input pauli.
- pygsti.tools.errgenproptools.iterative_error_generator_composition_numerical(errorgen_labels, rates, errorgen_matrix_dict=None, num_qubits=None)
Iteratively compute error generator compositions. The function computes a dense representation of this composition numerically and is primarily intended as part of testing infrastructure.
Parameters
- errorgen_labelstuple of LocalStimErrorgenLabel
A tuple of the elementary error generator labels to be composed.
- ratestuple of float
A tuple of corresponding error generator rates of the same length as the tuple of error generator labels.
- errorgen_matrix_dictdict, optional (default None)
An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit.
- num_qubitsint, optional (default None)
Number of qubits for the error generator commutator being computed. Only required if errorgen_matrix_dict is None.
Returns
- numpy.ndarray
Dense numpy array representation of the super operator corresponding to the iterated composition written in the standard basis.
- pygsti.tools.errgenproptools.random_support(tableau, return_support=False)
Compute the number of bits over which the stabilizer state corresponding to this stim tableau would have measurement outcomes which are random.
Parameters
- tableaustim.Tableau
stim.Tableau corresponding to the stabilizer state we want the random support for.
- return_supportbool, optional (default False)
If True also returns a list of qubit indices over which the distribution of outcome bit strings is random.
- pygsti.tools.errgenproptools.tableau_fidelity(tableau1, tableau2)
Calculate the fidelity between the stabilizer states corresponding to the given stim tableaus. This returns a result in units of probability (so this may be squared fidelity depending on your convention).
Parameters
- tableau1stim.Tableau
Stim tableau for first stabilizer state.
- tableau2stim.Tableau
Stim tableau for second stabilizer state.
- pygsti.tools.errgenproptools.bitstring_to_tableau(bitstring)
Map a computational basis bit string into a corresponding Tableau which maps the all zero state into that state.
Parameters
- bitstringstr
String of 0’s and 1’s corresponding to the computational basis state to prepare the Tableau for.
Returns
- stim.Tableau
Tableau which maps the all zero string to this computational basis state
- pygsti.tools.errgenproptools.amplitude_of_state(tableau, desired_state)
Get the amplitude of a particular computational basis state for given stabilizer state.
Parameters
- tableaustim.Tableau
Stim tableau corresponding to the stabilizer state we wish to extract the amplitude from.
- desired_statestr
String of 0’s and 1’s corresponding to the computational basis state to extract the amplitude for.
- pygsti.tools.errgenproptools.pauli_phase_update(pauli, bitstring, dual=False)
Takes as input a pauli and a bit string and computes the output bitstring and the overall phase that bit string accumulates.
Parameters
- paulistr or stim.PauliString
Pauli to apply
- bitstringstr
String of 0’s and 1’s representing the bit string to apply the pauli to.
- dualbool, optional (default False)
If True then then the pauli is acting to the left on a row vector.
Returns
Tuple whose first element is the phase accumulated, and whose second element is a string corresponding to the updated bit string.
- pygsti.tools.errgenproptools.phi(tableau, desired_bitstring, P, Q)
This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators.
Parameters
- tableaustim.Tableau
A stim Tableau corresponding to the input stabilizer state.
- desired_bitstringstr
A string of zeros and ones corresponding to the bit string being measured.
- Pstr or stim.PauliString
The first pauli string index.
- Qstr or stim.PauliString
The second pauli string index.
Returns
A complex number corresponding to the value of the phi function.
- pygsti.tools.errgenproptools.phi_numerical(tableau, desired_bitstring, P, Q)
This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators. (This version does this calculation numerically and is primarily intended for testing infrastructure.)
Parameters
- tableaustim.Tableau
A stim Tableau corresponding to the input stabilizer state.
- desired_bitstringstr
A string of zeros and ones corresponding to the bit string being measured.
- Pstr or stim.PauliString
The first pauli string index.
- Qstr or stim.PauliString
The second pauli string index.
Returns
A complex number corresponding to the value of the phi function.
- pygsti.tools.errgenproptools.alpha(errorgen, tableau, desired_bitstring)
First-order error generator sensitivity function for probability.
Parameters
- errorgenElementaryErrorgenLabel
Error generator label for which to calculate sensitivity.
- tableaustim.Tableau
Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for.
- desired_bitstringstr
Bit string to calculate the sensitivity for.
- pygsti.tools.errgenproptools.alpha_numerical(errorgen, tableau, desired_bitstring)
First-order error generator sensitivity function for probability. This implementation calculates this quantity numerically, and as such is primarily intended for used as parting of testing infrastructure.
Parameters
- errorgenElementaryErrorgenLabel
Error generator label for which to calculate sensitivity.
- tableaustim.Tableau
Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for.
- desired_bitstringstr
Bit string to calculate the sensitivity for.
- pygsti.tools.errgenproptools.alpha_pauli(errorgen, tableau, pauli)
First-order error generator sensitivity function for pauli expectations.
Parameters
- errorgenElementaryErrorgenLabel
Error generator label for which to calculate sensitivity.
- tableaustim.Tableau
Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for.
- paulistim.PauliString
Pauli to calculate the sensitivity for.
- pygsti.tools.errgenproptools.alpha_pauli_numerical(errorgen, tableau, pauli)
First-order error generator sensitivity function for pauli expectatons. This implementation calculates this quantity numerically, and as such is primarily intended for used as parting of testing infrastructure.
Parameters
- errorgenElementaryErrorgenLabel
Error generator label for which to calculate sensitivity.
- tableaustim.Tableau
Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for.
- paulistim.PauliString
Pauli to calculate the sensitivity for.
- pygsti.tools.errgenproptools.stabilizer_probability_correction(errorgen_dict, tableau, desired_bitstring, order=1, truncation_threshold=1e-14)
Compute the kth-order correction to the probability of the specified bit string.
Parameters
- errorgen_dictdict
Dictionary whose keys are LocalStimErrorgenLabel and whose values are corresponding rates.
- tableaustim.Tableau
Stim tableau corresponding to a particular stabilizer state being measured.
- desired_bitstringstr
String of 0’s and 1’s corresponding to the output bitstring being measured.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding rates are below this value.
Returns
- correctionfloat
float corresponding to the correction to the output probability for the desired bitstring induced by the error generator (to specified order).
- pygsti.tools.errgenproptools.stabilizer_pauli_expectation_correction(errorgen_dict, tableau, pauli, order=1, truncation_threshold=1e-14)
Compute the kth-order correction to the expectation value of the specified pauli.
Parameters
- errorgen_dictdict
Dictionary whose keys are LocalStimErrorgenLabel and whose values are corresponding rates.
- tableaustim.Tableau
Stim tableau corresponding to a particular stabilizer state being measured.
- paulistim.PauliString
Pauli operator to compute expectation value correction for.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding rates are below this value.
Returns
- correctionfloat
float corresponding to the correction to the expectation value for the selected pauli operator induced by the error generator (to specified order).
- pygsti.tools.errgenproptools.stabilizer_pauli_expectation_correction_numerical(errorgen_dict, errorgen_propagator, circuit, pauli, order=1)
Compute the kth-order correction to the expectation value of the specified pauli.
Parameters
- errorgen_dictdict
Dictionary whose keys are LocalStimErrorgenLabel and whose values are corresponding rates.
- errorgen_propagatorErrorGeneratorPropagator
Error generator propagator used for constructing dense representation of the error generator dictionary.
- circuitCircuit
Circuit the expectation value is being measured against.
- paulistim.PauliString
Pauli operator to compute expectation value correction for.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
Returns
- correctionfloat
float corresponding to the correction to the expectation value for the selected pauli operator induced by the error generator (to specified order).
- pygsti.tools.errgenproptools.stabilizer_probability(tableau, desired_bitstring)
Calculate the output probability for the specifed output bitstring.
TODO: Should be able to do this more efficiently for many bitstrings by looking at the structure of the random support.
Parameters
- tableaustim.Tableau
Stim tableau for the stabilizer state being measured.
- desired_bitstringstr
String of 0’s and 1’s corresponding to the output bitstring being measured.
Returns
- pfloat
probability of desired bitstring.
- pygsti.tools.errgenproptools.stabilizer_pauli_expectation(tableau, pauli)
Calculate the output probability for the specifed output bitstring.
Parameters
- tableaustim.Tableau
Stim tableau for the stabilizer state being measured.
- paulistim.PauliString
Pauli operator to compute expectation value for.
Returns
- expected_valuefloat
Expectation value of specified pauli
- pygsti.tools.errgenproptools.approximate_stabilizer_probability(errorgen_dict, circuit, desired_bitstring, order=1, truncation_threshold=1e-14)
Calculate the approximate probability of a desired bit string using an nth-order taylor series approximation.
Parameters
- errorgen_dictdict
Dictionary whose keys are ElementaryErrorgenLabel and whose values are corresponding rates.
- circuitCircuit or stim.Tableau
A pygsti Circuit or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau.
- desired_bitstringstr
String of 0’s and 1’s corresponding to the output bitstring being measured.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections)
Returns
- pfloat
Approximate output probability for desired bitstring.
- pygsti.tools.errgenproptools.approximate_stabilizer_pauli_expectation(errorgen_dict, circuit, pauli, order=1, truncation_threshold=1e-14)
Calculate the approximate probability of a desired bit string using a first-order approximation.
Parameters
- errorgen_dictdict
Dictionary whose keys are ElementaryErrorgenLabel and whose values are corresponding rates.
- circuitCircuit or stim.Tableau
A pygsti Circuit or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau.
- paulistr or stim.PauliString
Pauli operator to compute expectation value for.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections)
Returns
- expectation_valuefloat
Approximate expectation value for desired pauli.
- pygsti.tools.errgenproptools.approximate_stabilizer_pauli_expectation_numerical(errorgen_dict, errorgen_propagator, circuit, pauli, order=1)
Calculate the approximate probability of a desired bit string using a first-order approximation. This function performs the corrections numerically and so it primarily intended for testing infrastructure.
Parameters
- errorgen_dictdict
Dictionary whose keys are ElementaryErrorgenLabel and whose values are corresponding rates.
- errorgen_propagatorErrorGeneratorPropagator
Error generator propagator used for constructing dense representation of the error generator dictionary.
- circuitCircuit
A pygsti Circuit or a stim.Tableau to compute the output pauli expectation value for.
- paulistim.PauliString
Pauli operator to compute expectation value for.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections)
Returns
- expectation_valuefloat
Approximate expectation value for desired pauli.
- pygsti.tools.errgenproptools.approximate_stabilizer_probabilities(errorgen_dict, circuit, order=1, truncation_threshold=1e-14)
Calculate the approximate probability distribution over all bitstrings using a first-order approximation. Note the size of this distribtion scales exponentially in the qubit count, so this is very inefficient for any more than a few qubits.
Parameters
- errorgen_dictdict
Dictionary whose keys are ElementaryErrorgenLabel and whose values are corresponding rates.
- circuitCircuit or stim.Tableau
A pygsti Circuit or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections)
Returns
- pfloat
Approximate output probability for desired bitstring.
- pygsti.tools.errgenproptools.error_generator_taylor_expansion(errorgen_dict, order=1, truncation_threshold=1e-14)
Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input error generator dictionary. (Excluding the zeroth-order identity).
Parameters
- errorgen_dictdict
Dictionary whose keys are LocalStimErrorgenLabel and whose values are corresponding rates.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- truncation_thresholdfloat, optional (default 1e-14)
Optional threshold used to truncate corrections whose corresponding rates are below this value.
Returns
- list of dictionaries
List of dictionaries whose keys are error generator labels and whose values are rates (including whatever scaling comes from order of taylor expansion). Each list corresponds to an order of the taylor expansion.
- pygsti.tools.errgenproptools.error_generator_taylor_expansion_numerical(errorgen_dict, errorgen_propagator, order=1, mx_basis='pp')
Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input error generator dictionary. (Excluding the zeroth-order identity). This function computes a dense representation of this taylor expansion as a numpy array and is primarily intended for testing infrastructure.
Parameters
- errorgen_dictdict
Dictionary whose keys are LocalStimErrorgenLabel and whose values are corresponding rates.
- errorgen_propagatorErrorGeneratorPropagator
Error generator propagator used for constructing dense representation of the error generator dictionary.
- orderint, optional (default 1)
Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute.
- mx_basisBasis or str, optional (default ‘pp’)
Basis in which to return the matrix.
Returns
- numpy.ndarray
A dense numpy array corresponding to the nth order taylor expansion of the specified error generator.