pygsti.modelmembers.povms.composedpovm
Defines the ComposedPOVM class
Module Contents
Classes
TODO: update docstring |
- class pygsti.modelmembers.povms.composedpovm.ComposedPOVM(errormap, povm=None, mx_basis=None)
Bases:
pygsti.modelmembers.povms.povm.POVM
TODO: update docstring A POVM that is effectively a single Lindblad-parameterized gate followed by a computational-basis POVM.
Parameters
- errormapMapOperator
The error generator action and parameterization, encapsulated in a gate object. Usually a
LindbladOp
orComposedOp
object. (This argument is not copied, to allow ComposedPOVMEffects to share error generator parameters with other gates and spam vectors.)- povmPOVM, optional
A sub-POVM which supplies the set of “reference” effect vectors that errormap acts on to produce the final effect vectors of this LindbladPOVM. This POVM must be static (have zero parameters) and its evolution type must match that of errormap. If None, then a
ComputationalBasisPOVM
is used on the number of qubits appropriate to errormap’s dimension.- mx_basis{‘std’, ‘gm’, ‘pp’, ‘qt’} or Basis object
The basis for this spam vector. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object). If None, then this is extracted (if possible) from errormap.
Creates a new LindbladPOVM object.
Parameters
- errormapMapOperator
The error generator action and parameterization, encapsulated in a gate object. Usually a
LindbladOp
orComposedOp
object. (This argument is not copied, to allow ComposedPOVMEffects to share error generator parameters with other gates and spam vectors.)- povmPOVM, optional
A sub-POVM which supplies the set of “reference” effect vectors that errormap acts on to produce the final effect vectors of this LindbladPOVM. This POVM must be static (have zero parameters) and its evolution type must match that of errormap. If None, then a
ComputationalBasisPOVM
is used on the number of qubits appropriate to errormap’s dimension.- mx_basis{‘std’, ‘gm’, ‘pp’, ‘qt’} or Basis object
The basis for this spam vector. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object). If None, then this is extracted (if possible) from errormap.
- property parameter_labels
An array of labels (usually strings) describing this model member’s parameters.
- property num_params
Get the number of independent parameters which specify this POVM.
Returns
- int
the number of independent parameters.
- to_memoized_dict(mmg_memo)
Create a serializable dict with references to other objects in the memo.
Parameters
- mmg_memo: dict
Memo dict from a ModelMemberGraph, i.e. keys are object ids and values are ModelMemberGraphNodes (which contain the serialize_id). This is NOT the same as other memos in ModelMember (e.g. copy, allocate_gpindices, etc.).
Returns
- mm_dict: dict
A dict representation of this ModelMember ready for serialization This must have at least the following fields: module, class, submembers, params, state_space, evotype Additional fields may be added by derived classes.
- keys()
An iterator over the effect (outcome) labels of this POVM.
- values()
An iterator over the effect effect vectors of this POVM.
- items()
An iterator over the (effect_label, effect_vector) items in this POVM.
- set_gpindices(gpindices, parent, memo=None)
Set the parent and indices into the parent’s parameter vector that are used by this ModelMember object.
Parameters
- gpindicesslice or integer ndarray
The indices of this objects parameters in its parent’s array.
- parentModel or ModelMember
The parent whose parameter array gpindices references.
- memodict, optional
A memo dict used to avoid circular references.
Returns
None
- simplify_effects(prefix='')
Creates a dictionary of simplified effect vectors.
Returns a dictionary of effect POVMEffects that belong to the POVM’s parent Model - that is, whose gpindices are set to all or a subset of this POVM’s gpindices. Such effect vectors are used internally within computations involving the parent Model.
Parameters
- prefixstr
A string, usually identitying this POVM, which may be used to prefix the simplified gate keys.
Returns
OrderedDict of POVMEffects
- to_vector()
Extract a vector of the underlying gate parameters from this POVM.
Returns
- numpy array
a 1D numpy array with length == num_params().
- from_vector(v, close=False, dirty_value=True)
Initialize this POVM using a vector of its parameters.
Parameters
- vnumpy array
The 1D vector of POVM parameters. Length must == num_params().
- closebool, optional
Whether v is close to this POVM’s current set of parameters. Under some circumstances, when this is true this call can be completed more quickly.
- dirty_valuebool, optional
The value to set this object’s “dirty flag” to before exiting this call. This is passed as an argument so it can be updated recursively. Leave this set to True unless you know what you’re doing.
Returns
None
- transform_inplace(s)
Update each POVM effect E as s^T * E.
Note that this is equivalent to the transpose of the effect vectors being mapped as E^T -> E^T * s.
Parameters
- sGaugeGroupElement
A gauge group element which specifies the “s” matrix (and it’s inverse) used in the above similarity transform.
Returns
None
- depolarize(amount)
Depolarize this POVM by the given amount.
Parameters
- amountfloat or tuple
The amount to depolarize by. If a tuple, it must have length equal to one less than the dimension of the gate. All but the first element of each spam vector (often corresponding to the identity element) are multiplied by amount (if a float) or the corresponding amount[i] (if a tuple).
Returns
None
- errorgen_coefficient_labels()
The elementary error-generator labels corresponding to the elements of
errorgen_coefficients_array()
.Returns
- tuple
A tuple of (<type>, <basisEl1> [,<basisEl2]) elements identifying the elementary error generators of this gate.
- errorgen_coefficients_array()
The weighted coefficients of this POVM’s error generator in terms of “standard” error generators.
Constructs a 1D array of all the coefficients returned by
errorgen_coefficients()
, weighted so that different error generators can be weighted differently when a errorgen_penalty_factor is used in an objective function.Returns
- numpy.ndarray
A 1D array of length equal to the number of coefficients in the linear combination of standard error generators that is this state preparation’s error generator.
- errorgen_coefficients(return_basis=False, logscale_nonham=False)
Constructs a dictionary of the Lindblad-error-generator coefficients of this POVM.
Note that these are not necessarily the parameter values, as these coefficients are generally functions of the parameters (so as to keep the coefficients positive, for instance).
Parameters
- return_basisbool, optional
Whether to also return a
Basis
containing the elements with which the error generator terms were constructed.- logscale_nonhambool, optional
Whether or not the non-hamiltonian error generator coefficients should be scaled so that the returned dict contains: (1 - exp(-d^2 * coeff)) / d^2 instead of coeff. This essentially converts the coefficient into a rate that is the contribution this term would have within a depolarizing channel where all stochastic generators had this same coefficient. This is the value returned by
error_rates()
.
Returns
- lindblad_term_dictdict
Keys are (termType, basisLabel1, <basisLabel2>) tuples, where termType is “H” (Hamiltonian), “S” (Stochastic), or “A” (Affine). Hamiltonian and Affine terms always have a single basis label (so key is a 2-tuple) whereas Stochastic tuples have 1 basis label to indicate a diagonal term and otherwise have 2 basis labels to specify off-diagonal non-Hamiltonian Lindblad terms. Basis labels are integers starting at 0. Values are complex coefficients.
- basisBasis
A Basis mapping the basis labels used in the keys of lindblad_term_dict to basis matrices.
- set_errorgen_coefficients(lindblad_term_dict, action='update', logscale_nonham=False, truncate=True)
Sets the coefficients of terms in the error generator of this POVM.
The dictionary lindblad_term_dict has tuple-keys describing the type of term and the basis elements used to construct it, e.g. (‘H’,’X’).
Parameters
- lindblad_term_dictdict
Keys are (termType, basisLabel1, <basisLabel2>) tuples, where termType is “H” (Hamiltonian), “S” (Stochastic), or “A” (Affine). Hamiltonian and Affine terms always have a single basis label (so key is a 2-tuple) whereas Stochastic tuples have 1 basis label to indicate a diagonal term and otherwise have 2 basis labels to specify off-diagonal non-Hamiltonian Lindblad terms. Values are the coefficients of these error generators, and should be real except for the 2-basis-label case.
- action{“update”,”add”,”reset”}
How the values in lindblad_term_dict should be combined with existing error-generator coefficients.
- logscale_nonhambool, optional
Whether or not the values in lindblad_term_dict for non-hamiltonian error generators should be interpreted as error rates (of an “equivalent” depolarizing channel, see
errorgen_coefficients()
) instead of raw coefficients. If True, then the non-hamiltonian coefficients are set to -log(1 - d^2*rate)/d^2, where rate is the corresponding value given in lindblad_term_dict. This is what is performed by the functionset_error_rates()
.- truncatebool, optional
Whether to allow adjustment of the errogen coefficients in order to meet constraints (e.g. to preserve CPTP) when necessary. If False, then an error is thrown when the given coefficients cannot be set as specified.
Returns
None
- errorgen_coefficients_array_deriv_wrt_params()
The jacobian of
errogen_coefficients_array()
with respect to this POVM’s parameters.Returns
- numpy.ndarray
A 2D array of shape (num_coeffs, num_params) where num_coeffs is the number of coefficients of this operation’s error generator and num_params is this operation’s number of parameters.