How can I convert a Stim detector error model into a networkx/rustworkx weighted graph representing the equivalent syndrome graph?

I want it to test a possible method to introduce erasures in the high erasure rate regime, where the method described in How do I perform an erasure error in stim? might be invalid.


1 Answer 1


The general idea is you iterate over the instructions of the model, interpreting them as per the spec. For example, when you encounter an error instruction you add an edge to the graph. There are other details like dealing with loops and tracking the detector index offset. Ultimately it's boilerplate code: not necessarily hard, but definitely tedious.

There's code that takes a stim.DetectorErrorModel and outputs a networkx.graph in the old pymatching glue code in sinter: https://github.com/quantumlib/Stim/blob/0da65e5b44e600e9ea04f02ec0154c56b010e133/glue/sample/src/sinter/_decoding_pymatching_v1.py#L88 . You will likely need to tweak it for your use case, e.g. adjust what it does with decomposed hyper edges. But it'll get you started.


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.