pygsti.models.oplessmodel
¶
Defines the OplessModel class
Module Contents¶
Classes¶
A model that does not have independent component operations. 

An opless model that always outputs 2 (success & failure) probabilities for each circuit. 

A successfail model based on pergate error rates. 

A model where twirledlayer error rates are computed and multiplied together to compute success probabilities. 

A model where twirledgate error rates are computed and multiplied together to compute success probabilities. 

A model where any gate failure causes a circuit failure. 

A model where any gate error causes a random circuit output. 
 class pygsti.models.oplessmodel.OplessModel(state_space)¶
Bases:
pygsti.models.model.Model
A model that does not have independent component operations.
OplessModel
derived classes often implement coarser models that predict the success or outcome probability of a circuit based on simple properties of the circuit and not detailed gatelevel modeling. Parameters
state_space (StateSpace) – The state space of this model.
 property dim(self)¶
 property parameter_bounds(self)¶
Upper and lower bounds on the values of each parameter, utilized by optimization routines
 abstract circuit_outcomes(self, circuit)¶
Get all the possible outcome labels produced by simulating this circuit.
 Parameters
circuit (Circuit) – Circuit to get outcomes of.
 Returns
tuple
 abstract probabilities(self, circuit, outcomes=None, time=None)¶
Construct a dictionary containing the outcome probabilities of circuit.
 Parameters
circuit (Circuit or tuple of operation labels) – The sequence of operation labels specifying the circuit.
outcomes (list or tuple) – A sequence of outcomes, which can themselves be either tuples (to include intermediate measurements) or simple strings, e.g. ‘010’.
time (float, optional) – The start time at which circuit is evaluated.
 Returns
probs (OutcomeLabelDict) – A dictionary with keys equal to outcome labels and values equal to probabilities.
 abstract bulk_probabilities(self, circuits, clip_to=None, comm=None, mem_limit=None, smartc=None)¶
Construct a dictionary containing the probabilities for an entire list of circuits.
 Parameters
circuits ((list of Circuits) or CircuitOutcomeProbabilityArrayLayout) – When a list, each element specifies a circuit to compute outcome probabilities for. A
CircuitOutcomeProbabilityArrayLayout
specifies the circuits along with an internal memory layout that reduces the time required by this function and can restrict the computed probabilities to those corresponding to only certain outcomes.clip_to (2tuple, optional) – (min,max) to clip return value if not None.
comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors. Distribution is performed over subtrees of evalTree (if it is split).
mem_limit (int, optional) – A rough memory limit in bytes which is used to determine processor allocation.
smartc (SmartCache, optional) – A cache object to cache & use previously cached values inside this function.
 Returns
probs (dictionary) – A dictionary such that probs[opstr] is an ordered dictionary of (outcome, p) tuples, where outcome is a tuple of labels and p is the corresponding probability.
 abstract __str__(self)¶
Return str(self).
 class pygsti.models.oplessmodel.SuccessFailModel(state_space, use_cache=False)¶
Bases:
OplessModel
An opless model that always outputs 2 (success & failure) probabilities for each circuit.
 Parameters
state_space (StateSpace) – The state space of this model.
use_cache (bool, optional) – Whether a cache should be used to increase performance.
 _to_nice_serialization(self)¶
 classmethod _from_nice_serialization(cls, state)¶
 property sim(self)¶
Forward simulator for this model
 _post_copy(self, copy_into, memo)¶
Called after all other copying is done, to perform “linking” between the new model (copy_into) and its members.
 circuit_outcomes(self, circuit)¶
Get all the possible outcome labels produced by simulating this circuit.
 Parameters
circuit (Circuit) – Circuit to get outcomes of.
 Returns
tuple
 abstract _success_prob(self, circuit, cache)¶
 _success_dprob(self, circuit, param_slice, cache)¶
Derived classes can override this. Default implemntation is to use finite difference.
 probabilities(self, circuit, outcomes=None, time=None)¶
Construct a dictionary containing the outcome probabilities of circuit.
 Parameters
circuit (Circuit or tuple of operation labels) – The sequence of operation labels specifying the circuit.
outcomes (list or tuple) – A sequence of outcomes, which can themselves be either tuples (to include intermediate measurements) or simple strings, e.g. ‘010’.
time (float, optional) – The start time at which circuit is evaluated.
 Returns
probs (OutcomeLabelDict) – A dictionary with keys equal to outcome labels and values equal to probabilities.
 bulk_probabilities(self, circuits, clip_to=None, comm=None, mem_limit=None, smartc=None)¶
Construct a dictionary containing the probabilities for an entire list of circuits.
 Parameters
circuits ((list of Circuits) or CircuitOutcomeProbabilityArrayLayout) – When a list, each element specifies a circuit to compute outcome probabilities for. A
CircuitOutcomeProbabilityArrayLayout
specifies the circuits along with an internal memory layout that reduces the time required by this function and can restrict the computed probabilities to those corresponding to only certain outcomes.clip_to (2tuple, optional) – (min,max) to clip return value if not None.
comm (mpi4py.MPI.Comm, optional) – When not None, an MPI communicator for distributing the computation across multiple processors. Distribution is performed over subtrees of evalTree (if it is split).
mem_limit (int, optional) – A rough memory limit in bytes which is used to determine processor allocation.
smartc (SmartCache, optional) – A cache object to cache & use previously cached values inside this function.
 Returns
probs (dictionary) – A dictionary such that probs[opstr] is an ordered dictionary of (outcome, p) tuples, where outcome is a tuple of labels and p is the corresponding probability.
 class pygsti.models.oplessmodel.ErrorRatesModel(error_rates, num_qubits, state_space_labels=None, alias_dict={}, idle_name='Gi')¶
Bases:
SuccessFailModel
A successfail model based on pergate error rates.
 Parameters
error_rates (dict) – A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of errorrates for gates or SPAM elements, respectively.
num_qubits (int) – The number of qubits in the model.
state_space_labels (StateSpaceLabels or list or tuple) – The decomposition (with labels) of (pure) statespace this model acts upon. Regardless of whether the model contains operators or superoperators, this argument describes the Hilbert space dimension and imposed structure. If a list or tuple is given, it must be of a from that can be passed to StateSpaceLabels.__init__.
alias_dict (dict, optional) – An alias dictionary mapping the gate labels in circuits to the keys of a (nested) error_rates dictionary. This allows, for instance, many gates’ error rates to be set by the same model parameter.
idle_name (str, optional) – The gate name to be used for the 1qubit idle gate (this should be set in error_rates to add idle errors.
 property primitive_op_labels(self)¶
 property primitive_instrument_labels(self)¶
 __str__(self)¶
Return str(self).
 to_dict(self)¶
Convert this model to a dictionary (for debugging or easy printing).
 _circuit_cache(self, circuit)¶
 class pygsti.models.oplessmodel.TwirledLayersModel(error_rates, num_qubits, state_space_labels=None, alias_dict={}, idle_name='Gi')¶
Bases:
ErrorRatesModel
A model where twirledlayer error rates are computed and multiplied together to compute success probabilities.
In this model, the success probability of a circuit is the product of 1.0  alpha * pfail terms, one per layer of the circuit (including idles). The pfail of a circuit layer is given as 1  prod(1  error_rate_i), where i ranges over the gates in the layer. alpha is the constant 4^w / (4^w  1) where w is the circuit width.
 Parameters
error_rates (dict) – A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of errorrates for gates or SPAM elements, respectively.
num_qubits (int) – The number of qubits in the model.
state_space_labels (StateSpaceLabels or list or tuple) – The decomposition (with labels) of (pure) statespace this model acts upon. Regardless of whether the model contains operators or superoperators, this argument describes the Hilbert space dimension and imposed structure. If a list or tuple is given, it must be of a from that can be passed to StateSpaceLabels.__init__.
alias_dict (dict, optional) – An alias dictionary mapping the gate labels in circuits to the keys of a (nested) error_rates dictionary. This allows, for instance, many gates’ error rates to be set by the same model parameter.
idle_name (str, optional) – The gate name to be used for the 1qubit idle gate (this should be set in error_rates to add idle errors.
 _success_prob(self, circuit, cache)¶
 _success_dprob(self, circuit, param_slice, cache)¶
Derived classes can override this. Default implemntation is to use finite difference.
 class pygsti.models.oplessmodel.TwirledGatesModel(error_rates, num_qubits, state_space_labels=None, alias_dict={}, idle_name='Gi')¶
Bases:
ErrorRatesModel
A model where twirledgate error rates are computed and multiplied together to compute success probabilities.
In this model, the success probability of a circuit is the product of 1.0  alpha * pfail terms, one per gate of the circuit (including idles). The pfail of a gate is given as 1  error_rate, and alpha is the constant 4^w / (4^w  1) where w is the circuit width.
 Parameters
error_rates (dict) – A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of errorrates for gates or SPAM elements, respectively.
num_qubits (int) – The number of qubits in the model.
state_space_labels (StateSpaceLabels or list or tuple) – The decomposition (with labels) of (pure) statespace this model acts upon. Regardless of whether the model contains operators or superoperators, this argument describes the Hilbert space dimension and imposed structure. If a list or tuple is given, it must be of a from that can be passed to StateSpaceLabels.__init__.
alias_dict (dict, optional) – An alias dictionary mapping the gate labels in circuits to the keys of a (nested) error_rates dictionary. This allows, for instance, many gates’ error rates to be set by the same model parameter.
idle_name (str, optional) – The gate name to be used for the 1qubit idle gate (this should be set in error_rates to add idle errors.
 _circuit_cache(self, circuit)¶
 _success_prob(self, circuit, cache)¶
todo
 _success_dprob(self, circuit, param_slice, cache)¶
todo
 class pygsti.models.oplessmodel.AnyErrorCausesFailureModel(error_rates, num_qubits, state_space_labels=None, alias_dict={}, idle_name='Gi')¶
Bases:
ErrorRatesModel
A model where any gate failure causes a circuit failure.
Specifically, the success probability of a circuit is give by 1  prod(1  error_rate_i) where i ranges over all the gates in the circuit. That is, a circuit success probability is just the product of all its gate success probabilities. In this pessimistic model, any gate failure causes the circuit to fail.
 Parameters
error_rates (dict) – A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of errorrates for gates or SPAM elements, respectively.
num_qubits (int) – The number of qubits in the model.
state_space_labels (StateSpaceLabels or list or tuple) – The decomposition (with labels) of (pure) statespace this model acts upon. Regardless of whether the model contains operators or superoperators, this argument describes the Hilbert space dimension and imposed structure. If a list or tuple is given, it must be of a from that can be passed to StateSpaceLabels.__init__.
alias_dict (dict, optional) – An alias dictionary mapping the gate labels in circuits to the keys of a (nested) error_rates dictionary. This allows, for instance, many gates’ error rates to be set by the same model parameter.
idle_name (str, optional) – The gate name to be used for the 1qubit idle gate (this should be set in error_rates to add idle errors.
 _circuit_cache(self, circuit)¶
 _success_prob(self, circuit, cache)¶
 _success_dprob(self, circuit, param_slice, cache)¶
Derived classes can override this. Default implemntation is to use finite difference.
 class pygsti.models.oplessmodel.AnyErrorCausesRandomOutputModel(error_rates, num_qubits, state_space_labels=None, alias_dict={}, idle_name='Gi')¶
Bases:
ErrorRatesModel
A model where any gate error causes a random circuit output.
Specifically, the success probability of a circuit is give by all_ok + (1  all_ok) * 1 / 2^circuit_width where all_ok is the probability that all the gates succeed: all_ok = 1  prod(1  error_rate_i) with i ranging over all the gates in the circuit. In this model, any gate failure causes the circuit to produce a random output.
 Parameters
error_rates (dict) – A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of errorrates for gates or SPAM elements, respectively.
num_qubits (int) – The number of qubits in the model.
state_space_labels (StateSpaceLabels or list or tuple) – The decomposition (with labels) of (pure) statespace this model acts upon. Regardless of whether the model contains operators or superoperators, this argument describes the Hilbert space dimension and imposed structure. If a list or tuple is given, it must be of a from that can be passed to StateSpaceLabels.__init__.
alias_dict (dict, optional) – An alias dictionary mapping the gate labels in circuits to the keys of a (nested) error_rates dictionary. This allows, for instance, many gates’ error rates to be set by the same model parameter.
idle_name (str, optional) – The gate name to be used for the 1qubit idle gate (this should be set in error_rates to add idle errors.
 _circuit_cache(self, circuit)¶
 _success_prob(self, circuit, cache)¶
 _success_dprob(self, circuit, param_slice, cache)¶
todo