3
$\begingroup$

When I use stim to simulate d=3 Bacon-Shor's code, I can't find the problem with my circuits resulting in the weird DetectorErrorModel. The initialization and stabilizer measurement circuits are as follow: layout

circuits

I focus on $|0\rangle _L$ memory simulation and choose not to use reset after measurement. So with three rounds of stabilizer measurements, the detectors are

...
DETECTOR(0, 0, 0) rec[-4]
DETECTOR(1, 0, 0) rec[-3]
...
SHIFT_COORDS(0, 0, 1)
DETECTOR(0, 0, 0) rec[-4]
DETECTOR(1, 0, 0) rec[-3]
...
SHIFT_COORDS(0, 0, 1)
DETECTOR(0, 0, 0) rec[-4] rec[-8]
DETECTOR(1, 0, 0) rec[-3] rec[-7]
...
DETECTOR(0, 0, 1) rec[-9] rec[-6] rec[-8] rec[-5] rec[-7] rec[-4] rec[-13] rec[-17]
DETECTOR(1, 0, 1) rec[-6] rec[-3] rec[-5] rec[-2] rec[-4] rec[-1] rec[-12] rec[-16]

some error I can't understand appear in auto-generated DetectorErrorModel like D0 D4 L0 ^ D1 D5 ^ L0.

Here is my stim.Circuit file and generated error_model:

circuit.txt

stim.Circuit('''
    R 0 1 2 3 4 5 6 7 8 9 10 11 12
    H 0
    DEPOLARIZE1(0.001) 0
    CX 0 1
    DEPOLARIZE2(0.02) 0 1
    CX 1 2
    DEPOLARIZE2(0.02) 1 2
    H 3
    DEPOLARIZE1(0.001) 3
    CX 3 4
    DEPOLARIZE2(0.02) 3 4
    CX 4 5
    DEPOLARIZE2(0.02) 4 5
    H 6
    DEPOLARIZE1(0.001) 6
    CX 6 7
    DEPOLARIZE2(0.02) 6 7
    CX 7 8
    DEPOLARIZE2(0.02) 7 8
    H 0
    DEPOLARIZE1(0.001) 0
    H 1
    DEPOLARIZE1(0.001) 1
    H 2
    DEPOLARIZE1(0.001) 2
    H 3
    DEPOLARIZE1(0.001) 3
    H 4
    DEPOLARIZE1(0.001) 4
    H 5
    DEPOLARIZE1(0.001) 5
    H 6
    DEPOLARIZE1(0.001) 6
    H 7
    DEPOLARIZE1(0.001) 7
    H 8
    DEPOLARIZE1(0.001) 8 0 1 2 3 4 5 6 7 8
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 11 0
    DEPOLARIZE2(0.02) 11 0
    CX 12 1
    DEPOLARIZE2(0.02) 12 1
    DEPOLARIZE1(0.002) 2 3 4 5 6 7 8
    CX 11 1
    DEPOLARIZE2(0.02) 11 1
    CX 12 2
    DEPOLARIZE2(0.02) 12 2
    DEPOLARIZE1(0.002) 0 3 4 5 6 7 8
    CX 11 3
    DEPOLARIZE2(0.02) 11 3
    CX 12 4
    DEPOLARIZE2(0.02) 12 4
    DEPOLARIZE1(0.002) 0 1 2 5 6 7 8
    CX 11 4
    DEPOLARIZE2(0.02) 11 4
    CX 12 5
    DEPOLARIZE2(0.02) 12 5
    DEPOLARIZE1(0.002) 0 1 2 3 6 7 8
    CX 11 6
    DEPOLARIZE2(0.02) 11 6
    CX 12 7
    DEPOLARIZE2(0.02) 12 7
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 8
    CX 11 7
    DEPOLARIZE2(0.02) 11 7
    CX 12 8
    DEPOLARIZE2(0.02) 12 8
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 6
    DEPOLARIZE1(0.001) 0 1 2 3 4 5 6 7 8
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 0 9
    DEPOLARIZE2(0.02) 0 9
    CX 3 10
    DEPOLARIZE2(0.02) 3 10
    DEPOLARIZE1(0.002) 1 2 4 5 6 7 8 11 12
    CX 3 9
    DEPOLARIZE2(0.02) 3 9
    CX 6 10
    DEPOLARIZE2(0.02) 6 10
    DEPOLARIZE1(0.002) 0 1 2 4 5 7 8 11 12
    CX 1 9
    DEPOLARIZE2(0.02) 1 9
    CX 4 10
    DEPOLARIZE2(0.02) 4 10
    DEPOLARIZE1(0.002) 0 2 3 5 6 7 8 11 12
    CX 4 9
    DEPOLARIZE2(0.02) 4 9
    CX 7 10
    DEPOLARIZE2(0.02) 7 10
    DEPOLARIZE1(0.002) 0 1 2 3 5 6 8 11 12
    CX 2 9
    DEPOLARIZE2(0.02) 2 9
    CX 5 10
    DEPOLARIZE2(0.02) 5 10
    DEPOLARIZE1(0.002) 0 1 3 4 6 7 8 11 12
    CX 5 9
    DEPOLARIZE2(0.02) 5 9
    CX 8 10
    DEPOLARIZE2(0.02) 8 10
    DEPOLARIZE1(0.002) 0 1 2 3 4 6 7 11 12
    DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 7 8
    X_ERROR(0.05) 9
    M 9
    X_ERROR(0.05) 10
    M 10
    X_ERROR(0.05) 11
    M 11
    X_ERROR(0.05) 12
    M 12
    DETECTOR(0, 0, 0) rec[-4]
    DETECTOR(1, 0, 0) rec[-3]
    DEPOLARIZE1(0.001) 0 1 2 3 4 5 6 7 8 9 10
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 11 0
    DEPOLARIZE2(0.02) 11 0
    CX 12 1
    DEPOLARIZE2(0.02) 12 1
    DEPOLARIZE1(0.002) 2 3 4 5 6 7 8 9 10
    CX 11 1
    DEPOLARIZE2(0.02) 11 1
    CX 12 2
    DEPOLARIZE2(0.02) 12 2
    DEPOLARIZE1(0.002) 0 3 4 5 6 7 8 9 10
    CX 11 3
    DEPOLARIZE2(0.02) 11 3
    CX 12 4
    DEPOLARIZE2(0.02) 12 4
    DEPOLARIZE1(0.002) 0 1 2 5 6 7 8 9 10
    CX 11 4
    DEPOLARIZE2(0.02) 11 4
    CX 12 5
    DEPOLARIZE2(0.02) 12 5
    DEPOLARIZE1(0.002) 0 1 2 3 6 7 8 9 10
    CX 11 6
    DEPOLARIZE2(0.02) 11 6
    CX 12 7
    DEPOLARIZE2(0.02) 12 7
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 8 9 10
    CX 11 7
    DEPOLARIZE2(0.02) 11 7
    CX 12 8
    DEPOLARIZE2(0.02) 12 8
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 6 9 10
    DEPOLARIZE1(0.001) 0 1 2 3 4 5 6 7 8 9 10
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 0 9
    DEPOLARIZE2(0.02) 0 9
    CX 3 10
    DEPOLARIZE2(0.02) 3 10
    DEPOLARIZE1(0.002) 1 2 4 5 6 7 8 11 12
    CX 3 9
    DEPOLARIZE2(0.02) 3 9
    CX 6 10
    DEPOLARIZE2(0.02) 6 10
    DEPOLARIZE1(0.002) 0 1 2 4 5 7 8 11 12
    CX 1 9
    DEPOLARIZE2(0.02) 1 9
    CX 4 10
    DEPOLARIZE2(0.02) 4 10
    DEPOLARIZE1(0.002) 0 2 3 5 6 7 8 11 12
    CX 4 9
    DEPOLARIZE2(0.02) 4 9
    CX 7 10
    DEPOLARIZE2(0.02) 7 10
    DEPOLARIZE1(0.002) 0 1 2 3 5 6 8 11 12
    CX 2 9
    DEPOLARIZE2(0.02) 2 9
    CX 5 10
    DEPOLARIZE2(0.02) 5 10
    DEPOLARIZE1(0.002) 0 1 3 4 6 7 8 11 12
    CX 5 9
    DEPOLARIZE2(0.02) 5 9
    CX 8 10
    DEPOLARIZE2(0.02) 8 10
    DEPOLARIZE1(0.002) 0 1 2 3 4 6 7 11 12
    DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 7 8
    X_ERROR(0.05) 9
    M 9
    X_ERROR(0.05) 10
    M 10
    X_ERROR(0.05) 11
    M 11
    X_ERROR(0.05) 12
    M 12
    SHIFT_COORDS(0, 0, 1)
    DETECTOR(0, 0, 0) rec[-4]
    DETECTOR(1, 0, 0) rec[-3]
    DEPOLARIZE1(0.001) 0 1 2 3 4 5 6 7 8 9 10
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 11 0
    DEPOLARIZE2(0.02) 11 0
    CX 12 1
    DEPOLARIZE2(0.02) 12 1
    DEPOLARIZE1(0.002) 2 3 4 5 6 7 8 9 10
    CX 11 1
    DEPOLARIZE2(0.02) 11 1
    CX 12 2
    DEPOLARIZE2(0.02) 12 2
    DEPOLARIZE1(0.002) 0 3 4 5 6 7 8 9 10
    CX 11 3
    DEPOLARIZE2(0.02) 11 3
    CX 12 4
    DEPOLARIZE2(0.02) 12 4
    DEPOLARIZE1(0.002) 0 1 2 5 6 7 8 9 10
    CX 11 4
    DEPOLARIZE2(0.02) 11 4
    CX 12 5
    DEPOLARIZE2(0.02) 12 5
    DEPOLARIZE1(0.002) 0 1 2 3 6 7 8 9 10
    CX 11 6
    DEPOLARIZE2(0.02) 11 6
    CX 12 7
    DEPOLARIZE2(0.02) 12 7
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 8 9 10
    CX 11 7
    DEPOLARIZE2(0.02) 11 7
    CX 12 8
    DEPOLARIZE2(0.02) 12 8
    DEPOLARIZE1(0.002) 0 1 2 3 4 5 6 9 10
    DEPOLARIZE1(0.001) 0 1 2 3 4 5 6 7 8 9 10
    H 11
    DEPOLARIZE1(0.001) 11
    H 12
    DEPOLARIZE1(0.001) 12
    CX 0 9
    DEPOLARIZE2(0.02) 0 9
    CX 3 10
    DEPOLARIZE2(0.02) 3 10
    DEPOLARIZE1(0.002) 1 2 4 5 6 7 8 11 12
    CX 3 9
    DEPOLARIZE2(0.02) 3 9
    CX 6 10
    DEPOLARIZE2(0.02) 6 10
    DEPOLARIZE1(0.002) 0 1 2 4 5 7 8 11 12
    CX 1 9
    DEPOLARIZE2(0.02) 1 9
    CX 4 10
    DEPOLARIZE2(0.02) 4 10
    DEPOLARIZE1(0.002) 0 2 3 5 6 7 8 11 12
    CX 4 9
    DEPOLARIZE2(0.02) 4 9
    CX 7 10
    DEPOLARIZE2(0.02) 7 10
    DEPOLARIZE1(0.002) 0 1 2 3 5 6 8 11 12
    CX 2 9
    DEPOLARIZE2(0.02) 2 9
    CX 5 10
    DEPOLARIZE2(0.02) 5 10
    DEPOLARIZE1(0.002) 0 1 3 4 6 7 8 11 12
    CX 5 9
    DEPOLARIZE2(0.02) 5 9
    CX 8 10
    DEPOLARIZE2(0.02) 8 10
    DEPOLARIZE1(0.002) 0 1 2 3 4 6 7 11 12
    DEPOLARIZE1(0.01) 0 1 2 3 4 5 6 7 8
    X_ERROR(0.05) 9
    M 9
    X_ERROR(0.05) 10
    M 10
    X_ERROR(0.05) 11
    M 11
    X_ERROR(0.05) 12
    M 12
    SHIFT_COORDS(0, 0, 1)
    DETECTOR(0, 0, 0) rec[-4] rec[-8]
    DETECTOR(1, 0, 0) rec[-3] rec[-7]
    X_ERROR(0.05) 0
    M 0
    X_ERROR(0.05) 1
    M 1
    X_ERROR(0.05) 2
    M 2
    X_ERROR(0.05) 3
    M 3
    X_ERROR(0.05) 4
    M 4
    X_ERROR(0.05) 5
    M 5
    X_ERROR(0.05) 6
    M 6
    X_ERROR(0.05) 7
    M 7
    X_ERROR(0.05) 8
    M 8
    DEPOLARIZE1(0.01) 9 10 11 12
    DETECTOR(0, 0, 1) rec[-9] rec[-6] rec[-8] rec[-5] rec[-7] rec[-4] rec[-13] rec[-17]
    DETECTOR(1, 0, 1) rec[-6] rec[-3] rec[-5] rec[-2] rec[-4] rec[-1] rec[-12] rec[-16]
    OBSERVABLE_INCLUDE(0) rec[-9] rec[-8] rec[-7]
''')

error_model.txt

stim.DetectorErrorModel('''
    error(0.07819) D0 D2
    error(0.102128) D0 D4 L0
    error(0.102128) D0 D4 L0 ^ D1 D5 ^ L0
    error(0.0313222) D0 D4 L0 ^ D3 D5 ^ L0
    error(0.07819) D1 D3
    error(0.105303) D1 D5
    error(0.0860003) D2
    error(0.108379) D2 D4 L0
    error(0.117794) D2 D4 L0 ^ D3 D5 ^ L0
    error(0.0159144) D2 D4 L0 ^ D5 ^ L0
    error(0.0860003) D3
    error(0.108379) D3 D5
    error(0.117794) D4 D5
    error(0.0159144) D4 D5 ^ D2
    error(0.07239) D4 D6
    error(0.0313222) D4 D7
    error(0.120844) D4 L0
    error(0.0159144) D4 L0 ^ D2
    error(0.120844) D5
    error(0.07239) D5 D7
    error(0.0159144) D5 ^ D3
    error(0.166418) D6 D7
    error(0.169079) D6 L0
    error(0.0159144) D6 L0 ^ D4 L0
    error(0.166418) D7
    error(0.0159144) D7 ^ D5
    detector(0, 0, 0) D0
    detector(1, 0, 0) D1
    shift_detectors(0, 0, 1) 0
    detector(0, 0, 0) D2
    detector(1, 0, 0) D3
    shift_detectors(0, 0, 1) 0
    detector(0, 0, 0) D4
    detector(1, 0, 0) D5
    detector(0, 0, 1) D6
    detector(1, 0, 1) D7
''')

(Sorry for I did not combine some same-type gates into one line so it's a little uncomfortable to read.) I'm not sure whether I made some mistakes in writing the circuits or there is any error mechanism I'm not aware of.

$\endgroup$

1 Answer 1

2
$\begingroup$

Now that v1.8.0 is out I can use the new explain_detector_error_model_errors feature to find the circuit error causing the symptoms D0 D4 L0 ^ D1 D5 ^ L0:

import stim
circuit = ...your_circuit...

explained = circuit.explain_detector_error_model_errors(
    dem_filter=stim.DetectorErrorModel("""
        error(1) D0 D4 L0 ^ D1 D5 ^ L0
    """),
    reduce_to_one_representative_error=True,
)

print(explained[0].circuit_error_locations[0])

And the simplest way to cause those symptoms is...

CircuitErrorLocation {
    flipped_pauli_product: Z3
    Circuit location stack trace:
        (after 0 TICKs)
        at instruction #9 (DEPOLARIZE1) in the circuit
        at target #1 of the instruction
        resolving to DEPOLARIZE1(0.001) 3
}

A Z error on qubit 3 right after it is hit by a Hadamard in the first layer of Hadamards.

This isn't a logical error, by the way. Keep in mind the two L0 in D0 D4 L0 ^ D1 D5 ^ L0 cancel out. It's a not-so-well decomposed D0 D1 D4 D5.

$\endgroup$
12
  • $\begingroup$ 'Also, you appear to be directly measuring the stabilizers instead of measuring the edges that you're supposed to measure.', Sorry I don't quite understand the meaning of this. Could you explain a bit more? $\endgroup$
    – Inm
    Jan 29 at 7:59
  • $\begingroup$ @Inm The Bacon-Shor code is made up of 2-body parity measurements. The measurements don't all commute with each other, but you can multiply combinations of them together to recover the stabilizers that are actually used. $\endgroup$ Jan 29 at 8:02
  • $\begingroup$ I used the protocol that using one ancilla qubit to make CNOT with other 6 qubits and measure a stabilizer at one time. $\endgroup$
    – Inm
    Jan 29 at 8:05
  • $\begingroup$ Besides, the encoding procedure should be fault-tolerant. The point is that I can't think of an error can result in symptoms D0 D1 D4 D5. When I set only 2 detectors every cycle for Z stabilizer measurement, I think the number of symptoms caused by any single error should be no more than 2. $\endgroup$
    – Inm
    Jan 29 at 8:51
  • 1
    $\begingroup$ @Inn The latest dev release of stim has a match_errors command line mode where it lists the circuit errors that cause dem errors. They'll be a python method for it, soon. Keep in mind you have DEPOLARIZE2 operations, which have a YY term and each Y term can causes two detection events. And furthermore, using six cnots to measure a stabilizer means that if error occurs on the measurement qubit halfway through that process, it will kick out onto three separate data qubits. The only reason you don't have worse errors is there's only four stabilizers to flip! $\endgroup$ Jan 29 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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