qp.backline.decode

decode(syndrome, *, controller=None, coprocessor=None, out_bytes=None, in_bytes=None, decoder_id=0, work_item_idx=0, bitpack=True, library=None)[source]

Calls a coprocessor function available on the Backline to perform quantum error correction decoding — providing a syndrome and recieving the corresponding correction.

decode is implemented internally as a series of runtime_call(), with the communication driven from the controller’s own process over the session that inject-transport-session brought up from the device’s placement.

Warning

Backline is experimental and only usable through the Catalyst compiler. decode() must be called inside a @qjit program, within a QNode executing on a Backline. Calling it in any other context will fail.

Parameters:
  • syndrome – The syndrome to send. Passed by data pointer, so its byte length comes from its shape and dtype at compile time. With bitpack=True, this must be a 1D bit vector with at most 64 entries.

  • controller (Controller) – The Controller whose session drives the round.

  • coprocessor (Coprocessor | None) – The Coprocessor the round targets. Selects the session key; which coprocessor serves the round is otherwise fixed by the session’s configuration.

  • out_bytes (int, None) – The correction reply size in bytes. Defaults to the placement’s out_bytes.

  • in_bytes (int, None) – How many bytes of syndrome to send, at most what the round was committed to carry. Defaults to syndrome’s full byte length.

  • decoder_id (int) – Which coprocessor-side decoder handles this round.

  • work_item_idx (int) – The committed work-item index to post.

  • bitpack (bool) – Pack syndrome bits into 8-byte payload and unpack reply to 64-bit vector.

  • library (str, None) – Shared library exporting the transport symbols, recorded so the compiler links it. Defaults to None, relying on librt_transport already being loaded.

Returns:

The correction reply, as a uint8 buffer of out_bytes bytes, or a 64-entry boolean bit vector when bitpack=True.

Raises:

ValueError – if the round targets an unnamed coprocessor which cannot be resolved as the placement holds more than one coprocessor.

Example

import pennylane as qp

con = qp.Controller(
    device=qp.device("null.qubit", wires=2),
    executor_options={"host": "192.168.3.15", "port": 7810},
)
coproc = qp.Coprocessor(
    coprocessor_fn="decoder",
    name="decoder-0",
    hardware="gpu",
    endpoint=qp.Endpoint("192.168.1.3", 18590),
)
dev = qp.Backline(controller=con, coprocessors=[coproc], transport="rdma")

@qp.qjit(capture=True)
@qp.qnode(dev)
def circuit(syndrome):
    # one round: stage the syndrome, post it, wait for the correction
    correction = qp.backline.decode(syndrome)
    qp.cond(correction[0] == 1, qp.X)(0)
    return qp.expval(qp.Z(0))