Skip to content

Commit ae3716b

Browse files
committed
Rebase realtime_decoding_demo onto the refactored surface_code-1 app
Replace the example source with the surface_code-1.cpp from #685 (new syndrome format, decoder_context_from_memory_circuit, seeded runs) and adapt the driver script, build, docs, and CI to its interface. The example copy differs from the in-tree file only in the header comment, the usage line, and the --save_syndrome capture, which now emits true-width groups (the packed bytes are byte-padded; the FPGA playback tool sets each replayed frame's num_syndromes from the group's line count, and the decoder's per-shot measurement capacity is the exact sum, so padded groups overran it). - run_realtime_decoding.sh: --p-cnot replaces --p-spam (two-qubit depolarizing on the CNOTs, default 0.001); new --seed (default 42 -- runs and pass/fail counts are reproducible); config/kernel phases use --save_dem / --load_dem; the kernel needs only QEC_DECODING_SERVER_PORT (the app brings up the udp channel itself in its QEC_APP_CQR build). Decoders: pymatching, nv-qldpc-decoder, multi_error_lut (trt_decoder is not supported by the new app and is dropped; sliding_window exists in the app but is not exposed -- over device calls it needs matching updates to the proprietary cudevice archive). - Pass/fail criteria keep the surface-code test checks (hard decoder-failure greps, corrections-line completion proof, num_shots/50 residual ceiling, num_shots*(num_rounds+3) server dispatch floor) and adopt the two-process test's server-ownership proof: the app's in-process dispatch count must be 0. - CMakeLists.txt: -DQEC_APP_CQR; link cudaq-qec-realtime-decoding + cudaq-qec-realtime-decoding-server-cqr (exports the dispatch-count symbol). - Docs: decoder tables/text updated (3 decoders, --p-cnot/--seed, criteria); the FPGA-predecoder page's pointer at this example is removed (trt dropped). - CI (lib_qec.yaml): the gpu-test trt step and its artifact plumbing are removed (trt dropped); the CPU job's pymatching decode now runs the seeded 200-shot default, making the ceiling check deterministic (the 50-shot unseeded run could statistically exceed a ceiling of 1 -- the amd64-12.6 failure on the previous run). Signed-off-by: Chuck Ketcham <cketcham@nvidia.com>
1 parent 11108a4 commit ae3716b

7 files changed

Lines changed: 842 additions & 1391 deletions

File tree

.github/workflows/lib_qec.yaml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ jobs:
164164
--install-prefix "$HOME/.cudaqx" \
165165
--cudaq-prefix /cudaq-install \
166166
--realtime-lib-dir "$RT" \
167-
--example-build-dir /tmp/rtdemo-build \
168-
--num-shots 50
167+
--example-build-dir /tmp/rtdemo-build
169168
170169
# ========================================================================
171170
# Upload build artifacts for GPU tests
@@ -175,8 +174,6 @@ jobs:
175174
tar czf /tmp/qec-build-artifacts.tar.gz \
176175
/cudaq-install \
177176
/tmp/cudaq-realtime \
178-
"$HOME/.cudaqx" \
179-
/tmp/rtdemo-build \
180177
$GITHUB_WORKSPACE/libs/qec/unittests/decoders/realtime/data \
181178
$GITHUB_WORKSPACE/${{ steps.build.outputs.build-dir }}
182179
@@ -274,29 +271,6 @@ jobs:
274271
PYTHONPATH="/cudaq-install:$GITHUB_WORKSPACE/build_qec/python" \
275272
pytest -v libs/qec/python/tests/
276273
277-
# ========================================================================
278-
# Realtime decoding demo: trt_decoder THROUGH the decoding server over UDP.
279-
# This is the only CI coverage of trt_decoder via the decoding server (the
280-
# TRTDecoder unit tests exercise the decoder standalone, not the server).
281-
# Reuses the example binaries + SDK install prebuilt in build-and-test
282-
# (from the artifact). Needs a GPU (TensorRT inference runs server-side)
283-
# plus python onnx (the script generates the identity predecoder model).
284-
# Gated on TensorRT availability, matching the TensorRT installs above.
285-
# ========================================================================
286-
- name: Realtime decoding demo (trt_decoder, qpu-kernel over UDP)
287-
if: matrix.platform != 'arm64' || !startsWith(matrix.cuda_version, '12')
288-
shell: bash
289-
run: |
290-
pip install onnx
291-
RT="${CUDAQ_REALTIME_ROOT:-/tmp/cudaq-realtime}"
292-
bash docs/sphinx/examples/qec/realtime_decoding_demo/run_realtime_decoding.sh \
293-
--source qpu-kernel --decoder trt_decoder \
294-
--install-prefix "$HOME/.cudaqx" \
295-
--cudaq-prefix /cudaq-install \
296-
--realtime-lib-dir "$RT" \
297-
--example-build-dir /tmp/rtdemo-build \
298-
--num-shots 50
299-
300274
# ==========================================================================
301275
# Multi-GPU tests - decoder placement across >= 2 GPUs (uses build artifacts
302276
# from build-and-test).

docs/sphinx/examples/qec/realtime_decoding_demo/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ set_target_properties(surface_code_realtime_decoding PROPERTIES LINKER_LANGUAGE
131131
# DT_NEEDED and the process would crash at startup with no platform.
132132
target_link_libraries(surface_code_realtime_decoding PRIVATE
133133
-Wl,--no-as-needed
134-
cudaq-qec cudaq-qec-realtime-decoding-simulation ${_cudaq_core_libs}
134+
cudaq-qec cudaq-qec-realtime-decoding
135+
cudaq-qec-realtime-decoding-simulation ${_cudaq_core_libs}
135136
-Wl,--as-needed
136137
"${CUDAQ_REALTIME_DISPATCH_LIB}")
137138
target_link_options(surface_code_realtime_decoding PRIVATE
@@ -143,7 +144,7 @@ target_link_options(surface_code_realtime_decoding PRIVATE
143144
# (nvcc -dlink) that resolves the dispatch archive's RDC registration symbols.
144145
# ---------------------------------------------------------------------------- #
145146
_add_nvqpp_object(_cqr_obj generator-cqr
146-
--target stim -frealtime-lowering -DQEC_APP_EXTERNAL_DECODING_SERVER)
147+
--target stim -frealtime-lowering -DQEC_APP_CQR)
147148
add_executable(surface_code_realtime_decoding-cqr "${_cqr_obj}")
148149
set_target_properties(surface_code_realtime_decoding-cqr PROPERTIES
149150
CUDA_SEPARABLE_COMPILATION ON
@@ -152,7 +153,13 @@ set_target_properties(surface_code_realtime_decoding-cqr PROPERTIES
152153
LINKER_LANGUAGE CUDA)
153154
target_link_libraries(surface_code_realtime_decoding-cqr PRIVATE
154155
-Wl,--no-as-needed
155-
cudaq-qec cudaq-qec-realtime-decoding-simulation-cqr cudaq-device-call-runtime
156+
cudaq-qec cudaq-qec-realtime-decoding
157+
cudaq-qec-realtime-decoding-simulation-cqr
158+
# The in-process decoding service; also exports
159+
# cudaqx_qec_device_call_dispatch_count, which the app prints as evidence
160+
# that an external server (not the in-process service) did the decoding.
161+
cudaq-qec-realtime-decoding-server-cqr
162+
cudaq-device-call-runtime
156163
${_cudaq_core_libs}
157164
-Wl,--as-needed
158165
"${CUDAQ_REALTIME_DISPATCH_LIB}" CUDA::cudart)

docs/sphinx/examples/qec/realtime_decoding_demo/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,29 @@ toolchain; override the device-link architecture with
4646

4747
```bash
4848
./run_realtime_decoding.sh --source qpu-kernel --decoder pymatching --install-prefix <prefix>
49-
./run_realtime_decoding.sh --source qpu-kernel --decoder trt_decoder --install-prefix <prefix>
49+
./run_realtime_decoding.sh --source qpu-kernel --decoder multi_error_lut --install-prefix <prefix>
5050
./run_realtime_decoding.sh --source qpu-kernel --decoder nv-qldpc-decoder --gpu 0 --install-prefix <prefix>
5151
```
5252

5353
The lowered kernel runs the surface-code memory experiment and streams each
5454
shot's syndromes to the server over UDP; the server decodes and returns
55-
corrections. No NIC, no FPGA, no network setup.
55+
corrections. No NIC, no FPGA, no network setup. Runs are seeded (`--seed`,
56+
default 42), so the reported counts are reproducible.
5657

57-
PASS/FAIL uses the same criteria as the in-tree surface_code-4 tests: the run
58+
PASS/FAIL uses the same criteria as the in-tree surface-code tests: the run
5859
must complete without decoder errors, the residual logical-error count must
5960
stay at or under `num_shots/50` (a decoder that is connected but decoding
60-
wrong produces far more), the kernel must report server-owned decoders, and
61-
the server must have dispatched at least `num_shots * (num_rounds + 3)` RPCs.
61+
wrong produces far more), the kernel's in-process dispatch count must be 0
62+
(proof the decode stayed in the external server), and the server must have
63+
dispatched at least `num_shots * (num_rounds + 3)` RPCs.
6264

6365
### FPGA source (real FPGA; needs a ConnectX NIC)
6466

6567
```bash
6668
./run_realtime_decoding.sh --source fpga --decoder pymatching \
6769
--setup-network --device <nic> --bridge-ip <host-ip> --fpga-ip <fpga-ip> \
6870
--install-prefix <prefix>
69-
# --decoder trt_decoder / --decoder nv-qldpc-decoder --gpu 0 likewise
71+
# --decoder multi_error_lut / --decoder nv-qldpc-decoder --gpu 0 likewise
7072
```
7173

7274
The delivered playback tool streams pre-generated syndromes over RoCE from the
@@ -80,14 +82,11 @@ testing lives in the unittests `hsb_fpga_decoding_server_test.sh`.)
8082
| decoder | qpu-kernel (UDP) | fpga (real FPGA) | extra requirement |
8183
|---|---|---|---|
8284
| `pymatching` | CPU, no hardware | NIC | none |
83-
| `trt_decoder` | GPU (server-side TensorRT) | NIC + GPU | python `onnx` + GPU |
85+
| `multi_error_lut` | CPU, no hardware | NIC | none |
8486
| `nv-qldpc-decoder` | GPU (host-call path) | NIC + GPU (device path) | plugin + `--gpu` |
8587

8688
- **`pymatching`** — CPU matching decoder; nothing extra.
87-
- **`trt_decoder`** — a TensorRT predecoder feeding a PyMatching global decoder.
88-
TensorRT inference runs server-side on a GPU (both sources). The script
89-
generates a tiny identity-predecoder ONNX at runtime (needs the python
90-
`onnx` module); override with `--onnx <model>`.
89+
- **`multi_error_lut`** — CPU lookup-table decoder; nothing extra.
9190
- **`nv-qldpc-decoder`** — GPU relay-BP. Needs the prebuilt plugin
9291
(auto-found in the install prefix, else pass `--nv-qldpc-plugin <path.so>`)
9392
and a GPU selected with `--gpu <id>`. If the plugin is unavailable the script

0 commit comments

Comments
 (0)