pygsti.tools.optools.gateset_infidelity

pygsti.tools.optools.gateset_infidelity#

gateset_infidelity(model, target_model, itype='EI', weights=None, mx_basis=None, is_tp=None, is_unitary=None)#

Computes the average-over-gates of the infidelity between gates in model and the gates in target_model.

If itype is ‘EI’ then the “infidelity” is the entanglement infidelity; if itype is ‘AGI’ then the “infidelity” is the average gate infidelity (AGI and EI are related by a dimension dependent constant).

This is the quantity that RB error rates are sometimes claimed to be related to directly related.

Parameters:
  • model (Model) – The model to calculate the average infidelity, to target_model, of.

  • target_model (Model) – The model to calculate the average infidelity, to model, of.

  • itype (str, optional) – The infidelity type. Either ‘EI’, corresponding to entanglement infidelity, or ‘AGI’, corresponding to average gate infidelity.

  • weights (dict, optional) – If not None, a dictionary of floats, whereby the keys are the gates in model and the values are, possibly unnormalized, probabilities. These probabilities corresponding to the weighting in the average, so if the model contains gates A and B and weights[A] = 2 and weights[B] = 1 then the output is Inf(A)*2/3 + Inf(B)/3 where Inf(X) is the infidelity (to the corresponding element in the other model) of X. If None, a uniform-average is taken, equivalent to setting all the weights to 1.

  • mx_basis ({"std","gm","pp"} or Basis object, optional) – The basis of the models. If None, the basis is obtained from the model.

  • is_tp (bool, optional (default None)) – Flag indicating both matrices are TP. If None (the default), an explicit check is performed. If True/False, the check is skipped and the provided value is used (faster, but should only be used when the user is certain this is true apriori).

  • is_unitary (bool, optional (default None)) – Flag indicating that the second matrix, b, is unitary. If None (the default) an explicit check is performed. If True/False, the check is skipped and the provided value is used (faster, but should only be used when the user is certain this is true apriori).

Returns:

The weighted average-over-gates infidelity between the two models.

Return type:

float