I'm trying to implement the $[\![7,1,3]\!]$ Steane code on Stim
. My circuit is below:
circuit = stim.Circuit('''
R 0 1 2 3 4 5 6 7 8 9 10 11 12
MPP X0*X2*X4*X6
MPP X3*X4*X5*X6
MPP X1*X2*X5*X6
DETECTOR rec[-3]
DETECTOR rec[-2]
DETECTOR rec[-1]
X_ERROR(1) 0
REPEAT 3 {
MPP X0*X2*X4*X6
MPP X3*X4*X5*X6
MPP X1*X2*X5*X6
MPP Z0*Z2*Z4*Z6
MPP Z3*Z4*Z5*Z6
MPP Z1*Z2*Z5*Z6
.
.
'''
}
The idea is that the first part puts my qubits into a logical state by measuring the $X$ stabilizers. I need to do two things.
Keep the outcomes of the first three MPPs somewhere since these eigenvalues define my logical $\vert 0\rangle$.
I want to implement a correction based on the stabilizer eigenvalues in the
REPEAT
section. If all ofMPP X0 X2 X4 X6
,MPP X3 X4 X5 X6
andMPP X1 X2 X5 X6
disagree with the answers in 1., then I have a $Z$ error on qubit $6$. I want to implement a controlled $Z$ gate on qubit $6$ with the control being decided by the aforementioned logic.
What's the best way to do this?
EDIT: Updated circuit based on Craig Gidney's answer.
circuit = stim.Circuit('''
R 0 1 2 3 4 5 6 7 8 9 10 11 12
MPP X0*X2*X4*X6
MPP X3*X4*X5*X6
MPP X1*X2*X5*X6
MPP Z0*Z2*Z4*Z6
MPP Z3*Z4*Z5*Z6
MPP Z1*Z2*Z5*Z6
X_ERROR(1) 0
REPEAT 2 {
MPP X0*X2*X4*X6
MPP X3*X4*X5*X6
MPP X1*X2*X5*X6
MPP Z0*Z2*Z4*Z6
MPP Z3*Z4*Z5*Z6
MPP Z1*Z2*Z5*Z6
DETECTOR rec[-6] rec[-12]
DETECTOR rec[-5] rec[-11]
DETECTOR rec[-4] rec[-10]
DETECTOR rec[-3] rec[-9]
DETECTOR rec[-2] rec[-8]
DETECTOR rec[-1] rec[-7]
}
''')
Indeed, I only get one True
on the stabilizer $Z0Z2Z4Z6$ in the first round as that's where the error is.