I would like to output a detector check matrix and a logical observable matrix defined in this paper.

I've also learned from the related question: How to convert stim encoder circuit to a parity matrix.

The detector check matrix and logical observable matrix is originally included in a detector error model, which is easy to construct by detector_error_model = circuit.detector_error_model(decompose_errors=True) . My motivation is to connect stim circuit to some other types of decoders, which requires detector check matrix and logical observable matrix input, and I'm wondering how to acquire it directly from stim circuits.


1 Answer 1


You might want to consider encapsulating your decoder as a CustomDecoder to benefit from stim/sinter framework for your simulation.

Other people have done this (e.g. here). They ran into the same need to get a detector check matrix and logical observable matrix from a circuit. You do not need to start over from the circuit, you can build your check matrices directly from the detector error model. Each line of the detector error model will correspond to an error mechanism flipping some detectors/observables, corresponding with some caveats to a line (or several lines) in your detector/observable check matrix.

In the library I linked, they call the function detector_error_model_to_check_matrices defined here at line 61.

This function parses the detector error model to build a syndrome decoding (hyper)graph, whose adjacency matrix corresponds to the detector check matrix you want I believe.


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.