qldpc.decoders.retrieval
Methods to decode, or retrieve various decoders.
Attributes
Functions
|
Construct a decoder and decode a syndrome. |
|
Retrieve a decoder. |
|
Decoder based on belief finding (BF). |
|
Decoder based on belief propagation with localized statistics (BP+LSD). |
|
Decoder based on belief propagation with ordered statistics (BP+OSD). |
|
Decoder based on a generalization of Union-Find, described in arXiv:2103.08049. |
|
Decoder based on solving an integer linear program (ILP). |
|
Decoder based on minimum weight perfect matching (MWPM). |
|
Relay-BP decoders. |
|
Decoder based on a lookup table that maps errors to syndromes. |
Module Contents
- qldpc.decoders.retrieval.decode(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, syndrome: numpy.typing.NDArray[numpy.int_], **decoder_args: object) numpy.typing.NDArray[numpy.int_][source]
Construct a decoder and decode a syndrome.
Return the result of decoding.
- qldpc.decoders.retrieval.get_decoder(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, **decoder_args: object) qldpc.decoders.custom.Decoder[source]
Retrieve a decoder.
This method looks for a keyword “with_<DECODER_NAME>: bool” argument, and returns
get_decoder_<DECODER_NAME>(pcm_or_dem, **decoder_args). At most one such argument may be truthy, and a ValueError is raised otherwise. All remaining keyword arguments go to that constructor, so a decoder-specific option (such as the decompose_errors argument of get_decoder_MWPM) is only accepted when its decoder is selected.This method also recognizes the following keyword arguments for injecting a custom decoder:
decoder_constructor: return
decoder_constructor(pcm_or_dem, **decoder_args).static_decoder: ignore all other arguments and return static_decoder.
If no decoder is specified, this method defaults to generalized union-find (GUF) for non-binary parity check matrices, and BP+OSD otherwise.
- qldpc.decoders.retrieval.get_decoder_BF(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, *, error_rate: float = PLACEHOLDER_ERROR_RATE, error_channel: numpy.typing.NDArray[numpy.floating] | collections.abc.Sequence[float] | None = None, **decoder_args: object) qldpc.decoders.custom.Decoder[source]
Decoder based on belief finding (BF).
- Parameters:
pcm_or_dem – A parity check matrix or detector error model (DEM) to decode.
error_rate – The i.i.d. probability of each error in pcm_or_dem. This argument is ignored if pcm_or_dem is a DEM. Default: {PLACEHOLDER_ERROR_RATE}.
error_channel – A vector declaring the probability of each error mechanism in pcm_or_dem. If pcm_or_dem is a matrix, the error_channel defaults to
[error_rate] * num_errors. If pcm_or_dem is a DEM, its error probabilities are used as the default error_channel. If an explicit error_channel is provided, it overrides all defaults.**decoder_args – Additional keyword arguments passed to ldpc.BeliefFindDecoder.
- Returns:
A decoder constructed by the ldpc package.
This decoder cannot signal erasure, so
add_erasure_bit=Trueis rejected.For details about the BF decoder and its arguments, see:
help(ldpc.BeliefFindDecoder)
Documentation: https://software.roffe.eu/ldpc/quantum_decoder.html
References: - https://arxiv.org/abs/1709.06218 - https://arxiv.org/abs/2103.08049 - https://arxiv.org/abs/2209.01180
- qldpc.decoders.retrieval.get_decoder_BP_LSD(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, *, error_rate: float = PLACEHOLDER_ERROR_RATE, error_channel: numpy.typing.NDArray[numpy.floating] | collections.abc.Sequence[float] | None = None, **decoder_args: object) qldpc.decoders.custom.Decoder[source]
Decoder based on belief propagation with localized statistics (BP+LSD).
- Parameters:
pcm_or_dem – A parity check matrix or detector error model (DEM) to decode.
error_rate – The i.i.d. probability of each error in pcm_or_dem. This argument is ignored if pcm_or_dem is a DEM. Default: {PLACEHOLDER_ERROR_RATE}.
error_channel – A vector declaring the probability of each error mechanism in pcm_or_dem. If pcm_or_dem is a matrix, the error_channel defaults to
[error_rate] * num_errors. If pcm_or_dem is a DEM, its error probabilities are used as the default error_channel. If an explicit error_channel is provided, it overrides all defaults.**decoder_args – Additional keyword arguments passed to ldpc.bplsd_decoder.BpLsdDecoder.
- Returns:
A decoder constructed by the ldpc package.
This decoder cannot signal erasure, so
add_erasure_bit=Trueis rejected.For details about the BD-LSD decoder and its arguments, see:
help(ldpc.bplsd_decoder.BpLsdDecoder)
Documentation: https://software.roffe.eu/ldpc/quantum_decoder.html
Reference: https://arxiv.org/abs/2406.18655
- qldpc.decoders.retrieval.get_decoder_BP_OSD(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, *, error_rate: float = PLACEHOLDER_ERROR_RATE, error_channel: numpy.typing.NDArray[numpy.floating] | collections.abc.Sequence[float] | None = None, **decoder_args: object) qldpc.decoders.custom.Decoder[source]
Decoder based on belief propagation with ordered statistics (BP+OSD).
- Parameters:
pcm_or_dem – A parity check matrix or detector error model (DEM) to decode.
error_rate – The i.i.d. probability of each error in pcm_or_dem. This argument is ignored if pcm_or_dem is a DEM. Default: {PLACEHOLDER_ERROR_RATE}.
error_channel – A vector declaring the probability of each error mechanism in pcm_or_dem. If pcm_or_dem is a matrix, the error_channel defaults to
[error_rate] * num_errors. If pcm_or_dem is a DEM, its error probabilities are used as the default error_channel. If an explicit error_channel is provided, it overrides all defaults.**decoder_args – Additional keyword arguments passed to ldpc.BpOsdDecoder.
- Returns:
A decoder constructed by the ldpc package.
This decoder cannot signal erasure, so
add_erasure_bit=Trueis rejected.For details about the BD-OSD decoder and its arguments, see:
help(ldpc.BpOsdDecoder)
Documentation: https://software.roffe.eu/ldpc/quantum_decoder.html
Reference: https://arxiv.org/abs/2005.07016
- qldpc.decoders.retrieval.get_decoder_GUF(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, **decoder_args: object) qldpc.decoders.custom.GUFDecoder[source]
Decoder based on a generalization of Union-Find, described in arXiv:2103.08049.
- qldpc.decoders.retrieval.get_decoder_ILP(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, *, add_erasure_bit: bool = False, **decoder_args: object) qldpc.decoders.custom.ILPDecoder[source]
Decoder based on solving an integer linear program (ILP).
- qldpc.decoders.retrieval.get_decoder_MWPM(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, *, decompose_errors: bool = False, ignore_non_graphlike_errors: bool = False, **decoder_args: object) qldpc.decoders.custom.BatchDecoder[source]
Decoder based on minimum weight perfect matching (MWPM).
- Parameters:
pcm_or_dem – A parity check matrix or detector error model (DEM) to decode.
decompose_errors – Whether to apply suggested decompositions of error mechanisms.
ignore_non_graphlike_errors – Whether to ignore errors that trigger > 2 detectors (after decomposition, if applicable).
**decoder_args – Additional keyword arguments passed to ldpc.BeliefFindDecoder.
- Returns:
A decoder constructed by pymatching.Matching.from_check_matrix.
This decoder cannot signal erasure, so
add_erasure_bit=Trueis rejected.All other keyword arguments are passed to pymatching.Matching.from_check_matrix.
A point of potential confusion: even if passed a detector error model, we DO NOT USE the pymatching.Matching.from_check_matrix method here because this returns a decoder that maps a syndrome to observable flips, whereas we want a decoder that maps a syndrome to an error. If you want a decoder that maps syndromes to observable flips, see qldpc.decoders.sinter.
- qldpc.decoders.retrieval.get_decoder_RBP(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, error_priors: numpy.typing.NDArray[numpy.floating] | collections.abc.Sequence[float] | None = None, **decoder_args: object) qldpc.decoders.custom.RelayBPDecoder[source]
Relay-BP decoders.
For details about Relay-BP decoders, see:
Documentation: https://pypi.org/project/relay-bp
Reference: https://arxiv.org/abs/2506.01779
- qldpc.decoders.retrieval.get_decoder_lookup(pcm_or_dem: qldpc.math.IntegerArray | stim.DetectorErrorModel, **decoder_args: object) qldpc.decoders.lookup.LookupDecoder[source]
Decoder based on a lookup table that maps errors to syndromes.
- qldpc.decoders.retrieval.DECODER_CONSTRUCTORS: dict[str, collections.abc.Callable[..., qldpc.decoders.custom.Decoder]]