Repository navigation
Conversation
A quantized IVF column keeps each vector's int8 or binary form in its cell and the vector as it was inserted in _ivf_vectors, but ivf_get_vector_data() returned the cell's bytes for every column. A point query then read the column's float32 elements past the end of the quantized vector, and a full scan or a KNN query returned the quantized bytes as the column's value. A quantized column's vectors are now read from _ivf_vectors.
This was referenced Oct 23, 2026
This branch has not been deployed
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.
On an IVF column with
quantizer=int8orquantizer=binary, a point query reads past the end of the vector it returns, and a full scan or a KNN query returns the quantized bytes as the column's value.A quantized column keeps each vector's int8 or binary form in its cell and the vector as it was inserted in
_ivf_vectors, butivf_get_vector_data()returned the cell's bytes,ivf_vec_size()of them, for every column. A quantized column's vectors are now read from_ivf_vectors, through a cached statement like the rowid-map lookup's, which is reset as soon as its row is copied out so a read-only query leaves no statement in progress.Built with
-DSQLITE_VEC_EXPERIMENTAL_IVF_ENABLE=1, on main none of 10 int8 or binary rows reads back as inserted from a point query, a full scan or a KNN query, before or aftercompute-centroids; here all 10 do from each, and an unquantized column reads back as before. Test:test_ivf_quantized_vectors_read_backin test-ivf-quantization.py, parametrized over int8 and binary; both fail on main and pass here. The Python suite passes (with the IVF define, 303 passed, 4 skipped; without it, 239 passed, 68 skipped), under ASan and UBSan as well, and both builds' warnings are main's.#313 fixes the quantized paths of
clear-centroids,set-centroidandassign-vectorsand leaves this one as it is. This merges cleanly with it and with every other open PR that touches the IVF code, #343 and #347 included.Origin. Found in the IVF port to photostructure/sqlite-vec, photostructure#12 (65817f4), which lists it among the port's differences from upstream; the change and its test are written here for asg017's main. No open or closed PR or issue here makes the same change.