.. _detector_error_model: Detector Error Models ===================== A detector error model (DEM) describes how faults in a quantum circuit flip detectors and logical observables. For a complete circuit, CUDA-Q QEC provides :class:`~cudaq_qec.DetectorErrorModel` in Python and :cpp:class:`cudaq::qec::detector_error_model` in C++. Functions such as ``dem_from_memory_circuit()`` construct a DEM from a QEC circuit and a noise model. For circuit-level noise, the DEM can be put into a canonical form organized by measurement rounds, making it suitable for multi-round decoding. The parity check matrix a decoder consumes is derived from the DEM: each row is a detector and each column a possible error mechanism. For a runnable example that generates a DEM from a surface code and decodes with it, see :doc:`Experiments and Noise Modeling `. When the error mechanisms are known but their probabilities are uncertain, :ref:`noise learning ` can estimate those probabilities from detector samples. It learns rates for the existing DEM mechanisms; it does not discover missing mechanisms. See :doc:`Learning Noise and Decoding with Learned Rates ` for the workflow. .. toctree:: :hidden: :maxdepth: 2 Decoding from Stim DEM Text DEM Sampling Dynamic DEM The following guides cover different ways to use detector error models: * .. _decoding-from-stim-dem-text: :doc:`Decoding from Stim DEM Text ` explains how to construct a decoder from an existing Stim DEM and how its fault information is parsed. * .. _dem-sampling: :doc:`DEM Sampling ` explains how to generate synthetic errors and syndromes from a DEM to test a decoder, using CPU or GPU sampling. * .. _dynamic-dem: .. _dynamic-dem-construction: :doc:`Dynamic DEM ` explains how reusable phases describe repeating error-correction cycles, preserve effects across round boundaries, and support fixed-length shots or streaming decoding.