From this answer, I understand that stim can not be used to simulate non-stabilizer circuit. However, one can still have non-deterministic observables with 50-50 probability. Suppose for example measuring $X_L$ for the logical state $|\psi\rangle = |0\rangle_L + i|1\rangle_L$. I want to ask how one can used stim together with PyMatching to decode in this case. My primary issue is that if take $X_L$ as a observable, then as soon as I try to construct the detector_error_model, it gives me error that that the circuit contains non-deterministic observables.
- 217
- 1
- 10
1 Answers
I would start by warning you to think very carefully about what it is you think you are measuring, when you decode a non-deterministic observable. They are fundamentally not fault tolerant; they will have O(1) code distance no matter what you do.
Anyways, what you can do is to use OBSERVABLE_INCLUDE(#) X1 X4 ... X9 in order to artificially insert a tracked observable into the middle of a circuit. When decoding detectors derived from measurements from actual hardware or stim's measurement sampler, this will have no effect on how the observable is computed (e.g. if no measurements are added to the observable anywhere then it will simply always be reported as 0 so the declaration is a no-op). What it does affect is (1) how the errors in a detector error model derived from the circuit are annotated and (2) the observable flips reported when directly sampling detectors+observables. The reason for (2) is that it makes it possible to simultaneously benchmark non-commuting observables in simulations and the reason for (1) is to enable use cases like explaining a magic state injection or a commit region to a windowed decoder.
- 47,099
- 1
- 44
- 119
-
Can you explain why non-deterministic observable are fundamentally not fault tolerant? – Himanshu Jun 04 '25 at 18:25
-
@Himanshu make a noisy circuit with such an observable and compute the code distance. Unless you turn off noise where you artificially add the operator, there will be short combinations of errors looping before and after the addition in space time. Otherwise the construction would violate Heisenberg uncertainty. – Craig Gidney Jun 04 '25 at 20:15
-
I'm sorry but I couldn't exactly understood your point. If I think in terms of the basic circuit construction and decoding then -- You take syndrome (and multiple ones if there measurement error), the syndrome are independent of state and tells you how observable will be flipped. The observable either commute or not with the errors (I'm considering logical $X_L$ or $Z_L$) and that's decoded through the decoder. Where I would run into difficulty? – Himanshu Jun 04 '25 at 21:43
-
Another minor point, does it still true if the operator (non-deterministic) commutes with the errors (in my case if I only consider $X$-errors? – Himanshu Jun 04 '25 at 22:00
-
@Himanshu In that case the distance is vacuously infinity. In experiment you will see the decoder be "correct" 100% of the time if the observable includs no measurements, or ~50% if it includes some. In detector sampling you'll see it be correct 100% of the time. – Craig Gidney Jun 04 '25 at 22:08
-
You mean that even in the presence of measurement error, the decoder success rate would be 100%? – Himanshu Jun 05 '25 at 17:22
-
@Himanshu whether or not the apparent 0% error rate corresponds to the decoder succeeding would depend on context. This is what I mean by you need to very clearly understand what it is that you are measuring when you ask to do this. If you need someone else to answer that question, don't do the experiment; you won't correctly interpret the number that comes out. – Craig Gidney Jun 05 '25 at 17:57