- 
                Notifications
    
You must be signed in to change notification settings  - Fork 140
 
[WIP] Add filtering support for IVF-PQ and BITMAP filtering for CAGRA #1478
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
base: main
Are you sure you want to change the base?
Conversation
Add cuvsFilter parameter to IVF_PQ, IVF_Flat, CAGRA, and TieredIndex search functions. - IVF_PQ: Add BITMAP and BITSET filter support - IVF_Flat: Add BITMAP and BITSET filter support - CAGRA: Add BITMAP and BITSET filter support - TieredIndex: Add BITSET filter support (BITMAP not supported) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- C API: Add cuvsFilter parameter to IVF_PQ, IVF_Flat, CAGRA, TieredIndex search - Rust: Add Filter trait with NoFilter, BitmapFilter, BitsetFilter implementations - Python: Add filter parameter to search functions - Go: Add filter creation and passing to C API - Tests: Add comprehensive filter tests for all index types (ann_tiered_index_c.cu) - Update function signatures and documentation examples Based on upstream/main to avoid formatting changes
This commit adds comprehensive test coverage for bitmap and bitset filtering functionality across multiple index types: - IVF-PQ: Added BuildSearchBitsetFiltered and BuildSearchBitmapFiltered tests - IVF-Flat: Added BuildSearchBitsetFiltered and BuildSearchBitmapFiltered tests - CAGRA: Replaced BuildSearchFiltered with BuildSearchBitsetFiltered and added BuildSearchBitmapFiltered - Added TIERED_INDEX_C_TEST configuration to CMakeLists.txt All tests verify correct filter behavior by creating filters that remove even-indexed vectors and asserting all returned neighbors are odd-indexed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Move filter parameter to end of search() signature to match CAGRA and IVF-Flat, preventing breakage of existing code using positional args. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Remove TieredIndex BITMAP/BITSET filter changes and tests as they are unrelated to the IVF-PQ, IVF-Flat, and CAGRA filter additions. Preserved in branch: feat/tiered-index-filters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| 
           /ok to test 6ee63bf  | 
    
| 
           Thanks so much for the contribution @jeremywgleeson! This is a few important features that we've had on our roadmap and we really appreciate your help here.  | 
    
Remove test configuration for ann_tiered_index_c.cu which was deleted in the TieredIndex revert commit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| 
           /ok to test 577d5de  | 
    
- Update copyright header to SPDX format - Apply cargo fmt to function signatures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add #include <cuvs/neighbors/common.h> to provide cuvsFilter type definition required by cuvsIvfPqSearch function signature. Fixes compilation errors: - error: unknown type name 'cuvsFilter' - error: 'NO_FILTER' undeclared - error: 'cuvsFilter' has not been declared 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| 
           /ok to test 760b3d1  | 
    
Update copyright headers for files modified in this PR to include 2025. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add NO_FILTER initialization to cuvsIvfPqSearch call in example to match updated API signature. Fixes compilation error: error: too few arguments to function 'cuvsIvfPqSearch' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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 C++ cagra and ivf-* search code doesn't currently support using a bitmap filter - and passing one to it should throw an exception saying Unsupported sample filter type right now.    Do the tests that you've added for the bitmap filters for cagra and ivf-pq/ivf-flat work for you?
We'd love to add this bitmap support to the cagra and ivf indices, but the challenge right now is to do this without increasing the binary size of the libcuvs.so (which has the filter type as a template parameter to the search methods).
I'm wondering if we should break up this PR into multiple changes - and just have the bitset changes for ivf-pq and the rust api in this PR?
| 
           /ok to test e6feca5  | 
    
Summary
This PR adds filter support to the IVF-PQ C API (which previously had no filtering capability) and adds BITMAP filter support to the CAGRA and IVF-Flat C API (which only supported BITSET filters). Additionally, it adds strong filter support to the Rust crate, which was previously not exposed.
Changes
IVF-PQ C API - Add Filter Support
cuvsFilter filterparameter tocuvsIvfPqSearchIVF-Flat C API - Add BITMAP Filter Support
cuvsIvfFlatSearchCAGRA C API - Add BITMAP Filter Support
cuvsCagraSearchComprehensive Test Coverage
ann_ivf_pq_c.cu)ann_ivf_flat_c.cu)ann_cagra_c.cu)Rust Language Bindings - Complete Filter Support
filters.rsmodule with comprehensive filter utilitiesbitset_from_excluded_indices()- Create global filter from excluded indicesbitset_from_included_indices()- Create global filter from included indicesbitmap_from_excluded_indices()- Create per-query filters from excluded indicesbitmap_from_included_indices()- Create per-query filters from included indicesOther Language Bindings
NO_FILTERby defaultBackward Compatibility
C API - Breaking Changes:
{.type = NO_FILTER, .addr = (uintptr_t)NULL}for no filtering)(Based on #664 , it seems that this type of change is not considered breaking?)
Rust API - Breaking Changes:
None)Python API - Non-Breaking:
Go API - Non-Breaking:
Testing
All new functionality is covered by unit tests that:
0xAAAAAAAA)Closes #1464