Repository navigation
[Bugfix][Store] Store the full byte range of typed Python buffers in put/upsert #4327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
he-yufeng
wants to merge
6
commits into
kvcache-ai:main
from
he-yufeng:fix/py-buffer-typed-truncation
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d808a71
[Bugfix][Store] Store the full byte range of typed Python buffers in …
he-yufeng 7351193
test(store): satisfy ruff on the touched store test file
he-yufeng 0353baf
test(store): strip the whitespace-only line next to the touched print
he-yufeng af22755
[Bugfix][Store] Reject strided 1-D views in put_parts/upsert_parts
he-yufeng 0838ebb
test(store): pin acceptance of extent-1 dims with non-canonical strides
he-yufeng 177f756
Merge remote-tracking branch 'upstream/main' into fix/py-buffer-typed…
he-yufeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same silent-wrong-bytes problem is still present in
upsert_partsandput_parts(L2903–2909 and L3163–3169 in this revision; GitHub won't let me anchor there since those lines aren't in the diff). Their guard checksndim == 1 && itemsize == 1but not strides, so a strided 1-D view likememoryview(b"abcdefgh")[::2]passes and gets stored as 4 contiguous bytes starting atptr.Since the helper is already here, keeping the existing guard and swapping the length is enough:
With
itemsize == 1the byte count doesn't change; the only new behavior is the contiguity check. It would also be worth extendingtest_non_contiguous_buffer_rejected:I think this belongs in the same PR rather than a follow-up: it's the same bug class, #4299 points at these guards as the reference behavior, and the PR description currently calls them "unchanged".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Both
put_partsandupsert_partsnow also requirePyBuffer_IsContiguous(info.view(), 'C'), so a strided 1-D view likememoryview(b"abcdefgh")[::2]is rejected instead of being stored as the wrong bytes.buf.request(false)passesPyBUF_STRIDES | PyBUF_FORMAT, so the strides ininfo.view()are real and the contiguity check actually sees them.Added
test_parts_strided_view_rejectednext totest_non_contiguous_buffer_rejectedcovering both entry points.