Add QT_0bit to ScalarQuantizer for centroid-only IVF distance (#5079)#5079
Open
mnorris11 wants to merge 1 commit intofacebookresearch:mainfrom
Open
Add QT_0bit to ScalarQuantizer for centroid-only IVF distance (#5079)#5079mnorris11 wants to merge 1 commit intofacebookresearch:mainfrom
mnorris11 wants to merge 1 commit intofacebookresearch:mainfrom
Conversation
Contributor
|
@mnorris11 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100348052. |
mnorris11
pushed a commit
to mnorris11/faiss
that referenced
this pull request
Apr 11, 2026
…okresearch#5079) Summary: Adds a new ScalarQuantizer::QT_0bit type that encodes 0 bits per component, enabling IndexIVFScalarQuantizer to operate in centroid-only distance mode (code_size=0). In this mode, distance_to_code() returns the coarse distance from the quantizer, no per-vector data is stored, and reconstruction returns the centroid vector. This is useful for IVF configurations where only query-to-centroid distances are needed (e.g., Unicorn's SQ0 use case). Changes: - Add QT_0bit enum to ScalarQuantizer::QuantizerType - Add IVFCoarseDistanceScanner that returns coarse_dis from set_list() - Handle code_size=0 in encode/decode/reconstruct/add paths - Add 'SQ0' to index_factory - Force by_residual=false for QT_0bit - Guard memcpy in ArrayInvertedLists for code_size=0 - Handle QT_0bit in index_read.cpp validation switch - Add tests for L2, IP, and index_factory --- Differential Revision: D100348052
6b9279c to
98e1c63
Compare
mnorris11
pushed a commit
to mnorris11/faiss
that referenced
this pull request
Apr 13, 2026
…okresearch#5079) Summary: Adds a new ScalarQuantizer::QT_0bit type that encodes 0 bits per component, enabling IndexIVFScalarQuantizer to operate in centroid-only distance mode (code_size=0). In this mode, distance_to_code() returns the coarse distance from the quantizer, no per-vector data is stored, and reconstruction returns the centroid vector. This is useful for IVF configurations where only query-to-centroid distances are needed (e.g., Unicorn's SQ0 use case). Changes: - Add QT_0bit enum to ScalarQuantizer::QuantizerType - Add IVFCoarseDistanceScanner that returns coarse_dis from set_list() - Handle code_size=0 in encode/decode/reconstruct/add paths - Add 'SQ0' to index_factory - Force by_residual=false for QT_0bit - Guard memcpy in ArrayInvertedLists for code_size=0 - Handle QT_0bit in index_read.cpp validation switch - Add tests for L2, IP, and index_factory --- Differential Revision: D100348052
…okresearch#5079) Summary: Pull Request resolved: facebookresearch#5079 Adds a new ScalarQuantizer::QT_0bit type that encodes 0 bits per component, enabling IndexIVFScalarQuantizer to operate in centroid-only distance mode (code_size=0). In this mode, distance_to_code() returns the coarse distance from the quantizer, no per-vector data is stored, and reconstruction returns the centroid vector. This is useful for IVF configurations where only query-to-centroid distances are needed (e.g., Unicorn's SQ0 use case). Changes: - Add QT_0bit enum to ScalarQuantizer::QuantizerType - Add IVFCoarseDistanceScanner that returns coarse_dis from set_list() - Handle code_size=0 in encode/decode/reconstruct/add paths - Add 'SQ0' to index_factory - Force by_residual=false for QT_0bit - Guard memcpy in ArrayInvertedLists for code_size=0 - Handle QT_0bit in index_read.cpp validation switch - Add tests for L2, IP, and index_factory --- Differential Revision: D100348052
98e1c63 to
705b360
Compare
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:
Adds a new ScalarQuantizer::QT_0bit type that encodes 0 bits per component, enabling IndexIVFScalarQuantizer to operate in centroid-only distance mode (code_size=0). In this mode, distance_to_code() returns the coarse distance from the quantizer, no per-vector data is stored, and reconstruction returns the centroid vector.
This is useful for IVF configurations where only query-to-centroid distances are needed (e.g., Unicorn's SQ0 use case).
Changes:
Differential Revision: D100348052