pygsti.extras.idletomography.idttools

Idle Tomography utility routines

Module Contents

Functions

alloutcomes(prep, meas, maxweight)

Lists every "error bit string" that co1uld be caused by an error of weight

allerrors(nqubits, maxweight)

Lists every Pauli error operator for nqubits qubits with weight <= maxweight

allobservables(meas, maxweight)

Lists every weight <= maxweight observable whose expectation value can be

tile_pauli_fidpairs(base_fidpairs, nqubits, maxweight)

Tiles a set of base fiducial pairs on maxweight qubits to a

nontrivial_paulis(wt)

List all nontrivial paulis of given weight wt.

set_idle_errors(nqubits, model, errdict, rand_default=None, hamiltonian=True, stochastic=True, affine=True)

Set specific or random error terms (typically for a data-generating model)

extract_idle_errors(nqubits, model, hamiltonian=True, stochastic=True, affine=True, scale_for_idt=True)

Get error rates on the global idle operation withina CloudNoiseModel object.

predicted_intrinsic_rates(nqubits, maxweight, model, hamiltonian=True, stochastic=True, affine=True)

Get the exact intrinsic rates that would be produced by simulating model

predicted_observable_rates(idtresults, typ, nqubits, maxweight, model)

Get the exact observable rates that would be produced by simulating

pygsti.extras.idletomography.idttools.alloutcomes(prep, meas, maxweight)

Lists every “error bit string” that co1uld be caused by an error of weight up to maxweight when performing prep & meas (must be in same basis, but may have different signs).

Parameters
Returns

list – A list of NQOutcome objects.

pygsti.extras.idletomography.idttools.allerrors(nqubits, maxweight)

Lists every Pauli error operator for nqubits qubits with weight <= maxweight

Parameters
  • nqubits (int) –

  • maxweight (int) –

Returns

list – A list of NQPauliOp objects.

pygsti.extras.idletomography.idttools.allobservables(meas, maxweight)

Lists every weight <= maxweight observable whose expectation value can be extracted from the local Pauli measurement described by meas.

Parameters
Returns

list – A list of NQPauliOp objects.

pygsti.extras.idletomography.idttools.tile_pauli_fidpairs(base_fidpairs, nqubits, maxweight)

Tiles a set of base fiducial pairs on maxweight qubits to a set of fiducial pairs on nqubits qubits such that every set of maxweight qubits takes on the values in each base pair in at least one of the returned pairs.

Parameters
  • base_fidpairs (list) – A list of 2-tuples of NQPauliState objects (on maxweight qubits).

  • nqubits (int) – The number of qubits.

  • maxweight (int) – The maximum weight errors the base qubits are meant to detect. Equal to the number of qubits in the base pairs.

Returns

list – A list of 2-tuples of NQPauliState objects (on nqubits qubits).

pygsti.extras.idletomography.idttools.nontrivial_paulis(wt)

List all nontrivial paulis of given weight wt.

Parameters

wt (int) –

Returns

list – A list of tuples of ‘X’, ‘Y’, and ‘Z’, e.g. (‘X’,’Z’).

pygsti.extras.idletomography.idttools.set_idle_errors(nqubits, model, errdict, rand_default=None, hamiltonian=True, stochastic=True, affine=True)

Set specific or random error terms (typically for a data-generating model) within a noise model (a CloudNoiseModel object).

Parameters
  • nqubits (int) – The number of qubits.

  • model (CloudNoiseModel) – The model, to set the idle errors of.

  • errdict (dict) – A dictionary of errors to include. Keys are “S(<>)”, “H(<>)”, and “A(<>)” where <> is a string of ‘X’,’Y’,’Z’,and ‘I’ (e.g. “S(XIZ)”) and values are floating point error rates.

  • rand_default (float or numpy array, optional) – Random error rates to insert into values not specified in errdict. If a floating point number, a random value between 0 and rand_default is used. If an array, then values are taken directly and sequentially from this array (typically of random rates). The array must be long enough to provide values for all unspecified rates.

  • hamiltonian (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • stochastic (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • affine (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

Returns

numpy.ndarray – The random rates the were used.

pygsti.extras.idletomography.idttools.extract_idle_errors(nqubits, model, hamiltonian=True, stochastic=True, affine=True, scale_for_idt=True)

Get error rates on the global idle operation withina CloudNoiseModel object.

Parameters
  • nqubits (int) – The number of qubits.

  • model (CloudNoiseModel) – The model, to get the idle errors of.

  • hamiltonian (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • stochastic (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • affine (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • scale_for_idt (bool, optional) – Whether rates should be scaled to match the intrinsic rates output by idle tomography. If False, then the rates are simply the coefficients of corresponding terms in the error generator.

Returns

hamiltonian_rates, stochastic_rates, affine_rates (dict) – Dictionaries of error rates. Keys are Pauli labels of length nqubits, e.g. “XIX”, “IIX”, “XZY”. Only nonzero rates are returned.

pygsti.extras.idletomography.idttools.predicted_intrinsic_rates(nqubits, maxweight, model, hamiltonian=True, stochastic=True, affine=True)

Get the exact intrinsic rates that would be produced by simulating model (for comparison with idle tomography results).

Parameters
  • nqubits (int) – The number of qubits.

  • maxweight (int, optional) – The maximum weight of errors to consider.

  • model (CloudNoiseModel) – The model to extract intrinsic error rates from.

  • hamiltonian (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • stochastic (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

  • affine (bool, optional) – Whether model includes Hamiltonian, Stochastic, and/or Affine errors (e.g. if the model was built with “H+S” parameterization, then only hamiltonian and stochastic should be set to True).

Returns

ham_intrinsic_rates, sto_intrinsic_rates, aff_intrinsic_rates (numpy.ndarray) – Arrays of intrinsic rates. None if corresponding hamiltonian, stochastic or affine is set to False.

pygsti.extras.idletomography.idttools.predicted_observable_rates(idtresults, typ, nqubits, maxweight, model)

Get the exact observable rates that would be produced by simulating model (for comparison with idle tomography results).

Parameters
  • idtresults (IdleTomographyResults) – The idle tomography results object used to determing which observable rates should be computed, and the provider of the Jacobian relating the intrinsic rates internal to model to these observable rates.

  • typ ({"samebasis","diffbasis"}) – The type of observable rates to predict and return.

  • nqubits (int) – The number of qubits.

  • maxweight (int) – The maximum weight of errors to consider.

  • model (CloudNoiseModel) – The noise model to extract error rates from.

Returns

rates (dict) – A dictionary of the form: rate = rates[pauli_fidpair][obsORoutcome], to match the structure of an IdleTomographyResults object’s `