0
$\begingroup$

The following is a part of the syndrome measurement circuit for Steane's seven qubit code in Stim(For ease of viewing, the TICK is omitted.). Since we are considering the detection of X errors, we use the measurement results of the Z stabilizers' ancilla. Circuit_1 is a circuit that constructs the CNOTs of the Z stabilizer circuit after configuring the CNOTs of the X stabilizer circuit, and since it is a circuit with no errors, the results of DETECTOR in circuit_1 will always be False, which is the desired result. On the other hand, when considering circuit_2, which is a circuit designed to reduce the overall circuit depth by cleverly arranging the order of CNOTs, the CNOT operations are the same as in circuit_1, but the result of qubit 12 becomes random. Why is this happening?

circuit_1=stim.Circuit('''

    #encode into code state
    MPP X3*X4*X5*X6
    MPP X1*X2*X5*X6
    MPP X0*X2*X4*X6
    
    #ancilla of X stabilizers
    RX 7 8 9 
    
    #ancilla of Z stabilizers
    R 10 11 12 
    
    #CNOT of X stabilizers
    CX 7 6 8 5
    CX 7 2 8 1
    CX 7 4 8 6
    CX 7 0 8 2 9 5
    CX 9 6
    CX 9 3
    CX 9 4
    
    #CNOT of Z stabilizers
    CX 6 12
    CX 3 12
    CX 4 12
    CX 6 10 5 11
    CX 2 10 1 11
    CX 4 10 6 11    
    CX 0 10 2 11 5 12
    
    #measurement of stabilizers
    MRX 7 8 9
    MR 10 11 12
    DETECTOR rec[-3]
    DETECTOR rec[-2]
    DETECTOR rec[-1]

''')
circuit_2=stim.Circuit('''

    MPP X3*X4*X5*X6
    MPP X1*X2*X5*X6
    MPP X0*X2*X4*X6

    RX 7 8 9 
    R 10 11 12 

    CX 7 6 8 5
    CX 7 2 8 1 6 12
    CX 7 4 8 6 3 12
    CX 7 0 8 2 9 5 4 12
    CX 6 10 5 11
    CX 9 6 2 10 1 11
    CX 9 3 4 10 6 11    
    CX 9 4 0 10 2 11 5 12

    MRX 7 8 9
    MR 10 11 12
    DETECTOR rec[-3]
    DETECTOR rec[-2]
    DETECTOR rec[-1]

''')
```
$\endgroup$

2 Answers 2

0
$\begingroup$

I can't read your circuits, unfortunately. But if rearranging changes the outcome of your circuit, then the gates do not all commute.

$\endgroup$
0
$\begingroup$

It doesn't work because you've rearrange your circuit as if the CNOT gates don't interact with each other, but they do.

Here is what you should do:

  1. Add the missing three detectors to your circuit, comparing the X stabilizer measurements at the end to the ones at the start. You also want to be checking the X stabilizers, to prevent mistakes.
  2. Run circuit.detector_error_model() on the circuit. It checks that all the detectors are actually deterministic. It should finish without throwing an exception.
  3. Move ONE CNOT gate ONE step.
  4. Run circuit.detector_error_model() on the circuit. If it throws an exception, you just made a mistake. Don't move that CNOT that way. Put it back. Otherwise it's okay.
  5. Goto step (2).
  6. Start making multi-step moves. Some things can only be achieved by travelling through wrongspace; making more than one change at a time.

Note you can use circuit.diagram() to get a text diagram of the circuit, or circuit.diagram('timeline-svg') to get a picture diagram of the circuit, and if you add TICKs between layers then you can use circuit.diagram('detslice-with-ops-svg') to get the progression of the stabilizers corresponding to the detecting regions. That last one requires you to give decent qubit coordinates, so it doesn't just draw it on a line.

import stim
circuit_1=stim.Circuit('''
    QUBIT_COORDS(0, 0) 0
    QUBIT_COORDS(5, 0) 2
    QUBIT_COORDS(0, 5) 4
    QUBIT_COORDS(5, 5) 6
    QUBIT_COORDS(7, 7) 5
    QUBIT_COORDS(2, 7) 3
    QUBIT_COORDS(7, 2) 1
    QUBIT_COORDS(2.5, 2.5, 0) 7
    QUBIT_COORDS(6, 3.5, 0) 8
    QUBIT_COORDS(3.5, 6, 0) 9
    QUBIT_COORDS(2.5, 2.5, 1) 10
    QUBIT_COORDS(6, 3.5, 1) 11
    QUBIT_COORDS(3.5, 6, 1) 12

    #encode into code state
    MPP X3*X4*X5*X6
    MPP X1*X2*X5*X6
    MPP X0*X2*X4*X6
    TICK
    TICK
    
    #ancilla of X stabilizers
    RX 7 8 9 
    
    #ancilla of Z stabilizers
    R 10 11 12 
    TICK
    
    #CNOT of X stabilizers
    CX 7 6 8 5
    TICK
    CX 7 2 8 1
    TICK
    CX 7 4 8 6
    TICK
    CX 7 0 8 2 9 5
    TICK
    CX 9 6
    TICK
    CX 9 3
    TICK
    CX 9 4
    TICK
    
    #CNOT of Z stabilizers
    CX 6 12
    TICK
    CX 3 12
    TICK
    CX 4 12
    TICK
    CX 6 10 5 11
    TICK
    CX 2 10 1 11
    TICK
    CX 4 10 6 11    
    TICK
    CX 0 10 2 11 5 12
    TICK
    
    #measurement of stabilizers
    MRX 7 8 9
    MR 10 11 12
    DETECTOR rec[-3]
    DETECTOR rec[-2]
    DETECTOR rec[-1]
    DETECTOR rec[-4] rec[-9]
    DETECTOR rec[-5] rec[-8]
    DETECTOR rec[-6] rec[-7]
''')
circuit_1.diagram()
      /---------------------------------------------------------------\      /-\ /-\ /-\ /---\             /-\ /-\ /-\ /---\ /----------------------------------\
 q0: -QUBIT_COORDS(0,0)-----------------------------------MPP[X]:rec[2]------------------X-----------------------------@----------------DETECTOR:D5=rec[3]*rec[2]-
                                                          |                              |                             |
 q1: -QUBIT_COORDS(7,2)---------------------MPP[X]:rec[1]-|------------------------X-----|-----------------------@-----|----------------DETECTOR:D4=rec[4]*rec[1]-
                                            |             |                        |     |                       |     |
 q2: -QUBIT_COORDS(5,0)---------------------MPP[X]:rec[1]-MPP[X]:rec[2]----------X-|-----|-X-------------------@-|-----|-@----------------------------------------
                                            |             |                      | |     | |                   | |     | |
 q3: -QUBIT_COORDS(2,7)-------MPP[X]:rec[0]-|-------------|----------------------|-|-----|-|-----X-----@-------|-|-----|-|--------------DETECTOR:D3=rec[5]*rec[0]-
                              |             |             |                      | |     | |     |     |       | |     | |
 q4: -QUBIT_COORDS(0,5)-------MPP[X]:rec[0]-|-------------MPP[X]:rec[2]----------|-|-X---|-|-----|-X---|-@-----|-|-@---|-|----------------------------------------
                              |             |             |                      | | |   | |     | |   | |     | | |   | |
 q5: -QUBIT_COORDS(7,7)-------MPP[X]:rec[0]-MPP[X]:rec[1]-|--------------------X-|-|-|---|-|-X---|-|---|-|---@-|-|-|---|-|-@--------------------------------------
                              |             |             |                    | | | |   | | |   | |   | |   | | | |   | | |
 q6: -QUBIT_COORDS(5,5)-------MPP[X]:rec[0]-MPP[X]:rec[1]-MPP[X]:rec[2]------X-|-|-|-|-X-|-|-|-X-|-|-@-|-|-@-|-|-|-|-@-|-|-|--------------------------------------
                                                                             | | | | | | | | | | | | | | | | | | | | | | | |
 q7: -QUBIT_COORDS(2.5,2.5,0)---------------------------------------------RX-@-|-@-|-@-|-@-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-MRX:rec[3]---------------------------
                                                                               |   |   |   | | | | | | | | | | | | | | | | |
 q8: -QUBIT_COORDS(6,3.5,0)-----------------------------------------------RX---@---@---@---@-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-MRX:rec[4]---------------------------
                                                                                             | | | | | | | | | | | | | | | |
 q9: -QUBIT_COORDS(3.5,6,0)-----------------------------------------------RX-----------------@-@-@-@-|-|-|-|-|-|-|-|-|-|-|-|-MRX:rec[5]---------------------------
                                                                                                     | | | | | | | | | | | |
q10: -QUBIT_COORDS(2.5,2.5,1)---------------------------------------------R--------------------------|-|-|-X-|-X-|-X-|-X-|-|-MR:rec[6]--DETECTOR:D0=rec[6]--------
                                                                                                     | | |   |   |   |   | |
q11: -QUBIT_COORDS(6,3.5,1)-----------------------------------------------R--------------------------|-|-|---X---X---X---X-|-MR:rec[7]--DETECTOR:D1=rec[7]--------
                                                                                                     | | |                 |
q12: -QUBIT_COORDS(3.5,6,1)-----------------------------------------------R--------------------------X-X-X-----------------X-MR:rec[8]--DETECTOR:D2=rec[8]--------
      \---------------------------------------------------------------/      \-/ \-/ \-/ \---/             \-/ \-/ \-/ \---/ \----------------------------------/
circuit_1.diagram('timeline-svg')

enter image description here

circuit_1.diagram('detslice-with-ops-svg')

enter image description here

$\endgroup$

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.