I would like to check I precisely understand the definition of what a detector does in Stim. Below is my understanding and I am looking for confirmation that I understood correctly. If not, please correct me.

My current understanding of how detector work by definition:

I call $\{x_i\}_i$ a family of qubit measurement outcomes. We have $x_i \in \{0,1\}$.

A detector takes as input a family of measurements $\{x_i \}_{i=1}^N$.

Then, one considers two circuits: one with the noise "off". In this case, the family of measurement outcomes will be $\{x^{\text{no noise}}_i \}_{i=1}^N$.

The other family is with the noise "on". In this case, the family of measurement outcomes will be $\{x^{\text{noise}}_i \}_{i=1}^N$.

If the sum (modulo 2) $x^{\text{no noise}}_1 \oplus x^{\text{no noise}}_2 \oplus ... \oplus x^{\text{no noise}}_N=x^{\text{noise}}_1 \oplus x^{\text{noise}}_2 \oplus ... \oplus x^{\text{noise}}_N$, then, the detector returns FALSE. If not, it returns TRUE.

To give an example, the command DETECTOR rec[-1] rec[-2] rec[-3] (i) computes the sum of the last 3 measurements for a noiseless circuit run and compares it to the sum of the measurements of the noisy circuit run. It returns FALSE if they agree, TRUE if they disagree.

Am I correct?


1 Answer 1


Yes, this is a good definition of a detector. Note that the binary sum of a set of measurement outcomes needs to be deterministic to be able to use it as a detector. For example, a single measurement outcome from measuring a qubit in the state $|0>$ in the + basis can't be used as a detector. But if the measurement is done in the computational basis one can define a detector: $m_1 = 0$.

  • 1
    $\begingroup$ Great thanks. Just to be sure: in principle one can define a detector based on non-deterministic measurements (like the measurement you say). However it is just that the outcome of the detector will be useless for practical purposes: one could not really interpret the meaning of FALSE/TRUE because they could not be implied by the noise but rather by the inherent probabilistic nature of measurements. Would you agree? $\endgroup$ Mar 13 at 15:51
  • 1
    $\begingroup$ Yes I agree. But I would choose a definition of detector which does not allow for such a choice. $\endgroup$
    – Peter-Jan
    Mar 13 at 15:52
  • $\begingroup$ Technically stim allows non-deterministic detectors; but you need to pass allow_gauge_detectors=True to stim.Circuit.detector_error_model for it to work. What it does, essentially, is turn every anticommutation into a 50% error mechanism by using Gaussian elimination. But I recommend not using this feature. $\endgroup$ Mar 13 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.