Skip to content

Add boundary-aware overloads for canonicalize_for_rounds and sliding window decoder#656

Merged
bmhowe23 merged 12 commits into
NVIDIA:mainfrom
eliotheinrich:pr-boundary-alignment
Jul 14, 2026
Merged

Add boundary-aware overloads for canonicalize_for_rounds and sliding window decoder#656
bmhowe23 merged 12 commits into
NVIDIA:mainfrom
eliotheinrich:pr-boundary-alignment

Conversation

@eliotheinrich

@eliotheinrich eliotheinrich commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Closes #649

The addition of boundary detectors offsets the syndromes output by memory circuit experiments by introducing num_boundary_syndromes at the beginning and end of the syndrome block. The means that canonicalize_for_rounds straddles the new boundaries between rounds, leading to error mechanisms being associated to incorrect rounds when the boundary syndromes have a different length than the inter-round syndromes. This is a cosmetic error for PCMs representing entire memory circuits, but is incorrect when followed up with get_pcm_for_rounds for the purpose of, i.e., the sliding window decoder.

This PR adds round-aware overloads to canonicalize_for_rounds and the sliding window decoder, bringing them up-to-date with syndrome format.

canonicalize_for_rounds has a new overload which accepts num_boundary_syndromes, which appropriately treats the first and last num_boundary_syndromes columns as distinct rounds for the purpose of round-based topological sorting.

The sliding window decoder now takes an additional parameter num_boundary_syndromes (default 0). The PCM of the decoder is zero-padded to have uniform width num_syndromes_per_round. Syndromes passed to the decoder are automatically padded to the uniform length. If num_boundary_syndromes is 0, then the boundary syndromes are presumed to be the same width as the interior syndromes (as is the case in X/Z-only experiments).

New tests:

test_qec.cpp:PCMUtilsTester.checkGetSortedColumnIndicesWithBoundary: Verifies the boundary-aware column sort orders
test_qec.cpp:DetectorErrorModelTest.CanonicalizeBoundaryRejectsWideBoundary: Assertrs canonicalize_for_rounds(S, B, ...) throws when the boundary is wider than the interior (B > S).
test_decoders.cpp::SlidingWindowDecoder.PreparePcmRejectsBadBoundaryLayout: Confirms the sliding-window decoder throws during construction for inconsistent boundary layouts (B > S, or a row count that can't fit [B | K·S | B]).
test_qec_stim.cpp::QECCodeTester.checkDemFromMemoryCircuitShor9: Checks the Shor [[9,1,3]] full DEM has the expected non-uniform shape, consistent column counts, and correct round ordering.
test_qec_stim.cpp::QECCodeTester.checkSlidingWindowShor9Boundary: A single all-rounds window decoding the Shor boundary DEM must match a full decoder for every DEM column.
test_qec_stim.cpp:QECCodeTester.checkSlidingWindowShor9Streaming: Streams variable-width detector layers for X(Z) (6(2) at boundaries, 8 interior) through a sliding config (window=2, step=1) and requires results to match a full decoder.
test_sliding_window.py::test_sliding_window_boundary_layout: Parametrized over 3 codes × 3 window counts; injects errors over 300 shots and asserts sliding-window observable predictions match a single_error_lut full decoder.

Runtime / performance impact

N/A

Self-review checklist

Please confirm each item before requesting review. Check [x] or strike
through and explain.

Before requesting review

  • I reviewed my own full diff in GitHub or my editor.
  • PR is in Draft if it is not yet ready for review.
  • Temporary / debugging changes have been removed.
  • Local test logs reviewed; no unexplained warnings or errors.
  • CI logs reviewed; no unexplained warnings or errors.
  • Full CI has been run.

Scope and size

  • PR is under ~1000 lines, or an exception is justified in the description.
  • Refactoring-only changes are isolated in their own PR(s).
  • No existing tests were disabled or modified just to make this PR pass
    (if so, an issue has been raised).

Tests

  • New functionality has new tests.
  • Tests fail if the new functionality is broken (including crashes), not
    just when it is missing.
  • Negative tests added where exceptions are expected.
  • Truth data added where simple EXPECT_* / assert checks are
    insufficient for algorithmic correctness.
  • CI runtime impact considered; team notified if significant.

Documentation

  • Public-facing APIs have Doxygen docs.
  • User-visible behavior changes have public docs, or a follow-up is
    tracked.

Code style

  • Naming follows the existing convention (snake_case vs camelCase) for
    the area being modified.

Dependencies

  • No new third-party dependencies, or the team has been notified and
    OSRB tickets filed.

… window decoder

Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
@eliotheinrich
eliotheinrich marked this pull request as ready for review July 7, 2026 17:35
@eliotheinrich
eliotheinrich requested a review from kvmto July 7, 2026 18:31
@eliotheinrich
eliotheinrich marked this pull request as draft July 7, 2026 20:33
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Comment thread libs/qec/include/cudaq/qec/pcm_utils.h Outdated
@eliotheinrich
eliotheinrich marked this pull request as ready for review July 10, 2026 19:57
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
@eliotheinrich eliotheinrich mentioned this pull request Jul 13, 2026
18 tasks
eliotheinrich and others added 2 commits July 13, 2026 15:20
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Comment thread libs/qec/include/cudaq/qec/pcm_utils.h
Comment thread libs/qec/lib/decoders/sliding_window.cpp
Comment thread libs/qec/lib/pcm_utils.cpp
@kvmto

kvmto commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

The rest seems good! :)

eliotheinrich and others added 3 commits July 13, 2026 16:25
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
Signed-off-by: Eliot Heinrich <38039898+eliotheinrich@users.noreply.github.com>
Signed-off-by: Eliot Heinrich <eheinrich@nvidia.com>
@eliotheinrich
eliotheinrich force-pushed the pr-boundary-alignment branch from 6cea65d to fa1a05e Compare July 14, 2026 00:20

@bmhowe23 bmhowe23 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @eliotheinrich!

@bmhowe23
bmhowe23 enabled auto-merge (squash) July 14, 2026 03:46
@bmhowe23
bmhowe23 merged commit 131c4d0 into NVIDIA:main Jul 14, 2026
24 checks passed
bmhowe23 added a commit to bmhowe23/cudaqx that referenced this pull request Jul 14, 2026
Resolve conflicts from PR NVIDIA#656 (num_boundary_syndromes) against the
declarative decoder-schema refactor:

- decoding_config.h / config.cpp: keep the schema-based machinery; the
  typed per-decoder config structs (incl. main's num_boundary_syndromes
  field on sliding_window_config) stay removed.
- sliding_window.cpp: integrate num_boundary_syndromes into the
  sliding_window parameter schema (uint64) so the framework accepts the
  key the constructor already reads, and mirror the constructor's
  num_boundary_syndromes <= num_syndromes_per_round constraint in the
  schema validate hook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Ben Howe <bhowe@nvidia.com>
bmhowe23 added a commit to bmhowe23/cudaqx that referenced this pull request Jul 15, 2026
…ridge branch

Main landed the squashed PR 670 plus NVIDIA#656/NVIDIA#673/NVIDIA#674/NVIDIA#678/NVIDIA#680/NVIDIA#683/NVIDIA#688/
NVIDIA#690/NVIDIA#691/NVIDIA#692.  Resolution keeps this branch's design and ports main's
content into it:

- Naming: main's GpuRoce{Transceiver,Factory,LinkCheck} map 1:1 onto this
  branch's DeviceGraph* files (the de-transport-ing follow-up requested in
  the PR 670 review).  Main's post-review fixes are ported into the
  renamed files: ring-size overflow + host-page-size alignment validation,
  gpu_id resolved from the decoder's cuda_device_id instead of an env var,
  the factory taking pinned_cuda_device, and the linkcheck exercising the
  new factory signature.
- Schema: per-decoder 'dispatch: host|device_graph' plus the top-level
  transport section stay; main's per-decoder 'transport:' key does not
  return.  cuda_device_id is adopted as a per-decoder placement knob
  (config struct + YAML trait), and the hsb script now injects
  'dispatch: device_graph' + cuda_device_id and drives the server with
  QEC_DEVICE_GRAPH_* env and the device_graph READY sentinel.
- Features adopted from main: decoder CUDA-device pinning (worker-thread
  pin via promise, graph-capture pin, hardware_guards.h), per-session
  decode counters + print_session_stats + QEC_DECODING_SERVER_STATS
  server-side stats printing, DecodingServer ctor exception safety,
  virtualized realtime decoder API (NVIDIA#674), CMP0126 fix, CUDA::cudart on
  the core lib, and the cudevice-archive dedup in the server link.
- DecodingSession combines main's set_graph_capture_device with this
  branch's reserved-SMs decode-graph capture
  (QEC_DEVICE_GRAPH_RESERVED_SMS).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ben Howe <bhowe@nvidia.com>
anjbur added a commit to anjbur/cudaqx that referenced this pull request Jul 16, 2026
…sliding window decoder (NVIDIA#656)"

This reverts commit 131c4d0.

Signed-off-by: Angela Burton <angelab@nvidia.com>
anjbur added a commit to anjbur/cudaqx that referenced this pull request Jul 16, 2026
Signed-off-by: Angela Burton <angelab@nvidia.com>
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.

Update sliding window decoder and canonicalize_for_rounds to use new syndrome format

3 participants