# Threshold value when simulating erasures with stim

Did anyone try to simulate erasures with stim and can tell me whether he achieved values that hold with the literature?

I tried an unrotated surface code with erasures at the data qubits initialization and no other errors, and got threshold of ~0.2, far below the expected 0.5 of 2D surface code, and even below the 0.249 of a 3D surface code.

I tried to follow the method described in How do I perform an erasure error in stim?.

Attached here the stim circuit (for d=3). I simulated an unrotated ladder-like surface code, for a Z logical memory. Qubits with integer coordinates are data qubits and measurement ancilla, while qubits with half-integer are the erasure heralding ancillas.

The code and indexing scheme (| for dual data qubit, _ for primal data qubit, s for star syndrome ancilla, and f for face syndrome ancilla):

# Code- indices-
# |f|f| 0,5,10,15,20
# s-s-s 1,6,11,16,21
# |f|f| 2,7,12,17,22
# s-s-s 3,8,13,18,23
# |f|f| 4,9,14,19,24
QUBIT_COORDS(0, 0) 0
QUBIT_COORDS(0.5, 0.5) 25
QUBIT_COORDS(1, 0) 1
QUBIT_COORDS(2, 0) 2
QUBIT_COORDS(2.5, 0.5) 27
QUBIT_COORDS(3, 0) 3
QUBIT_COORDS(4, 0) 4
QUBIT_COORDS(4.5, 0.5) 29
QUBIT_COORDS(0, 1) 5
QUBIT_COORDS(1, 1) 6
QUBIT_COORDS(1.5, 1.5) 31
QUBIT_COORDS(2, 1) 7
QUBIT_COORDS(3, 1) 8
QUBIT_COORDS(3.5, 1.5) 33
QUBIT_COORDS(4, 1) 9
QUBIT_COORDS(0, 2) 10
QUBIT_COORDS(0.5, 2.5) 35
QUBIT_COORDS(1, 2) 11
QUBIT_COORDS(2, 2) 12
QUBIT_COORDS(2.5, 2.5) 37
QUBIT_COORDS(3, 2) 13
QUBIT_COORDS(4, 2) 14
QUBIT_COORDS(4.5, 2.5) 39
QUBIT_COORDS(0, 3) 15
QUBIT_COORDS(1, 3) 16
QUBIT_COORDS(1.5, 3.5) 41
QUBIT_COORDS(2, 3) 17
QUBIT_COORDS(3, 3) 18
QUBIT_COORDS(3.5, 3.5) 43
QUBIT_COORDS(4, 3) 19
QUBIT_COORDS(0, 4) 20
QUBIT_COORDS(0.5, 4.5) 45
QUBIT_COORDS(1, 4) 21
QUBIT_COORDS(2, 4) 22
QUBIT_COORDS(2.5, 4.5) 47
QUBIT_COORDS(3, 4) 23
QUBIT_COORDS(4, 4) 24
QUBIT_COORDS(4.5, 4.5) 49
TICK
R 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 27 29 31 33 35 37 39 41 43 45 47 49
PAULI_CHANNEL_2(0.0025, 0, 0, 0, 0.0025, 0, 0, 0, 0.0025, 0, 0, 0, 0.0025, 0, 0) 0 25 2 27 4 29 6 31 8 33 10 35 12 37 14 39 16 41 18 43 20 45 22 47 24 49
M 25
DETECTOR(0.5, 0.5, 0, 0) rec[-1]
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 29
DETECTOR(4.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 45
DETECTOR(0.5, 4.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 49
DETECTOR(4.5, 4.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE1(0) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
TICK
H 1 3 11 13 21 23
DEPOLARIZE1(0) 1 3 11 13 21 23
TICK
CX 1 2 6 5 3 4 8 7 11 12 13 14 16 15 21 22 18 17 23 24
R 27 31 29 33 37 39 41 47 43 49
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 2 27 6 31 4 29 8 33 12 37 14 39 16 41 22 47 18 43 24 49
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 29
DETECTOR(4.5, 0.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 49
DETECTOR(4.5, 4.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 2 6 5 3 4 8 7 11 12 13 14 16 15 21 22 18 17 23 24
TICK
CX 1 6 10 5 3 8 12 7 11 16 14 9 13 18 20 15 22 17 24 19
R 31 35 33 37 41 39 43 45 47 49
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 6 31 10 35 8 33 12 37 16 41 14 39 18 43 20 45 22 47 24 49
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 45
DETECTOR(0.5, 4.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 49
DETECTOR(4.5, 4.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 6 10 5 3 8 12 7 11 16 14 9 13 18 20 15 22 17 24 19
TICK
CX 0 5 2 7 11 6 4 9 13 8 10 15 21 16 12 17 23 18 14 19
R 25 27 31 29 33 35 41 37 43 39
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 0 25 2 27 6 31 4 29 8 33 10 35 16 41 12 37 18 43 14 39
M 25
DETECTOR(0.5, 0.5, 0, 0) rec[-1]
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 29
DETECTOR(4.5, 0.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 0 5 2 7 11 6 4 9 13 8 10 15 21 16 12 17 23 18 14 19
TICK
CX 1 0 3 2 6 7 11 10 8 9 13 12 21 20 16 17 23 22 18 19
R 25 27 31 35 33 37 45 41 47 43
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 0 25 2 27 6 31 10 35 8 33 12 37 20 45 16 41 22 47 18 43
M 25
DETECTOR(0.5, 0.5, 0, 0) rec[-1]
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 45
DETECTOR(0.5, 4.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 0 3 2 6 7 11 10 8 9 13 12 21 20 16 17 23 22 18 19
SHIFT_COORDS(0, 0, 0, -5)
TICK
H 1 3 11 13 21 23
DEPOLARIZE1(0) 1 3 11 13 21 23
TICK
M(0) 1 3 11 13 21 23 5 7 9 15 17 19
DETECTOR(4, 3, 0) rec[-1]
DETECTOR(2, 3, 0) rec[-2]
DETECTOR(0, 3, 0) rec[-3]
DETECTOR(4, 1, 0) rec[-4]
DETECTOR(2, 1, 0) rec[-5]
DETECTOR(0, 1, 0) rec[-6]
REPEAT 3 {
TICK
R 1 3 11 13 21 23 5 7 9 15 17 19
DEPOLARIZE1(0) 1 3 11 13 21 23 5 7 9 15 17 19
TICK
H 1 3 11 13 21 23
DEPOLARIZE1(0) 1 3 11 13 21 23
SHIFT_COORDS(0, 0, 1, 0)
TICK
CX 1 2 6 5 3 4 8 7 11 12 13 14 16 15 21 22 18 17 23 24
R 27 31 29 33 37 39 41 47 43 49
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 2 27 6 31 4 29 8 33 12 37 14 39 16 41 22 47 18 43 24 49
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 29
DETECTOR(4.5, 0.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 49
DETECTOR(4.5, 4.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 2 6 5 3 4 8 7 11 12 13 14 16 15 21 22 18 17 23 24
TICK
CX 1 6 10 5 3 8 12 7 11 16 14 9 13 18 20 15 22 17 24 19
R 31 35 33 37 41 39 43 45 47 49
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 6 31 10 35 8 33 12 37 16 41 14 39 18 43 20 45 22 47 24 49
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 45
DETECTOR(0.5, 4.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 49
DETECTOR(4.5, 4.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 6 10 5 3 8 12 7 11 16 14 9 13 18 20 15 22 17 24 19
TICK
CX 0 5 2 7 11 6 4 9 13 8 10 15 21 16 12 17 23 18 14 19
R 25 27 31 29 33 35 41 37 43 39
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 0 25 2 27 6 31 4 29 8 33 10 35 16 41 12 37 18 43 14 39
M 25
DETECTOR(0.5, 0.5, 0, 0) rec[-1]
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 29
DETECTOR(4.5, 0.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
M 39
DETECTOR(4.5, 2.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 0 5 2 7 11 6 4 9 13 8 10 15 21 16 12 17 23 18 14 19
TICK
CX 1 0 3 2 6 7 11 10 8 9 13 12 21 20 16 17 23 22 18 19
R 25 27 31 35 33 37 45 41 47 43
PAULI_CHANNEL_2(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) 0 25 2 27 6 31 10 35 8 33 12 37 20 45 16 41 22 47 18 43
M 25
DETECTOR(0.5, 0.5, 0, 0) rec[-1]
M 27
DETECTOR(2.5, 0.5, 0, 0) rec[-1]
M 31
DETECTOR(1.5, 1.5, 0, 0) rec[-1]
M 35
DETECTOR(0.5, 2.5, 0, 0) rec[-1]
M 33
DETECTOR(3.5, 1.5, 0, 0) rec[-1]
M 37
DETECTOR(2.5, 2.5, 0, 0) rec[-1]
M 45
DETECTOR(0.5, 4.5, 0, 0) rec[-1]
M 41
DETECTOR(1.5, 3.5, 0, 0) rec[-1]
M 47
DETECTOR(2.5, 4.5, 0, 0) rec[-1]
M 43
DETECTOR(3.5, 3.5, 0, 0) rec[-1]
SHIFT_COORDS(0, 0, 0, 1)
DEPOLARIZE2(0) 1 0 3 2 6 7 11 10 8 9 13 12 21 20 16 17 23 22 18 19
SHIFT_COORDS(0, 0, 0, -4)
TICK
H 1 3 11 13 21 23
DEPOLARIZE1(0) 1 3 11 13 21 23
TICK
M(0) 1 3 11 13 21 23 5 7 9 15 17 19
DETECTOR(4, 3, 0) rec[-1] rec[-53]
DETECTOR(2, 3, 0) rec[-2] rec[-54]
DETECTOR(0, 3, 0) rec[-3] rec[-55]
DETECTOR(4, 1, 0) rec[-4] rec[-56]
DETECTOR(2, 1, 0) rec[-5] rec[-57]
DETECTOR(0, 1, 0) rec[-6] rec[-58]
DETECTOR(3, 4, 0) rec[-7] rec[-59]
DETECTOR(1, 4, 0) rec[-8] rec[-60]
DETECTOR(3, 2, 0) rec[-9] rec[-61]
DETECTOR(1, 2, 0) rec[-10] rec[-62]
DETECTOR(3, 0, 0) rec[-11] rec[-63]
DETECTOR(1, 0, 0) rec[-12] rec[-64]
}
TICK
SHIFT_COORDS(0, 0, 1, 0)
M(0) 0 2 4 10 12 14 20 22 24 6 8 16 18
DETECTOR(0, 1, 0) rec[-19] rec[-4] rec[-10] rec[-13]
DETECTOR(2, 1, 0) rec[-18] rec[-3] rec[-9] rec[-12] rec[-4]
DETECTOR(4, 1, 0) rec[-17] rec[-8] rec[-11] rec[-3]
DETECTOR(0, 3, 0) rec[-16] rec[-2] rec[-7] rec[-10]
DETECTOR(2, 3, 0) rec[-15] rec[-1] rec[-6] rec[-9] rec[-2]
DETECTOR(4, 3, 0) rec[-14] rec[-5] rec[-8] rec[-1]
OBSERVABLE_INCLUDE(0) rec[-13] rec[-12] rec[-11]
• Please provide the circuit that you simulated. Commented Feb 7, 2023 at 5:24
• Which decoder are you using? Did you check the distance of your circuit? You can use stim.Circuit.shortest_graphlike_error() for this. Commented Feb 7, 2023 at 9:15
• How can I add my code? Commented Feb 12, 2023 at 15:49
• quantumcomputing.stackexchange.com/editing-help#code
– hft
Commented Feb 12, 2023 at 19:29
• @Peter-Jan, the distance according to stim.Circuit.shortest_graphlike_error() is fine. I am using sinter (stim and pymatching). Commented Feb 13, 2023 at 9:06

## 1 Answer

Please find this paper for threshold results when erasures are simulated using STIM: https://arxiv.org/abs/2210.15024 The error model is for trapped-ion gates so a little complicated, but you can just look at the erasure conversion rate $$R_e$$.