Repository navigation
Conversation
Keep the previous valid center when cancellation or quantization yields a zero center, before updating center movement bounds. Cover opposite and underflowing vector and halfvec inputs, builds, and table rewrites. Audit finding: F003
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.
Valid, nonzero input vectors can produce a zero cluster center when their contributions cancel. Floating-point quantization can also round a nonzero mean to zero. The resulting center cannot be normalized, causing IVFFlat cosine index creation to fail with:
ERROR: Zero norm detected. Please report a bug.Retain the corresponding previous valid center whenever an updated center has zero norm. Apply this fallback before computing center-movement distances and updating Elkan bounds. Final center validation remains enabled.
Example
Two opposite vectors are sufficient to reproduce the failure:
Both input vectors have nonzero norms, but their mean is
[0,0].The regression test also covers means that round to zero for both
vectorandhalfvec.The complete reproducer is included in
test/t/049_f003_regression.pl.Validation
vectorandhalfvec.REINDEX,VACUUM FULL, andCLUSTERusing the primary-keyindex.
tests on PostgreSQL 17.