pygsti.models.modelnoise.OpModelNoise#
- class OpModelNoise#
Bases:
ModelNoiseNoise on a model containing individual gate/SPAM operations, e.g. an
OpModelobject.This class is a base class that should not be instantiated directly.
Methods
__init__()apply_errorgen_stencil(stencil, evotype, ...)Apply an error-generator stencil created by this object to a specific set of target labels.
apply_errormap_stencil(stencil, evotype, ...)Apply an error-map stencil created by this object to a specific set of target labels.
cast(obj)Convert an object to an
OpModelNoiseobject if it isn't already.compute_stencil_absolute_sslbls(stencil, ...)Computes the set of state space labels that would be utilized when applying a stencil.
create_errorgen(opkey, evotype, state_space)Create an error generator object to implement the noise on a given model operation.
create_errorgen_stencil(opkey, evotype, ...)Create an "error generator stencil" for the noise corresponding to an operation label.
create_errormap(opkey, evotype, state_space)Create an error map object to implement the noise on a given model operation.
create_errormap_stencil(opkey, evotype, ...)Create an "error map stencil" for the noise corresponding to an operation label.
keys()The operation labels for which this object specifies noise.
Resets the internal key-access counters to zero.
Issue a warning if any of the internal key-access counters are zero
- apply_errorgen_stencil(stencil, evotype, state_space, target_labels=None, qudit_graph=None, copy=False)#
Apply an error-generator stencil created by this object to a specific set of target labels.
A stencil is applied by embedding each operator in the stencil according to its target state space labels (which may include stencil-label expansions) and then composing the results.
- Parameters:
stencil (OrderedDict) – The stencil to apply, usually created by
create_errorgen_stencil().evotype (str or Evotype) – The evolution type of to use when creating the embedded and composed operators, which should match that of the stencil operators (the evotype used to create the stencil).
state_space (StateSpace) – The state space to use when creating the composed and embedded operators. This should be the total state space of the model that these noise operations will be inserted into.
target_labels (tuple or None, optional) – The target labels that determine where on the qudit graph this stencil will be placed. When a tuple, it should have length equal to the num_target_labels argument passed to
create_errorgen_stencil(). None indicates that the entire space is the “target” space of the stencil (e.g. a global idle, preparation, or measurement).qudit_graph (QubitGraph, optional) – The relevant qudit graph, usually from a processor specification, that contains adjacency and direction information used to resolve stencil state space labels into absolute labels within state_space. If None, then an error will be raised if any direction or connectivity information is needed to resolve the state space labels.
copy (bool, optional) – Whether the stencil operations should be copied before embedding and composing them to apply the stencil. True can be used to make different applications of the stencil independent operations.
- Return type:
- apply_errormap_stencil(stencil, evotype, state_space, target_labels=None, qudit_graph=None, copy=False)#
Apply an error-map stencil created by this object to a specific set of target labels.
A stencil is applied by embedding each operator in the stencil according to its target state space labels (which may include stencil-label expansions) and then composing the results.
- Parameters:
stencil (OrderedDict) – The stencil to apply, usually created by
create_errormap_stencil().evotype (str or Evotype) – The evolution type of to use when creating the embedded and composed operators, which should match that of the stencil operators (the evotype used to create the stencil).
state_space (StateSpace) – The state space to use when creating the composed and embedded operators. This should be the total state space of the model that these noise operations will be inserted into.
target_labels (tuple or None, optional) – The target labels that determine where on the qudit graph this stencil will be placed. When a tuple, it should have length equal to the num_target_labels argument passed to
create_errormap_stencil(). None indicates that the entire space is the “target” space of the stencil (e.g. a global idle, preparation, or measurement).qudit_graph (QubitGraph, optional) – The relevant qudit graph, usually from a processor specification, that contains adjacency and direction information used to resolve stencil state space labels into absolute labels within state_space. If None, then an error will be raised if any direction or connectivity information is needed to resolve the state space labels.
copy (bool, optional) – Whether the stencil operations should be copied before embedding and composing them to apply the stencil. True can be used to make different applications of the stencil independent operations.
- Return type:
- classmethod cast(obj)#
Convert an object to an
OpModelNoiseobject if it isn’t already.If a dictionary is given, it is assumed to contain per-operation error specifications. If a list/tuple is given, it is assumed to contain multiple sub-specifications that should be composed together (by constructing a
ComposedOpModelNoiseobject).- Parameters:
obj (object) – The object to convert.
- Return type:
- compute_stencil_absolute_sslbls(stencil, state_space, target_labels=None, qudit_graph=None)#
Computes the set of state space labels that would be utilized when applying a stencil.
This function computes which state space labels are non-trivially acted upon by the operation that results from applying stencil to target_labels.
- Parameters:
stencil (OrderedDict) – The stencil. A dictionary with keys that are target state space labels (perhaps stencil labels) and values that are operations. This function only cares about the keys of this dictionary.
state_space (StateSpace) – The state space that would be given if/when applying stencil. This should be the total state space of the model that the applied stencil would be inserted into.
target_labels (tuple or None, optional) – The target labels that determine where on the qudit graph stencil will be placed. None indicates that the entire space is the “target” space of the stencil.
qudit_graph (QubitGraph, optional) – The relevant qudit graph that contains adjacency and direction information used to resolve stencil state space labels into absolute labels within state_space. If None, then an error will be raised if any direction or connectivity information is needed to resolve the state space labels.
- Returns:
A set (i.e. without any duplicates) of the state space labels that would be acted upon.
- Return type:
set
- create_errorgen(opkey, evotype, state_space, target_labels=None, qudit_graph=None)#
Create an error generator object to implement the noise on a given model operation.
- Parameters:
opkey (Label or StencilLabel) – The operation label to create the error generator for.
evotype (str or Evotype) – The evolution type to use when creating the error generator.
state_space (StateSpace) – The state space to use when creating the error generator.
target_labels (tuple or None, optional) – The target state space labels for this operation. Sometimes this is also contained in opkey, but not always, so it must be supplied as a separate argument.
qudit_graph (QubitGraph, optional) – The relevant qudit graph, usually from a processor specification, that contains adjacency and direction information used to create more complex types of errors. If None, then an error will be raised if graph information is needed.
- Return type:
- create_errorgen_stencil(opkey, evotype, state_space, num_target_labels=None)#
Create an “error generator stencil” for the noise corresponding to an operation label.
A stencil is one or more operator objects that have yet to be embedded on their final qudits and then composed. The embedding and composing step is done later so that, if desired, the same errors can be used on multiple sets of target qudits (often this is done when a “independent” argument to a model-creation function is False). An “error generator stencil” is a stencil whose operators are error generators, rather than error maps.
- Parameters:
opkey (Label or StencilLabel) – The operation label to create the stencil for.
evotype (str or Evotype) – The evolution type of to use when creating the stencil operators.
state_space (StateSpace) – The state space to use when creating the stencil operators. This can be a local state space, disparate from the actual processor’s state space, or the entire state space that the stencil operations will ultimately be embedded into. In the former case, num_target_labels should be left as None, indicating that state_space is the exact space being acted upon. In the latter case, num_target_labels should specify the number of target labels within state_space that this stencil will be given when it is applied (embedded) into state_space. This requires that all the labels in state_space correspond to the same type and dimension space (e.g. all are qubit spaces).
num_target_labels (int or None) – The number of labels within state_space that the op_key operation acts upon (this assumes that all the labels in state_space are similar, e.g., all qubits). If None then it acts on the entire space given by state_space.
- Returns:
stencil – A dictionary with keys that are
LabelorStencilLabelobjects and values that areLinearOperatorobjects. The stencil is applied by embedding each operator according to its key and then composing the results.- Return type:
OrderedDict
- create_errormap(opkey, evotype, state_space, target_labels=None, qudit_graph=None, copy=False)#
Create an error map object to implement the noise on a given model operation.
- Parameters:
opkey (Label or StencilLabel) – The operation label to create the error map for.
evotype (str or Evotype) – The evolution type to use when creating the error map.
state_space (StateSpace) – The state space to use when creating the error map.
target_labels (tuple or None, optional) – The target state space labels for this operation. Sometimes this is also contained in opkey, but not always, so it must be supplied as a separate argument.
qudit_graph (QubitGraph, optional) – The relevant qudit graph, usually from a processor specification, that contains adjacency and direction information used to create more complex types of errors. If None, then an error will be raised if graph information is needed.
copy (bool, optional) – Whether the operations arising from the same stencil should be copied before embedding and composing them to apply the stencil. True can be used to make different applications of the stencil independent operations.
- Return type:
- create_errormap_stencil(opkey, evotype, state_space, num_target_labels=None)#
Create an “error map stencil” for the noise corresponding to an operation label.
A stencil is one or more operator objects that have yet to be embedded on their final qudits and then composed. The embedding and composing step is done later so that, if desired, the same errors can be used on multiple sets of target qudits (often this is done when a “independent” argument to a model-creation function is False). An “error map stencil” is a stencil whose operators are error maps rather than error generators.
- Parameters:
opkey (Label or StencilLabel) – The operation label to create the stencil for.
evotype (str or Evotype) – The evolution type of to use when creating the stencil operators.
state_space (StateSpace) – The state space to use when creating the stencil operators. This can be a local state space, disparate from the actual processor’s state space, or the entire state space that the stencil operations will ultimately be embedded into. In the former case, num_target_labels should be left as None, indicating that state_space is the exact space being acted upon. In the latter case, num_target_labels should specify the number of target labels within state_space that this stencil will be given when it is applied (embedded) into state_space. This requires that all the labels in state_space correspond to the same type and dimension space (e.g. all are qubit spaces).
num_target_labels (int or None) – The number of labels within state_space that the op_key operation acts upon (this assumes that all the labels in state_space are similar, e.g., all qubits). If None then it acts on the entire space given by state_space.
- Returns:
stencil – A dictionary with keys that are
LabelorStencilLabelobjects and values that areLinearOperatorobjects. The stencil is applied by embedding each operator according to its key and then composing the results.- Return type:
OrderedDict
- keys()#
The operation labels for which this object specifies noise.
- reset_access_counters()#
Resets the internal key-access counters to zero.
These counters tally the number of times each operation key is accessed, and are used to identify model noise specification that are supplied by the user but never used. See
warn_about_zero_counters().- Return type:
None
- warn_about_zero_counters()#
Issue a warning if any of the internal key-access counters are zero
Used to catch noise specifications that are never utilized and that the caller/user should be warned about.
- Return type:
None