0
$\begingroup$

I am trying to simulate the quantum torus code in Stim but have indeterministic errors when I do the final measurements and compare data qubits with respective previous syndrome qubit measurements.

I can't find the bug. Due to the bug, I understand that the measured qubits are not on a computational basis. However, due to the way the detectors are constructed, considering the qubits in the plaquettes, I can't find a reason for the bug.

See the circuit that I generate below.

QUBIT_COORDS(0, 1) 0                                                                                                                 
QUBIT_COORDS(0, 3) 1                                                                                                                 
QUBIT_COORDS(0, 5) 2                                                                                                                 
QUBIT_COORDS(1, 0) 3                                                                                                                 
QUBIT_COORDS(1, 2) 4                                                                                                                 
QUBIT_COORDS(1, 4) 5                                                                                                                 
QUBIT_COORDS(2, 1) 6                                                                                                                 
QUBIT_COORDS(2, 3) 7                                                                                                                 
QUBIT_COORDS(2, 5) 8                                                                                                                 
QUBIT_COORDS(3, 0) 9                                                                                                                 
QUBIT_COORDS(3, 2) 10                                                                                                                
QUBIT_COORDS(3, 4) 11                                                                                                                
QUBIT_COORDS(4, 1) 12                                                                                                                
QUBIT_COORDS(4, 3) 13                                                                                                                
QUBIT_COORDS(4, 5) 14                                                                                                                
QUBIT_COORDS(5, 0) 15                                                                                                                
QUBIT_COORDS(5, 2) 16                                                                                                                
QUBIT_COORDS(5, 4) 17                                                                                                                
H 6 1 13 8                                                                                                                           
CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                       
TICK                                                                                                                                 
CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                       
TICK                                                                                                                                 
CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                       
TICK                                                                                                                                 
CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                       
TICK                                                                                                                                 
DEPOLARIZE2(0) 6 10 1 5 13 17 8 9 6 4 1 17 13 11 8 3 6 3 1 16 13 10 8 5 6 9 1 4 13 16 8 11 0 4 12 16 7 11 2 3 14 15 0 16 12 10 7 5 2 
15 14 9 0 15 12 9 7 4 2 17 14 11 0 3 12 15 7 10 2 5 14 17                                                                            
MR 6 1 13 8 0 12 7 2 14                                                                                                              
CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                       
TICK                                                                                                                                 
CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                       
TICK                                                                                                                                 
CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                       
TICK                                                                                                                                 
CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                       
TICK                                                                                                                                 
H 6 1 13 8 6 1 13 8                                                                                                                  
CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                       
TICK                                                                                                                                 
CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                       
TICK                                                                                                                                 
CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                       
TICK                                                                                                                                 
CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                       
TICK                                                                                                                                 
DEPOLARIZE2(0) 6 10 1 5 13 17 8 9 6 4 1 17 13 11 8 3 6 3 1 16 13 10 8 5 6 9 1 4 13 16 8 11 0 4 12 16 7 11 2 3 14 15 0 16 12 10 7 5 2 
15 14 9 0 15 12 9 7 4 2 17 14 11 0 3 12 15 7 10 2 5 14 17                                                                            
MR 6 1 13 8 0 12 7 2 14                                                                                                              
CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                       
TICK                                                                                                                                 
CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                       
TICK                                                                                                                                 
CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                       
TICK                                                                                                                                 
CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                       
TICK                                                                                                                                 
H 6 1 13 8                                                                                                                           
DETECTOR(0, 1, 0) rec[-5]                                                                                                            
DETECTOR(4, 1, 0) rec[-4]                                                                                                            
DETECTOR(2, 3, 0) rec[-3]                                                                                                            
DETECTOR(0, 5, 0) rec[-2]                                                                                                            
DETECTOR(4, 5, 0) rec[-1]                                                                                                            
REPEAT 10 {                                                                                                                          
    H 6 1 13 8                                                                                                                       
    CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                   
    TICK                                                                                                                             
    CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                   
    TICK                                                                                                                             
    CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                   
    TICK                                                                                                                             
    CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                   
    TICK                                                                                                                             
    DEPOLARIZE2(0) 6 10 1 5 13 17 8 9 6 4 1 17 13 11 8 3 6 3 1 16 13 10 8 5 6 9 1 4 13 16 8 11 0 4 12 16 7 11 2 3 14 15 0 16 12 10 7 
5 2 15 14 9 0 15 12 9 7 4 2 17 14 11 0 3 12 15 7 10 2 5 14 17                                                                        
    MR 6 1 13 8 0 12 7 2 14                                                                                                          
    CX 6 10 1 5 13 17 8 9 4 0 16 12 11 7 3 2 15 14                                                                                   
    TICK                                                                                                                             
    CX 6 4 1 17 13 11 8 3 16 0 10 12 5 7 15 2 9 14                                                                                   
    TICK                                                                                                                             
    CX 6 3 1 16 13 10 8 5 15 0 9 12 4 7 17 2 11 14                                                                                   
    TICK                                                                                                                             
    CX 6 9 1 4 13 16 8 11 3 0 15 12 10 7 5 2 17 14                                                                                   
    TICK                                                                                                                             
    H 6 1 13 8                                                                                                                       
    SHIFT_COORDS(0, 0, 1)                                                                                                            
    DETECTOR(0, 1, 0) rec[-5] rec[-14]                                                                                               
    DETECTOR(4, 1, 0) rec[-4] rec[-13]                                                                                               
    DETECTOR(2, 3, 0) rec[-3] rec[-12]                                                                                               
    DETECTOR(0, 5, 0) rec[-2] rec[-11]                                                                                               
    DETECTOR(4, 5, 0) rec[-1] rec[-10]                                                                                               
    DETECTOR(2, 1, 0) rec[-9] rec[-18]                                                                                               
    DETECTOR(0, 3, 0) rec[-8] rec[-17]                                                                                               
    DETECTOR(4, 3, 0) rec[-7] rec[-16]                                                                                               
    DETECTOR(2, 5, 0) rec[-6] rec[-15]                                                                                               
}                                                                                                                                    
M 3 9 15 4 10 16 5 11 17                                                                                                             
DETECTOR(0, 1, 1) rec[-9] rec[-7] rec[-6] rec[-4] rec[-14]                                                                           
DETECTOR(4, 1, 1) rec[-8] rec[-7] rec[-5] rec[-4] rec[-13]                                                                           
DETECTOR(2, 3, 1) rec[-6] rec[-5] rec[-3] rec[-2] rec[-12]                                                                           
DETECTOR(0, 5, 1) rec[-9] rec[-7] rec[-3] rec[-1] rec[-11]                                                                           
DETECTOR(4, 5, 1) rec[-8] rec[-7] rec[-2] rec[-1] rec[-10]                                                                           
OBSERVABLE_INCLUDE(0) rec[-9] rec[-8] rec[-7]
$\endgroup$

1 Answer 1

1
$\begingroup$

This circuit has quite a few problems, the data measurements being non-deterministic is just the one that's being noticed first.

For example, if you install the dev version of stim and make a detector slice diagram, you should see blue (Z) and red (X) shapes growing from a point then shrinking back down. Instead, you only see blue shapes with some of them not expanding:

enter image description here

Looking at it more in depth it looks like you're missing every other layer of measurements, and also like your X basis stabilizer measurement qubits are initialized in the wrong basis resulting in their later measurement not depending on the intended stabilizer:

enter image description here

I also noticed that some Z errors at resets propagate to multiple measurements instead, but typically they would only propagate to one:

enter image description here

You almost definitely need to fix these things before you will be able to fix the failures at the end of the circuit.

$\endgroup$
2
  • $\begingroup$ Thanks a lot, Craig. I can see the stupid thing I did. I think to have solved the problem above by placing the Hadamard gate before measurements, which makes complete sense, and initializing X-syndrome qubits with RX and measuring via MRX. However, I really don't understand why initializing them with R gate and measuring with MR does not work. I would love it if you could make sense of such a thing. $\endgroup$
    – Unknown
    Commented Jan 3, 2023 at 16:12
  • $\begingroup$ @Unknown If you're trying to do the cycle with CNOTs you should be initializing the Z measure qubits with RX (or R then H) and the X measure qubits with R. Otherwise the part of the CNOT on the measure qubit will commute with the initialization basis and do nothing (e.g. CNOT controlled by |0> does nothing). $\endgroup$ Commented Jan 3, 2023 at 18:38

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.