In Stim, logical observable has to be deterministic. To calculate the logical error rate, we compare the actual_observables sampled with stim circuit and predicted_observables which is the prediction from PyMatching.

I wander if we can analyze logical error rate for non-deterministic observable. For example we have a logical state |0>+2|1> (up to a normalization factor), we perform d rounds of error correction and measure in logical X basis. Is it possible to do this? (Though probably it would be tricky to define what logical error rate is in this case).

A more useful application of analyzing non-deterministic observable is lattice surgery, in which we perform logical XX or ZZ measurement on two patches of surface code. However, the joint measurement result is generally random. We perform d rounds of error correction after the merging operation and decode the defect graph to get the predicted value of joint measurement outcome (which is given by the parity of the new stabilizers in the first round of error correction after merging). So how could we determine the measurement outcome of this non-deterministic joint observable fault-tolerantly in this case?

Thanks very much!


1 Answer 1


Pymatching implicitly supports non-deterministic observables, because it's only trying to predict whether the observable is flipped and this prediction does not care about whether or not the observable is deterministic.

Stim currently has no way to define a non-deterministic observable. The reason for this is because stim only supports stabilizer circuits, and in stabilizer circuits all measurements and parities of combinations of measurements are either completely deterministic or completely 50/50 random. So if you declare a non-deterministic observable, it would be impossible to check if it's working. The circuit wouldn't correspond to a useful experiment.

The main place where this is an issue isn't lattice surgery. It's non-clifford gates. For example, suppose you want to test a T-state injection into a surface code. One way to do this is by tomography, where you inject the state many times doing a variety of x and y and z basis measurements to figure out the process fidelity. Because you're injecting into a surface code, this involves error correction, but because it involves non-clifford gates, there are observables that aren't deterministic and aren't fully random either.

My plan for adding support for this use case is to eventually extend the observable include instruction to allow qubit Pauli terms. Like OBSERVABLE_INCLUDE(0) X0 X1. The idea is that this would allow you to artificially pretend that an observable didn't pass through a non-Clifford operation, by removing specific terms and then adding them back in after the gate. The tricky bit is that this doesn't correspond to any physical operation, it's more of a " don't you worry about this gate I'll take care of this gate" sort of thing. I haven't added it yet because I'm pretty sure it would be really easy to use it wrong and get nonsense out.

I mentioned that lattice surgery still allows you to define experiments that check that it is working. Here's an example. An XX parity measurement should preserve the ZZ observable. You can turn that rule into an experiment checking that it does so. The circuit

R 0 1
M 0 1
OBSERVABLE_INCLUDE(0) rec[-1] rec[-2]

is checking the ZZ preservation rule of the parity measurement. Change the individual qubits into surface code qubits and that's a valid thing that you could run on hardware checking that your surface code lattice surgery works. You can check all of the required rules in this way. You can't necessarily check all the rules with a single experiment... but the same is true of memory experiments. In order to know that memory works, you do separate experiments where you check that the Z observable and the X observable are preserved.

  • $\begingroup$ Thanks for you answer! Indeed we can check whether our surface code lattice surgery works or not in this way, i.e. by checking if ZZ observable are preserved or not. However, in this way we still can't know if the XX measurement result is correct, which is important to continue implementing CNOT gate. For example, we have a logical |0> and |1> for two sheets of surface code. By doing XX measurement, we project the state to |01>+|10> if we measure +1, and |01>-|10> if we measure -1. Both of the post-measurement state preserve ZZ observable, but they have different measurement results. $\endgroup$
    – Jerry
    Mar 22, 2023 at 18:29
  • $\begingroup$ @Jerry You do a separate experiment to check each flow. There are four flows to check. Same as a memory experiment having two experiments to check the two required flows. $\endgroup$ Mar 22, 2023 at 21:04
  • $\begingroup$ Thanks for your reply. I don't think I get your point. First, generally XX parity measurement doesn't preserve the ZZ observable for any two-qubit state. Secondly, yes we can check if XX parity measurement preserve the ZZ observable for state |00>, |01>, |10>, and |11>, separately, but we still don't know if we are indeed in the +1 eigenstate of XX if we measure the parity +1. And we can't measure ZZ immediately to check, because we still need other operations to perform logical CNOT gate. $\endgroup$
    – Jerry
    Mar 22, 2023 at 23:34
  • $\begingroup$ What I'm confused is how we could determine the XX measurement parity fault-tolerantly. To do a logical CNOT, one need to use lattice surgery to do joint XX and ZZ measurement, and the measurement result is given by the parity of the new stabilizers introduced in the merging operation. Theoretically, we perform d rounds of error correction after preparing the intermediate qubits, and we determine the sign of the XX parity result by decoding the defect graph of this d-round error correction. $\endgroup$
    – Jerry
    Mar 22, 2023 at 23:42
  • $\begingroup$ The problem is that XX parity is generally random. With your method we can check if lattice surgery works, but this is not enough to fault-tolerantly do a logical CNOT gate. It's like "yes we check if it works, but it's not enough to just know it works" sort of thing. I really appreciate your kindness and effort to the answer! $\endgroup$
    – Jerry
    Mar 22, 2023 at 23:48

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.