pygsti.models.cloudnoisemodel
¶
Defines the CloudNoiseModel class and supporting functions
Module Contents¶
Classes¶
A nqubit model using a lowweight and geometrically local error model with a common "global idle" operation. 

Rules for composing a layer operation from the elements stored within a model. 
 class pygsti.models.cloudnoisemodel.CloudNoiseModel(processor_spec, gatedict, prep_layers=None, povm_layers=None, build_cloudnoise_fn=None, build_cloudkey_fn=None, simulator='map', evotype='default', errcomp_type='gates', implicit_idle_mode='none', verbosity=0)¶
Bases:
pygsti.models.implicitmodel.ImplicitOpModel
A nqubit model using a lowweight and geometrically local error model with a common “global idle” operation.
 Parameters
num_qubits (int) – The number of qubits
gatedict (dict) – A dictionary (an OrderedDict if you care about insertion order) that associates with stringtype gate names (e.g. “Gx”)
LinearOperator
, numpy.ndarray, orOpFactory
objects. When the objects may act on fewer than the total number of qubits (determined by their dimension/shape) then they are repeatedly embedded into num_qubitsqubit gates as specified by their availability. These operations represent the ideal target operations, and thus, any LinearOperator or OpFactory objects must be static, i.e., have zero parameters.availability (dict, optional) –
A dictionary whose keys are the same gate names as in gatedict and whose values are lists of qubitlabeltuples. Each qubitlabeltuple must have length equal to the number of qubits the corresponding gate acts upon, and causes that gate to be embedded to act on the specified qubits. For example, { ‘Gx’: [(0,),(1,),(2,)], ‘Gcnot’: [(0,1),(1,2)] } would cause the 1qubit `’Gx’gate to be embedded three times, acting on qubits 0, 1, and 2, and the 2qubit ‘Gcnot’gate to be embedded twice, acting on qubits 0 & 1 and 1 & 2. Instead of a list of tuples, values of availability may take the special values:
”allpermutations” and “allcombinations” equate to all possible
permutations and combinations of the appropriate number of qubit labels (deterined by the gate’s dimension).  “alledges” equates to all the vertices, for 1Q gates, and all the edges, for 2Q gates of the geometry.  “arbitrary” or “*” means that the corresponding gate can be placed on any target qubits via an
EmbeddingOpFactory
(uses less memory but slower than “allpermutations”.If a gate name (a key of gatedict) is not present in availability, the default is “alledges”.
qubit_labels (tuple, optional) – The circuitline labels for each of the qubits, which can be integers and/or strings. Must be of length num_qubits. If None, then the integers from 0 to num_qubits1 are used.
geometry ({"line","ring","grid","torus"} or QubitGraph) – The type of connectivity among the qubits, specifying a graph used to define neighbor relationships. Alternatively, a
QubitGraph
object with node labels equal to qubit_labels may be passed directly.global_idle_layer (LinearOperator) – A global idle operation which acts on all the qubits and is, if add_idle_noise_to_all_gates=True, composed with the actions of specific gates to form the layer operation of any circuit layer.
prep_layers (None or operator or dict or list, optional) – The SPAM operations as nqubit layer operations. If None, then no preps (or POVMs) are created. If a dict, then the keys are labels and the values are layer operators. If a list, then the elements are layer operators and the labels will be assigned as “rhoX” and “MX” where X is an integer starting at 0. If a single layer operation is given, then this is used as the sole prep or POVM and is assigned the label “rho0” or “Mdefault” respectively.
povm_layers (None or operator or dict or list, optional) – The SPAM operations as nqubit layer operations. If None, then no preps (or POVMs) are created. If a dict, then the keys are labels and the values are layer operators. If a list, then the elements are layer operators and the labels will be assigned as “rhoX” and “MX” where X is an integer starting at 0. If a single layer operation is given, then this is used as the sole prep or POVM and is assigned the label “rho0” or “Mdefault” respectively.
build_cloudnoise_fn (function, optional) – A function which takes a single
Label
as an argument and returns the cloudnoise operation for that primitive layer operation. Note that if errcomp_type=”gates” the returned operator should be a superoperator whereas if errcomp_type=”errorgens” then the returned operator should be an error generator (not yet exponentiated).build_cloudkey_fn (function, optional) – An function which takes a single
Label
as an argument and returns a “cloud key” for that primitive layer. The “cloud” is the set of qubits that the error (the operator returned from build_cloudnoise_fn) touches – and the “key” returned from this function is meant to identify that cloud. This is used to keep track of which primitive layerlabels correspond to the same cloud  e.g. the cloudkey for (“Gx”,2) and (“Gy”,2) might be the same and could be processed together when selecing sequences that amplify the parameters in the cloudnoise operations for these two labels. The return value should be something hashable with the property that two noise which act on the same qubits should have the same cloud key.simulator (ForwardSimulator or {"auto", "matrix", "map"}) –
The circuit simulator used to compute any requested probabilities, e.g. from :method:`probs` or :method:`bulk_probs`. The default value of “auto” automatically selects the simulation type, and is usually what you want. Other special allowed values are:
”matrix” : op_matrixop_matrix products are computed and cached to get composite gates which can then quickly simulate a circuit for any preparation and outcome. High memory demand; best for a small number of (1 or 2) qubits.
”map” : op_matrixstate_vector products are repeatedly computed to simulate circuits. Slower for a small number of qubits, but faster and more memory efficient for higher numbers of qubits (3+).
evotype (Evotype or str, optional) – The evolution type of this model, describing how states are represented. The special value “default” is equivalent to specifying the value of pygsti.evotypes.Evotype.default_evotype.
errcomp_type ({"gates","errorgens"}) – How errors are composed when creating layer operations in the created model. “gates” means that the errors on multiple gates in a single layer are composed as separate and subsequent processes. Specifically, the layer operation has the form Composed(target,idleErr,cloudErr) where target is a composition of all the ideal gate operations in the layer, idleErr is idle error (.operation_blks[‘layers’][‘globalIdle’]), and cloudErr is the composition (ordered as layerlabel) of cloud noise contributions, i.e. a map that acts as the product of exponentiated errorgenerator matrices. “errorgens” means that layer operations have the form Composed(target, error) where target is as above and error results from composing the idle and cloudnoise error generators, i.e. a map that acts as the exponentiated sum of error generators (ordering is irrelevant in this case).
add_idle_noise_to_all_gates (bool, optional) – Whether the global idle should be added as a factor following the ideal action of each of the nonidle gates.
verbosity (int, optional) – An integer >= 0 dictating how must output to send to stdout.
 create_processor_spec(self)¶
 property clouds(self)¶
Returns the set of cloudsets used when creating sequences which amplify the parameters of this model.
 Returns
dict
 _to_nice_serialization(self)¶
 classmethod _from_nice_serialization(cls, state)¶
 class pygsti.models.cloudnoisemodel.CloudNoiseLayerRules(errcomp_type, implied_global_idle_label, implicit_idle_mode)¶
Bases:
pygsti.models.layerrules.LayerRules
Rules for composing a layer operation from the elements stored within a model.
A
LayerRules
object serves as an intermediary between aImplicitModel
object and aForwardSimulator
. It contains the logic for creating layer operations based on the partial/fundamental operation “blocks” stored within the model. Since different models hold different operation blocks, layer rules are usually tailored to a specific models. _to_nice_serialization(self)¶
 classmethod _from_nice_serialization(cls, state)¶
 prep_layer_operator(self, model, layerlbl, caches)¶
Create the operator corresponding to layerlbl.
 Parameters
layerlbl (Label) – A circuit layer label.
 Returns
State
 povm_layer_operator(self, model, layerlbl, caches)¶
Create the operator corresponding to layerlbl.
 Parameters
layerlbl (Label) – A circuit layer label.
 Returns
POVM or POVMEffect
 operation_layer_operator(self, model, layerlbl, caches)¶
Create the operator corresponding to layerlbl.
 Parameters
layerlbl (Label) – A circuit layer label.
 Returns
LinearOperator
 _layer_component_targetop(self, model, complbl, cache)¶
Retrieves the target or idealoperation portion of one component of a layer operation.
 Parameters
complbl (Label) – A component label of a larger layer label.
 Returns
LinearOperator
 _layer_component_cloudnoises(self, model, complbl_list, cache)¶
Retrieves cloudnoise portion of the components of a layer operation.
Get any present cloudnoise ops from a list of components. This function processes a list rather than an item because it’s OK if some components don’t have corresponding cloudnoise ops  we just leave those off.
 Parameters
complbl_list (list) – A list of circuitlayer component labels.
 Returns
list