I am trying to reproduce the dataset in this paper [arXiv:1705.00857] using Stim. The paper decomposes the errors into a "pure-error", which is any error that generates the observed syndrome, and a logical error which they train a neural-network to decode. Their dataset comprises of ancilla measurements as inputs, and 4 labels indicating the logical error that occured in the experiment as the target.

In the paper, the dataset is obtained by keeping track of all the data qubit errors in the circuit, rather then using a decoding algorithm. They then calculate the logical error based on the actual data qubit errors happening in the circuit.

I am trying to reproduce their dataset using Stim. In order to do that, I need to be able to obtain both the $X$ and $Z$ logical observables, indicating what error has occurred. Is there an easy way to do that using Stim (preferably using the pre-generated surface codes in the package, but not necessarily)?

I tried doing that by initializing the circuit to some state, then simulating it twice with the same random seed, once measuring the $X$ observable and once the $Z$ observable (essentially, preparing the same state and performing two measurements). The problem is,

  1. I understand that it is terrible practice to force the noise to be the same, and indeed it doesn't look like the errors stay exactly the same between circuits.
  2. Not really a problem since I can write my own circuit, but the $X$ and $Z$ generated circuits initialize a different initial state.

Is there a way to do that using a single circuit? Clearly, a circuit that measures both $X$ and $Z$ observables is non-physical, but is there a way to keep track of the logical errors without performing a measurement using Stim?

I don't think that I necessarily want to measure the logical observables, since I just need to know how the logical state has changed, not what it is. Really what I want to do is to compare the end logical values to the initial logical values to obtain the actual logical error.


1 Answer 1


What I do in my papers is to add an ancilla qubit, with no noise ever applied to it. I can then simultaneously test the pair of observables $X_aX_L$ and $Z_aZ_L$, because they commute. I use noiseless MPP operations to initialize and terminate the system, by measuring every stabilizer and observable.

Because the ancilla $a$ is noiseless, seeing $X_aX_L$ flip tells you that $X_L$ flipped and seeing $Z_aZL$ flip tells you that $Z_L$ flipped. You need magically noiseless initialization and measurement, but the bulk of the experiment can be normal.

Adding the ancilla turns what you want from an unphysical experiment into an experiment that merely requires certain things to be noiselesss.

An alternative approach would be to use stim.FlipSimulator(stabilizer_randomization=False), which gives you direct access to which qubits and detectors and observables have been flipped by the simulator without requiring that anything be deterministic in reality. But that won't give you an easy way to extract the appropriate detector error model, since the dem extraction code won't know what to do when you have anti-commuting observables.


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.