qp.backline.css_bp_decoder

css_bp_decoder(Hx, Hz, *, postprocess='osd', num_iters=10, prob=0.1, **build_options)[source]

Compile a CSS code’s Tanner graph into a coprocessor decode function for use with backline.

Accepts the X- and Z-type parity-check matrices of a CSS code and compiles a decoder down to a shared library that can be used as a CoprocessorFunction.

Warning

Backline is experimental and only usable through the Catalyst compiler.

Parameters:
  • Hx (ArrayLike) – X parity-check matrix.

  • Hz (ArrayLike) – Z parity-check matrix.

Keyword Arguments:
  • postprocess (str) – Postprocessing step applied after belief propagation. Use "hard" for hard-decision output or "osd" for ordered-statistics decoding.

  • num_iters (int) – Number of belief-propagation iterations.

  • prob (float) – Uniform prior error probability across qubits.

  • platform (str) – Required Triton platform string of the form "backend:arch:warp_size". For example, "hip:gfx942:64" or "cuda:80:32".

  • grid (tuple[int, int, int]) – Triton kernel launch grid dimensions. Defaults to (1, 1, 1).

  • num_warps (int) – Triton kernel launch warp count. Defaults to 1.

  • num_stages (int) – Triton pipeline stage count. Defaults to 1.

  • compiler (str) – Optional compiler executable override. Defaults to "".

  • cflags (tuple[str, ...]) – Extra compiler flags. Defaults to ().

Returns:

The compiled decode function, ready to pass as

coprocessor_fn.

Return type:

CoprocessorFunction

Raises:
  • ImportError – If Triton decoder support is unavailable.

  • ValueError – If the decoder options or parity-check matrices are invalid.

Example

>>> import numpy as np
>>> import pennylane as qp
>>> Hz = Hx = np.array([
...     [1, 0, 1, 0, 1, 0, 1],
...     [0, 1, 1, 0, 0, 1, 1],
...     [0, 0, 0, 1, 1, 1, 1],
... ])
>>> decoder = qp.backline.css_bp_decoder(
...     Hx,
...     Hz,
...     postprocess="hard",
...     num_iters=5,
...     platform="hip:gfx942:64",
... )