Fix API that approximates the size of FAISS indexes#75
Open
CascadingRadium wants to merge 5 commits into
Open
Conversation
Co-authored-by: Copilot <copilot@github.com>
faiss_IndexBinary_size and faiss_Index_sizeThere was a problem hiding this comment.
Pull request overview
This PR updates the FAISS C “_ex” APIs for index sizing to return a more useful (approximate) in-memory byte estimate instead of effectively returning the pointer size, with the goal of supporting GPU-memory eligibility/throttling decisions when cloning indexes.
Changes:
- Changes
faiss_Index_size/faiss_IndexBinary_sizeto return an error code (int) and write the size to an out-parameter (size_t*). - Implements a new size estimate based on
ntotal * code_sizeplus extra IVF-related overhead (centroids + stored IDs). - Updates/expands header documentation and adds IVF includes to enable IVF-specific handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| c_api/Index_c_ex.h | Updates C API signature + documentation for faiss_Index_size. |
| c_api/Index_c_ex.cpp | Implements the new size estimation logic for float indexes (including IVF path). |
| c_api/IndexBinary_c_ex.h | Updates C API signature + documentation for faiss_IndexBinary_size. |
| c_api/IndexBinary_c_ex.cpp | Implements the new size estimation logic for binary indexes (including IVF path). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
capemox
previously approved these changes
May 11, 2026
Thejas-bhat
reviewed
May 11, 2026
Member
|
looks good but can you please add the MB for it? |
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.
8bytes for thefaiss_IndexBinary_sizeand thefaiss_Index_sizeAPIsquite useless as it always returns
8after performing asizeofoperation.this API cannot be used.
it would require if we bring the entire index to the memory, which would be useful in
approximating how much memory must be available in the GPU to
consider the FAISS index to be eligible for cloning.