Skip to content

Add a TRT+PyMatching decoder profile to the HSB FPGA decoding-server test#673

Open
cketcham2333 wants to merge 1 commit into
NVIDIA:mainfrom
cketcham2333:add-trt+pymatching-fpga
Open

Add a TRT+PyMatching decoder profile to the HSB FPGA decoding-server test#673
cketcham2333 wants to merge 1 commit into
NVIDIA:mainfrom
cketcham2333:add-trt+pymatching-fpga

Conversation

@cketcham2333

Copy link
Copy Markdown
Collaborator

Description

Adds a trt_decoder profile to hsb_fpga_decoding_server_test.sh: the TensorRT
predecoder + PyMatching global decoder
combo running as a single decoding_server session,
with the FPGA feeding syndromes through the unchanged hololink_fpga_syndrome_playback tool.
The profile rides the existing pymatching plumbing end to end — trt_decoder has no
graph-dispatch support, so it uses the same cpu_roce HOST_CALL transport, the same
Bridge Ready handshake, and the same decoder-agnostic wire format. The combo itself comes
from the generator: surface_code-4-yaml --decoder_type trt_decoder --onnx_path X writes the
config entry with global_decoder: pymatching and its parameters automatically.

hololink_fpga_syndrome_playback (UNCHANGED)   decoding_server --transport=cpu_roce
  programs SIF w/ server QP/RKey/addr           --qp_config=hsb_fpga
  writes per-round RPC frames to FPGA BRAM      decoder session: trt_decoder
  arms ILA, verifies captured RPCResponses        ONNX -> TRT engine -> per-shot inference
                                                  -> PyMatching global decode -> corrections

Changes (one file: libs/qec/unittests/utils/hsb_fpga_decoding_server_test.sh)

  • --decoder trt_decoder profile + --onnx PATH flag (default AUTO). AUTO generates
    the tiny identity predecoder ONNX at run time (mirrors the
    app_examples/surface_code-4-yaml-test.sh snippet): output row = [pre_L=0, syndrome untouched], so TRT preserves the syndrome, PyMatching performs the actual correction, and
    expected corrections stay computable at generation time with no trained model — while still
    exercising ONNX parse, TRT engine build, and per-shot inference. Requires the python3
    onnx module (checked with a clear error).
  • Config generation passes --onnx_path for the profile and pins the generated YAML to
    the combo (must contain a trt_decoder entry with onnx_load_path). The syndromes run
    (--yaml) constructs the decoder in-process and decodes, so the TRT plugin .so is
    checked explicitly before generation — the decoder-plugin loader silently skips
    missing/broken .sos.
  • Build phase: -DCUDAQ_QEC_BUILD_TRT_DECODER flips from the hardwired OFF to ON for
    the trt profile (hard configure failure when the TensorRT dev packages are absent — loud
    beats two layered silent skips) and stays OFF otherwise; cudaq-qec-trt-decoder joins
    the profile's build targets.
  • New session-identity check for ALL profiles: after Bridge Ready, the server log must
    name the constructed session (decoder 0 type: <decoder>). This matters most for
    trt_decoder, where the identity ONNX makes a silently-substituted plain-pymatching
    session pass the FPGA corrections verification bit-identically; with the session identity
    pinned, the plugin's no-fallback semantics mean matching corrections in the FPGA capture
    RAM prove TRT inference ran on every shot.

Pass criterion unchanged: hololink_fpga_syndrome_playback --verify (ILA-verified header +
correction matching). No C++ changes — plugin, server, playback, and wire format
untouched.

…-server test

Add a trt_decoder profile to hsb_fpga_decoding_server_test.sh: the TensorRT
predecoder + PyMatching global decoder combo running as one decoding_server
session, with the FPGA (or emulator) feeding syndromes through the unchanged
hololink_fpga_syndrome_playback tool.  The profile rides the existing
pymatching plumbing end to end -- trt_decoder has no graph-dispatch support,
so it uses the same cpu_roce HOST_CALL transport, the same Bridge Ready
handshake, and the same decoder-agnostic wire format.  The combo itself
comes from the generator: surface_code-4-yaml --decoder_type trt_decoder
--onnx_path X writes the config entry with global_decoder: pymatching and
its parameters automatically.

Script changes:

- --decoder trt_decoder profile + new --onnx PATH flag (default AUTO).
  AUTO generates the tiny identity predecoder ONNX at run time (mirrors
  app_examples/surface_code-4-yaml-test.sh): output row = [pre_L=0, input
  syndrome untouched], so TRT preserves the syndrome, PyMatching performs
  the actual correction, and expected corrections stay computable at
  generation time with no trained model -- while still exercising ONNX
  parse, TRT engine build, and per-shot inference.  Requires the python3
  'onnx' module (checked with a clear error).
- Config generation passes --onnx_path for the profile, and the generated
  YAML is pinned to the combo (must contain a trt_decoder entry with
  onnx_load_path).  The syndromes run (--yaml) constructs the decoder
  in-process and decodes, so the TRT plugin .so is required before
  generation -- checked explicitly, because the decoder-plugin loader
  silently skips missing/broken .so's.
- Build phase: -DCUDAQ_QEC_BUILD_TRT_DECODER flips from the hardwired OFF
  to ON for the trt profile (ON hard-fails at configure when the TensorRT
  dev packages are absent -- loud beats two layered silent skips) and OFF
  otherwise, preserving existing behavior for other profiles; the
  cudaq-qec-trt-decoder target is added to the profile's build set.
- New configuration-identity check for ALL profiles: after Bridge Ready,
  the server log must name the constructed session ("decoder 0 type:
  <decoder>").  This matters most for trt_decoder, where the identity ONNX
  makes a silently-substituted plain-pymatching session pass the FPGA
  corrections verification bit-identically; the check pins the session
  identity, after which the plugin's no-fallback semantics mean matching
  corrections in the FPGA capture RAM prove TRT inference ran per shot.

The pass criterion is unchanged: hololink_fpga_syndrome_playback --verify
(ILA-verified header + correction matching).  No C++ changes anywhere; the
trt_decoder plugin, playback, server, and wire format are untouched.

Environment prerequisites (dev rig): TensorRT dev packages matching the
installed runtime (libnvinfer-dev, libnvinfer-plugin-dev,
libnvonnxparsers-dev = 10.15.1.29-1+cuda13.1) and the python3 onnx module.

Signed-off-by: Chuck Ketcham <cketcham@nvidia.com>
@cketcham2333 cketcham2333 marked this pull request as ready for review July 10, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant