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
Backlineto perform quantum error correction decoding — providing a syndrome and recieving the corresponding correction.decodeis implemented internally as a series ofruntime_call(), with the communication driven from the controller’s own process over the session thatinject-transport-sessionbrought up from the device’s placement.Warning
Backlineis experimental and only usable through the Catalyst compiler.decode()must be called inside a@qjitprogram, within a QNode executing on aBackline. 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
Controllerwhose session drives the round.coprocessor (Coprocessor | None) – The
Coprocessorthe 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
syndrometo send, at most what the round was committed to carry. Defaults tosyndrome’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 onlibrt_transportalready being loaded.
- Returns:
The correction reply, as a
uint8buffer ofout_bytesbytes, or a 64-entry boolean bit vector whenbitpack=True.- Raises:
ValueError – if the round targets an unnamed coprocessor which cannot be resolved as the placement holds more than one coprocessor.
See also
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))