pygsti.models.localnoisemodel
¶
Defines the LocalNoiseModel class and supporting functions
Module Contents¶
Classes¶
A nqubit implicit model that allows for only local noise. 

Rules for composing a layer operation from the elements stored within a model. 
 class pygsti.models.localnoisemodel.LocalNoiseModel(processor_spec, gatedict, prep_layers=None, povm_layers=None, evotype='default', simulator='auto', on_construction_error='raise', independent_gates=False, ensure_composed_gates=False, implicit_idle_mode='none')¶
Bases:
pygsti.models.implicitmodel.ImplicitOpModel
A nqubit implicit model that allows for only local noise.
This model holds as building blocks individual noisy gates which are trivially embedded into circuit layers as requested.
 Parameters
num_qubits (int) – The total number of qubits.
gatedict (dict) – A dictionary (an OrderedDict if you care about insertion order) that associates with gate names (e.g. “Gx”)
LinearOperator
, numpy.ndarray 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 availability. While the keys of this dictionary are usually stringtype gate names, labels that include target qubits, e.g. (“Gx”,0), may be used to override the default behavior of embedding a reference or a copy of the gate associated with the same label minus the target qubits (e.g. “Gx”). Furthermore,OpFactory
objects may be used in place of LinearOperator objects to allow the evaluation of labels with arguments.prep_layers (None or operator or dict or list) – The state preparateion operations as nqubit layer operations. If None, then no state preparations will be present in the created model. 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” where X is an integer starting at 0. If a single layer operation of type
State
is given, then this is used as the sole prep and is assigned the label “rho0”.povm_layers (None or operator or dict or list) – The state preparateion operations as nqubit layer operations. If None, then no POVMS will be present in the created model. 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 “MX” where X is an integer starting at 0. If a single layer operation of type
POVM
is given, then this is used as the sole POVM and is assigned the label “Mdefault”.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.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.
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+).
on_construction_error ({'raise','warn',ignore'}) – What to do when the conversion from a value in gatedict to a
LinearOperator
of the type given by parameterization fails. Usually you’ll want to “raise” the error. In some cases, for example when converting as many gates as you can into parameterization=”clifford” gates, “warn” or even “ignore” may be useful.independent_gates (bool, optional) –
Whether gates are allowed independent local noise or not. If False, then all gates with the same name (e.g. “Gx”) will have the same (local) noise (e.g. an overrotation by 1 degree), and the operation_bks[‘gates’] dictionary contains a single key per gate name. If True, then gates with the same name acting on different qubits may have different local noise, and so the operation_bks[‘gates’] dictionary contains a key for each gate
available gate placement.
ensure_composed_gates (bool, optional) – If True then the elements of the operation_bks[‘gates’] will always be
ComposedOp
objects. The purpose of this is to facilitate modifying the gate operations after the model is created. If False, then the appropriately parameterized gate objects (often dense gates) are used directly.global_idle (LinearOperator, optional) – A global idle operation, which is performed once at the beginning of every circuit layer. If None, no such operation is performed. If a 1qubit operator is given and num_qubits > 1 the global idle is the parallel application of this operator on each qubit line. Otherwise the given operator must act on all num_qubits qubits.
 create_processor_spec(self)¶
 _to_nice_serialization(self)¶
 classmethod _from_nice_serialization(cls, state)¶
 class pygsti.models.localnoisemodel._SimpleCompLayerRules(global_idle_layer_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