Skip to content
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

Automatic adjustment of itopk size according to filtering rate #509

Merged
merged 30 commits into from
Feb 1, 2025

Conversation

anaruse
Copy link
Contributor

@anaruse anaruse commented Dec 4, 2024

This PR is based on #492.

The new multi-CTA algorithm proposed in #492 can be used to obtain good recall even with high filtering rates. However, good recall cannot be obtained unless the number of search iterations, or itopk size, one of CAGRA's search parameters, is appropriately increased according to the filtering rate. Therefore, users need to find the appropriate itopk size according to the filtering rate by trial and error, which is a pain.

This PR is intended to alleviate this problem by internally calculating the filtering rate and automatically adjusting the itopk size accordingly.

@anaruse anaruse requested a review from a team as a code owner December 4, 2024 06:40
Copy link

copy-pr-bot bot commented Dec 4, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions bot added the cpp label Dec 4, 2024
@anaruse anaruse marked this pull request as draft December 4, 2024 06:40
…when the number of results is large

Fix some issues

Fix lower recall issue with new multi-cta algo

Removing redundant code and changing some parameters

Update cpp/src/neighbors/detail/cagra/search_plan.cuh

Co-authored-by: Tamas Bela Feher <[email protected]>

Remove an unnecessary line and satisfy clang-format
@anaruse anaruse force-pushed the adjust_itopk branch 2 times, most recently from d2e8d4c to aa7cfde Compare December 5, 2024 09:52
@cjnolet cjnolet added improvement Improves an existing functionality non-breaking Introduces a non-breaking change vector search labels Dec 5, 2024
@cjnolet
Copy link
Member

cjnolet commented Dec 5, 2024

/ok to test

* The value must be equal to or greater than 0.0 and less than 1.0. Default value is
* negative, in which case the filtering rate is automatically set.
*/
float filtering_rate = -1.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. So is specifying this value an alternative to explicitly computing the sparsity of the pre-filtering bitset (which would introduce additional compute into the search)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be clearer to write "automatically computed" rather than "automatically set" here. I will fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that. "automatically compted" is perfect.

@@ -349,9 +351,18 @@ void search(raft::resources const& res,
auto& sample_filter =
dynamic_cast<const cuvs::neighbors::filtering::bitset_filter<uint32_t, int64_t>&>(
sample_filter_ref);
search_params params_copy = params;
if (params.filtering_rate < 0.0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see- the filtering rate set to "auto" will automatically calculate the sparsity of the bitset while a user can skip having to compute this if they set the filtering rate directly. I like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct. By default, it calculates the filtering rate, but if the user specifies the filtering rate, that calculation is skipped.

@cjnolet cjnolet changed the base branch from branch-24.12 to branch-25.02 January 23, 2025 18:39
@cjnolet cjnolet marked this pull request as ready for review January 23, 2025 18:39
@cjnolet
Copy link
Member

cjnolet commented Jan 23, 2025

/ok to test

@cjnolet
Copy link
Member

cjnolet commented Jan 23, 2025

@anaruse it looks like there's some failed style checkers in this PR. Can you run the git pre-commit hooks to fix them? Here's the docs to enable them.

@cjnolet
Copy link
Member

cjnolet commented Jan 29, 2025

/ok to test

@cjnolet
Copy link
Member

cjnolet commented Jan 30, 2025

/ok to test

@cjnolet
Copy link
Member

cjnolet commented Jan 30, 2025

@anaruse I think the changes look great. Can you also add the new search param to the main indexing docs for completeness? That would be the file in docs/source/indexes/cagra.rst

@anaruse anaruse requested a review from a team as a code owner January 31, 2025 08:23
@anaruse
Copy link
Contributor Author

anaruse commented Jan 31, 2025

@anaruse I think the changes look great. Can you also add the new search param to the main indexing docs for completeness? That would be the file in docs/source/indexes/cagra.rst

I've updated text in the filtering considerations section of docs/source/indexes/cagra.rst. What do you think of this?

@cjnolet
Copy link
Member

cjnolet commented Feb 1, 2025

/ok to test

@cjnolet
Copy link
Member

cjnolet commented Feb 1, 2025

/ok to test

@cjnolet
Copy link
Member

cjnolet commented Feb 1, 2025

/merge

@rapids-bot rapids-bot bot merged commit 888a34f into rapidsai:branch-25.02 Feb 1, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp improvement Improves an existing functionality non-breaking Introduces a non-breaking change vector search
Projects
Development

Successfully merging this pull request may close these issues.

4 participants