-
Notifications
You must be signed in to change notification settings - Fork 197
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
Add sample filtering for ivf_flat. Filtering code refactoring and cleanup #1541
Add sample filtering for ivf_flat. Filtering code refactoring and cleanup #1541
Conversation
Pull requests from external contributors require approval from a |
@achirkin @cjnolet Would it be possible for you folks to run some tests, if you don't mind? :) The reason is that I'm leaving Meta in 1 week and then go to a vacation for several weeks, and we're having a holiday on Monday, so it would be nice if this PR could be merged this week. Please let me know on how I can speed up the process. Thanks. |
/ok to test |
@alexanderguzhva done. Do you mind merging your changes forward into |
@@ -65,7 +65,7 @@ struct NoneSampleFilter { | |||
* }; | |||
* | |||
* Initialize it as: | |||
* using filter_type = IndexSampleFilter<idx_t>; |
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.
Instead of raft/neighbors/sample_filter.cuh
, we use the suffix _types
to denote header files that contain important vocabulary bits for interacting w/ any public APIs not in raft/core
. Can you rename this file to neighbors/sample_filter_types.hpp
? It's also important that any functions in these files be accessible from host (and conditionally accessible from device). Can you change all __host__ __device__
to _RAFT_HOST_DEVICE
(from core/detail/macros.hpp
)?
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.
@cjnolet sure, 23.08.
2cf2624
to
61040c5
Compare
cpp/include/raft/neighbors/detail/ivf_pq_compute_similarity-ext.cuh
Outdated
Show resolved
Hide resolved
cpp/include/raft/neighbors/detail/ivf_pq_compute_similarity-inl.cuh
Outdated
Show resolved
Hide resolved
cpp/src/neighbors/detail/ivf_flat_interleaved_scan_float_float_int64_t.cu
Outdated
Show resolved
Hide resolved
cpp/src/neighbors/detail/ivf_flat_interleaved_scan_int8_t_int32_t_int64_t.cu
Outdated
Show resolved
Hide resolved
@@ -15,22 +15,28 @@ | |||
*/ | |||
|
|||
#include <raft/neighbors/detail/ivf_flat_interleaved_scan-inl.cuh> | |||
#include <raft/neighbors/sample_filter.cuh> |
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.
Rather than marking all of them, I'll just point out here that I think a search and replace might be in order.
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.
Thanks, it seems that my grep did not work as I expected somewhy O_o, I'll fix that.
Also, what about the problem in check-style, bcz it seems to be complaining on /python/raft-dask/pyproject.toml
and /python/pylibraft/pyproject.toml
?
/ok to test |
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.
Sorry for the late response, LGTM!
refinement_index.metric(), | ||
1, | ||
k, | ||
raft::distance::is_min_close(metric), | ||
// TODO: add the filtering support |
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.
I think, we can remove this todo because refine
does not need filtering support (it takes already filtered results).
Am I right, @cjnolet?
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.
That sounds right: if the neighbor candidates are already filtered, then we do not need any extra filtering in refine.
…ivf_flat_search_with_filtering
/ok to test |
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.
LGTM. Thanks @alexanderguzhva for this feature!
/ok to test |
/merge |
The PR does the following:
ivf_flat::search_with_filtering()
call in the same way the filtering was introduced to ivf_pq in Introduce sample filtering to IVFPQ index search #1513sample_filter.cuh
fromraft/neighbor/detail
toraft/neighbor
NoneSampleFilter
fromraft::neighbor::ivf_pq::detail
namespace toraft::neighbor::filtering
namespaceNoneSampleFilter
toNoneIvfSampleFilter
and template argumentSampleFilterT
toIvfSampleFilterT
resource::get_workspace_resource(handle)
inivf_flat-inl.cuh
in asearch_with_filtering()
call (which was copied fromsearch()
call with the same problem)ivf_pq-inl.h
ivf_pq-inl.h