Repository navigation
Align NumPy inputs before native processing - #143
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
C-contiguous NumPy arrays can still start at an address that is not aligned for float32. A view with a one-byte offset currently reaches misaligned float loads during RaBitQKMeans training.
Copy unaligned two-dimensional inputs into aligned, owned arrays at the shared binding conversion boundary. Already-aligned compatible arrays retain their existing path, and input contents remain unchanged. Add read-only offset-1/2/3 regressions for both clustering classes and all three index wrappers, and document the copy behavior.
No public signature, saved-index format, or dependency changes.
Testing
Validated this branch independently of the HNSW seed fix and IVF append optimization on Linux x86-64, using GCC 14.3, GoogleTest 1.14.0, Python 3.13, and
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF:OpenMPBindingtest passes.load of misaligned address. This branch passes that reproducer and 15/15 alignment regressions with-fsanitize=alignment -fno-sanitize-recover=alignmenton the bindings and included template code. This is a focused alignment check, not a whole-library ASan/UBSan run.git diff --checkpass.This is a correctness fix; no throughput improvement is claimed. Windows, macOS, and ARM64 execution remain for CI.