sf.lab.ThresholdDetector

class mrmustard.lab.ThresholdDetector(efficiency=1.0, dark_count_prob=0.0, efficiency_trainable=False, dark_count_prob_trainable=False, efficiency_bounds=(0.0, 1.0), dark_count_prob_bounds=(0.0, None), stochastic_channel=None, modes=None)[source]

Bases: Parametrized, FockMeasurement

Threshold detector: any Fock component other than vacuum counts toward a click in the detector.

If len(modes) > 1 the detector is applied in parallel to all of the modes provided.

If a parameter is a single float, its value is applied to all of the parallel instances of the detector.

To apply mode-specific values use a list of floats.

It can be supplied the full conditional detection probabilities, or it will compute them from the quantum efficiency (binomial) and the dark count probability (bernoulli).

Parameters:
  • efficiency (float or List[float]) – list of quantum efficiencies for each detector

  • dark_count_prob (float or List[float]) – list of dark count probabilities for each detector

  • efficiency_trainable (bool) – whether the efficiency is trainable

  • dark_count_prob_trainable (bool) – whether the dark count probabilities are trainable

  • efficiency_bounds (Tuple[float, float]) – bounds for the efficiency

  • dark_count_prob_bounds (Tuple[float, float]) – bounds for the dark count probabilities

  • stochastic_channel (Optional 2d array) – if supplied, this stochastic_channel will be used for belief propagation

  • modes (Optional List[int]) – list of modes to apply the detector to

constant_parameters

Return a list of constant parameters within the Parametrized object by recursively traversing the object's fields

trainable_parameters

Return a list of trainable parameters within the Parametrized object by recursively traversing the object's fields

constant_parameters

Return a list of constant parameters within the Parametrized object by recursively traversing the object’s fields

Return type:

List[Constant]

trainable_parameters

Return a list of trainable parameters within the Parametrized object by recursively traversing the object’s fields

Return type:

Sequence[Trainable]

primal(state)

Returns a tensor representing the post-measurement state in the unmeasured modes in the Fock basis.

recompute_stochastic_channel([cutoffs])

recompute belief using the defined stochastic channel

should_recompute_stochastic_channel()

Returns True if the stochastic channel has to be recomputed.

primal(state)

Returns a tensor representing the post-measurement state in the unmeasured modes in the Fock basis. The first N indices of the returned tensor correspond to the Fock measurements of the N modes that the detector is measuring. The remaining indices correspond to the density matrix of the unmeasured modes.

Args

state (State): the quatum state

Returns

Tensor: a tensor representing the post-measurement state

Return type:

TypeVar(Tensor)

recompute_stochastic_channel(cutoffs=None)[source]

recompute belief using the defined stochastic channel

should_recompute_stochastic_channel()[source]

Returns True if the stochastic channel has to be recomputed.

This method should be overriden by subclasses accordingly.