2

I built a complex time-space dependent error model with Qiskit, and I am simulating surface codes with such error model to test their error correction capabilities. Qiskit supplies measurement data as a dictionary of counts for each bitstring that has been observed at least once.

By reading the documentation, I noted that PyMatching can be easily interfaced with Stim to test a plethora of pre-buit surface codes, however I am reluctant to switch to that simulator, since stabiliser-based simulation does not fit my needs.

How can I extract the error syndromes from Qiskit measurement data and create a syndrome graph compatible with matching algorithms such as PyMatching?

1 Answers1

1

If you can build your noiseless circuit as a stabilizer circuit, specifically as a stim circuit with DETECTOR and OBSERVABLE_INCLUDE annotations, then stim can handle converting from measurement results to detection events that can be consumed by pymatching. If you put a simple noise model in that circuit, then it can also output a DetectorErrorModel that you can use to configure pymatching.

If you don't want to involve stim at all, or you can't due to not being able to explain your circuit as a stabilizer circuit, then you need to implement what Stim implemented. You need detectors: a list of sets of measurements to compare, where each set should have deterministic parity. From this list and the circuit you can compute the expected parity of each set by simulating the circuit noiselessly, and then determine whether the parity is correct or violated within a given shot. You can then, for each error mechanism, determine which measurement sets have their parity change when that error occurs. This allows you to derive the Tanner graph relating error mechanisms to detection events, and you can configure PyMatching by giving it the grahlike subset of this graph.

Craig Gidney
  • 47,099
  • 1
  • 44
  • 119