qldpc.decoders.retrieval

Methods to decode, or retrieve various decoders.

Attributes

DECODER_CONSTRUCTORS

Functions

decode(→ numpy.typing.NDArray[numpy.int_])

Construct a decoder and decode a syndrome.

get_decoder(→ qldpc.decoders.custom.Decoder)

Retrieve a decoder.

get_decoder_BF(→ qldpc.decoders.custom.Decoder)

Decoder based on belief finding (BF).

get_decoder_BP_LSD(→ qldpc.decoders.custom.Decoder)

Decoder based on belief propagation with localized statistics (BP+LSD).

get_decoder_BP_OSD(→ qldpc.decoders.custom.Decoder)

Decoder based on belief propagation with ordered statistics (BP+OSD).

get_decoder_GUF(→ qldpc.decoders.custom.GUFDecoder)

Decoder based on a generalization of Union-Find, described in arXiv:2103.08049.

get_decoder_ILP(→ qldpc.decoders.custom.ILPDecoder)

Decoder based on solving an integer linear program (ILP).

get_decoder_MWPM(→ qldpc.decoders.custom.BatchDecoder)

Decoder based on minimum weight perfect matching (MWPM).

get_decoder_RBP(→ qldpc.decoders.custom.RelayBPDecoder)

Relay-BP decoders.

get_decoder_lookup(→ qldpc.decoders.lookup.LookupDecoder)

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=True is rejected.

For details about the BF decoder and its arguments, see:

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=True is rejected.

For details about the BD-LSD decoder and its arguments, see:

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=True is rejected.

For details about the BD-OSD decoder and its arguments, see:

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=True is 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:

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]]