pygsti.models.oplessmodel
Defines the OplessModel class
Module Contents
Classes
A model that does not have independent component operations. |
|
An op-less model that always outputs 2 (success & failure) probabilities for each circuit. |
|
A success-fail model based on per-gate error rates. |
|
A model where twirled-layer error rates are computed and multiplied together to compute success probabilities. |
|
A model where twirled-gate 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.ModelA 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 gate-level modeling.Parameters
- state_spaceStateSpace
The state space of this model.
- property dim
- property parameter_bounds
Upper and lower bounds on the values of each parameter, utilized by optimization routines
- basis = 'None'
- abstractmethod circuit_outcomes(circuit)
Get all the possible outcome labels produced by simulating this circuit.
Parameters
- circuitCircuit
Circuit to get outcomes of.
Returns
tuple
- abstractmethod probabilities(circuit, outcomes=None, time=None)
Construct a dictionary containing the outcome probabilities of circuit.
Parameters
- circuitCircuit or tuple of operation labels
The sequence of operation labels specifying the circuit.
- outcomeslist or tuple
A sequence of outcomes, which can themselves be either tuples (to include intermediate measurements) or simple strings, e.g. ‘010’.
- timefloat, optional
The start time at which circuit is evaluated.
Returns
- probsOutcomeLabelDict
A dictionary with keys equal to outcome labels and values equal to probabilities.
- abstractmethod bulk_probabilities(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
CircuitOutcomeProbabilityArrayLayoutspecifies 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_to2-tuple, optional
(min,max) to clip return value if not None.
- commmpi4py.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_limitint, optional
A rough memory limit in bytes which is used to determine processor allocation.
- smartcSmartCache, optional
A cache object to cache & use previously cached values inside this function.
Returns
- probsdictionary
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.SuccessFailModel(state_space, use_cache=False)
Bases:
OplessModelAn op-less model that always outputs 2 (success & failure) probabilities for each circuit.
Parameters
- state_spaceStateSpace
The state space of this model.
- use_cachebool, optional
Whether a cache should be used to increase performance.
- property sim
Forward simulator for this model
- use_cache = 'False'
- circuit_outcomes(circuit)
Get all the possible outcome labels produced by simulating this circuit.
Parameters
- circuitCircuit
Circuit to get outcomes of.
Returns
tuple
- probabilities(circuit, outcomes=None, time=None)
Construct a dictionary containing the outcome probabilities of circuit.
Parameters
- circuitCircuit or tuple of operation labels
The sequence of operation labels specifying the circuit.
- outcomeslist or tuple
A sequence of outcomes, which can themselves be either tuples (to include intermediate measurements) or simple strings, e.g. ‘010’.
- timefloat, optional
The start time at which circuit is evaluated.
Returns
- probsOutcomeLabelDict
A dictionary with keys equal to outcome labels and values equal to probabilities.
- bulk_probabilities(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
CircuitOutcomeProbabilityArrayLayoutspecifies 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_to2-tuple, optional
(min,max) to clip return value if not None.
- commmpi4py.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_limitint, optional
A rough memory limit in bytes which is used to determine processor allocation.
- smartcSmartCache, optional
A cache object to cache & use previously cached values inside this function.
Returns
- probsdictionary
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=None, idle_name='Gi')
Bases:
SuccessFailModelA success-fail model based on per-gate error rates.
Parameters
- error_ratesdict
A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of error-rates for gates or SPAM elements, respectively.
- num_qubitsint
The number of qubits in the model.
- state_space_labelsStateSpaceLabels or list or tuple
The decomposition (with labels) of (pure) state-space 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_dictdict, 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_namestr, optional
The gate name to be used for the 1-qubit idle gate (this should be set in error_rates to add idle errors.
- property primitive_op_labels
- property primitive_instrument_labels
- to_dict()
Convert this model to a dictionary (for debugging or easy printing).
- class pygsti.models.oplessmodel.TwirledLayersModel(error_rates, num_qubits, state_space_labels=None, alias_dict=None, idle_name='Gi')
Bases:
ErrorRatesModelA model where twirled-layer 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_ratesdict
A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of error-rates for gates or SPAM elements, respectively.
- num_qubitsint
The number of qubits in the model.
- state_space_labelsStateSpaceLabels or list or tuple
The decomposition (with labels) of (pure) state-space 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_dictdict, 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_namestr, optional
The gate name to be used for the 1-qubit idle gate (this should be set in error_rates to add idle errors.
- class pygsti.models.oplessmodel.TwirledGatesModel(error_rates, num_qubits, state_space_labels=None, alias_dict=None, idle_name='Gi')
Bases:
ErrorRatesModelA model where twirled-gate 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_ratesdict
A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of error-rates for gates or SPAM elements, respectively.
- num_qubitsint
The number of qubits in the model.
- state_space_labelsStateSpaceLabels or list or tuple
The decomposition (with labels) of (pure) state-space 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_dictdict, 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_namestr, optional
The gate name to be used for the 1-qubit idle gate (this should be set in error_rates to add idle errors.
todo
- class pygsti.models.oplessmodel.AnyErrorCausesFailureModel(error_rates, num_qubits, state_space_labels=None, alias_dict=None, idle_name='Gi')
Bases:
ErrorRatesModelA 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_ratesdict
A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of error-rates for gates or SPAM elements, respectively.
- num_qubitsint
The number of qubits in the model.
- state_space_labelsStateSpaceLabels or list or tuple
The decomposition (with labels) of (pure) state-space 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_dictdict, 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_namestr, optional
The gate name to be used for the 1-qubit idle gate (this should be set in error_rates to add idle errors.
- class pygsti.models.oplessmodel.AnyErrorCausesRandomOutputModel(error_rates, num_qubits, state_space_labels=None, alias_dict=None, idle_name='Gi')
Bases:
ErrorRatesModelA 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_ratesdict
A dictionary with “gates” and “readout” keys, each of which corresponds to a dictionary of error-rates for gates or SPAM elements, respectively.
- num_qubitsint
The number of qubits in the model.
- state_space_labelsStateSpaceLabels or list or tuple
The decomposition (with labels) of (pure) state-space 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_dictdict, 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_namestr, optional
The gate name to be used for the 1-qubit idle gate (this should be set in error_rates to add idle errors.