Skip to content

Handle strided arrays in Sinter decoding - #301

Closed
danielgaskins wants to merge 5 commits into
quantumlib:mainfrom
danielgaskins:fix/sinter-strided-input
Closed

danielgaskins wants to merge 5 commits into
quantumlib:mainfrom
danielgaskins:fix/sinter-strided-input

Conversation

@danielgaskins

Copy link
Copy Markdown

decode_shots_bit_packed accepted non-contiguous NumPy views, but treated the bytes within each shot as contiguous. For a view such as shots[:, ::2], this could read the wrong bytes and decode a different set of detectors.

Use pybind11's two-dimensional array accessor so both strides are respected. Add a regression test where the second byte of each shot is non-contiguous.

Tests:

  • bazel test --jobs=1 src/... //docs:tutorial_jupytext_sync_test
  • clang-format-14 --dry-run --Werror src/tesseract_sinter_compat.pybind.h

@danielgaskins
danielgaskins requested a review from a team as a code owner August 14, 2026 23:13
@danielgaskins
danielgaskins requested review from oscarhiggott and removed request for a team August 14, 2026 23:13
@danielgaskins

Copy link
Copy Markdown
Author

Yes, this also handles Fortran-contiguous arrays. unchecked<2>() uses both NumPy strides for each (shot, byte) access. I checked a two-byte Fortran-order input locally, and it produced the expected predictions.

For C-contiguous input, the accessor does a little more index calculation than the previous raw pointer access. I have not benchmarked the two implementations, so I do not want to claim zero overhead. The decoding work is likely to dominate, but a contiguous fast path could be added later if profiling shows this matters.

@danielgaskins

Copy link
Copy Markdown
Author

Current main now handles this in the shared decode_sinter_shots_bit_packed helper added by #256, with coverage for row-strided, column-strided, and Fortran-ordered inputs. That covers the original bug more broadly than this branch, so I’m closing this PR as superseded. Thanks for the reviews and branch updates.

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.

5 participants