pygsti.forwardsims.weakforwardsim

Defines the WeakForwardSimulator calculator class

Module Contents

Classes

WeakForwardSimulator

A calculator of circuit outcome probabilities from a "weak" forward simulator

class pygsti.forwardsims.weakforwardsim.WeakForwardSimulator(shots, model=None)

Bases: pygsti.forwardsims.forwardsim.ForwardSimulator

A calculator of circuit outcome probabilities from a “weak” forward simulator (i.e. probabilites taken as average frequencies over a number of “shots”).

Due to their ability to only sample outcome probabilities, WeakForwardSimulators rely heavily on implementing the _compute_sparse_circuit_outcome_probabilities function of ForwardSimulators.

abstract _compute_circuit_outcome_for_shot(self, spc_circuit, resource_alloc, time=None)

Compute outcome for a single shot of a circuit.

Parameters
  • spc_circuit (SeparatePOVMCircuit) – A tuple-like object of simplified gates (e.g. may include instrument elements like ‘Imyinst_0’) generated by Circuit.expand_instruments_and_separate_povm()

  • resource_alloc (ResourceAlloc) – Currently not used

  • time (float, optional) – The start time at which circuit is evaluated.

Returns

outcome_label (tuple) – An outcome label for the single shot sampled

_compute_sparse_circuit_outcome_probabilities(self, circuit, resource_alloc, time=None)
_compute_circuit_outcome_probabilities(self, array_to_fill, circuit, outcomes, resource_alloc, time=None)
bulk_probs(self, circuits, clip_to=None, resource_alloc=None, smartc=None)

Construct a dictionary containing the probabilities for an entire list of circuits.

Parameters
  • circuits (list of Circuits) – The list of circuits. May also be a CircuitOutcomeProbabilityArrayLayout object containing pre-computed quantities that make this function run faster.

  • clip_to (2-tuple, optional) – (min,max) to clip return value if not None.

  • resource_alloc (ResourceAllocation, optional) – A resource allocation object describing the available resources and a strategy for partitioning them.

  • smartc (SmartCache, optional) – A cache object to cache & use previously cached values inside this function.

Returns

probs (dictionary) – A dictionary such that probs[circuit] is an ordered dictionary of outcome probabilities whose keys are outcome labels.