1

In the tutorial example of Stim, there is a repetition code example.

The circuit is the following:

stim.Circuit('''
    R 0 1 2 3 4
    TICK
    DEPOLARIZE1(0.04) 0 2 4
    CX 0 1 2 3
    TICK
    CX 2 1 4 3
    TICK
    X_ERROR(0.01) 1 3
    MR 1 3
    DETECTOR(1, 0) rec[-2]
    DETECTOR(3, 0) rec[-1]
    REPEAT 24 {
        TICK
        DEPOLARIZE1(0.04) 0 2 4
        CX 0 1 2 3
        TICK
        CX 2 1 4 3
        TICK
        X_ERROR(0.01) 1 3
        MR 1 3
        SHIFT_COORDS(0, 1)
        DETECTOR(1, 0) rec[-2] rec[-4]
        DETECTOR(3, 0) rec[-1] rec[-3]
    }
    X_ERROR(0.01) 0 2 4
    M 0 2 4
    DETECTOR(1, 1) rec[-2] rec[-3] rec[-5]
    DETECTOR(3, 1) rec[-1] rec[-2] rec[-4]
    OBSERVABLE_INCLUDE(0) rec[-1]
''')

I am confused by the meaning of the lines such as:

DETECTOR(1, 0) rec[-2]

Question 1: What does X and Y mean in Detector (X,Y)?

In the doc it says it represents "coordinates" but what does it mean? I am a beginner in Stim I only know the very basic of the initial tutorial (hence I am looking for a very basic answer).

Question 2: My understanding of a detector is that it should compare the outcome of two measurements and return TRUE if they are not consistent. For instance if Z measurements output 00 or 11, the detector will return False. If the measurement is 01 or 10 it will return True.

  • What does it mean to only put a single measurement outcome in a detector? For instance, the line DETECTOR(1, 0) rec[-2].
  • What does it mean to put more than 2 measurement outcomes in a detector? For instance, the line DETECTOR(1, 0) rec[-2] rec[-4].
Marco Fellous-Asiani
  • 2,220
  • 2
  • 15
  • 42

1 Answers1

2

Question 1: What does X and Y mean in Detector (X,Y)? In the doc it says it represents "coordinates" but what does it mean?

The checks of an error correcting code can be drawn as a Tanner graph. X and Y define the location in the plane to draw the check node that is equivalent to the detector.

What does it mean to only put a single measurement outcome in a detector? For instance, the line DETECTOR(1, 0) rec[-2].

A detector refers to a parity constraint on measurement outcomes. Consider the single qubit circuit: prepare $|0 \rangle$, then measure $M_Z$. If no noise occurs the measurement should always be 0. Therefore one can construct a weight 1 parity constraint: $m_1 = 0$.

What does it mean to put more than 2 measurement outcomes in a detector? For instance, the line DETECTOR(1, 0) rec[-2] rec[-4].

Hopefully an example of a weight 4 stabilizer will help. Consider four qubits being stabilized by $S_Z=Z_1 Z_2 Z_3 Z_4$ and $S_X=X_1 X_2 X_3 X_4$. If you measure the weight four Z-stabilizer, the measurement outcome is deterministic. If you were to measure a single qubit in the Z basis, this measurement would be non-determinist. But if you were to measure all 4 qubit individually, you can combine the measurement results to find the outcome you would've got by measuring $S_Z$ directly. The parity constraint here is $m_1 \oplus m_2 \oplus m_3 \oplus m_4 = 0$.

Peter-Jan
  • 2,163
  • 8
  • 28