Skip to content

Handle strided arrays in Sinter decoding - #301

Open
danielgaskins wants to merge 1 commit into
quantumlib:mainfrom
danielgaskins:fix/sinter-strided-input
Open

Handle strided arrays in Sinter decoding#301
danielgaskins wants to merge 1 commit 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.

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