I'm trying to simulate 3 qubit (distance 3) bit-flip code in stim. I wrote code similar to How to import a generic stabilizer code in stim using MPP operation. I found the following way yields logical error rate below physical error rate

MPP Z0*Z1 #stabilizer measurement in the last round
MPP Z1*Z2 #stabilizer measurement in the last round

M 0 1 2 #measure logical Z
DETECTOR rec[-2] rec[-3] rec[-5]
DETECTOR rec[-1] rec[-2] rec[-4]

However is it possible to use MPP in the end? If so, how? I'm asking this because I'm confused when trying to write a similar readout for 7-qubit code where the relation is more complex.


1 Answer 1


Yes, you can use MPP to measure the logical observable. For a repetition code the observable is just any one qubit's Z, so all you'd really be doing is replacing the transversal measurement M 0 1 2 with MPP Z2.

For making a circuit to run on hardware, you'd want to leave things as you have them. If the measurements are noisy, you need the detectors you've declared to correct errors. Replacing M 0 1 2 with MPP Z2 will force you to delete those detectors and the circuit will no longer be fault tolerant to noise that occurs between the last layer of stabilizer measurements and the observable measurement.

  • $\begingroup$ If, after the last noisy layer, I do a layer of noiseless stabilizer measurement, detect, and then measure the observable using MPP, this detects noise between the last layer and the observable measurement, right?\n MPP Z0*Z3*Z5*Z6 MPP Z1*Z3*Z4*Z6 MPP Z2*Z4*Z5*Z6 DETECTOR rec[-1] rec[-4] DETECTOR rec[-2] rec[-5] DETECTOR rec[-3] rec[-6] MPP Z0*Z1*Z2*Z3*Z4*Z5*Z6 OBSERVABLE_INCLUDE(0) rec[-1] \n $\endgroup$ Oct 24, 2022 at 15:23
  • $\begingroup$ @GuhhoiWong No it won't detect noise at that location, but you just specified that that location was noiseless, so it will work. If you attempt to run it on hardware, instead of in stim's simulator, the "it's noiseless" assertion will become false and it will stop working. $\endgroup$ Oct 24, 2022 at 15:28

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.