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

Output non-normalized distances in IVF-PQ and brute-force KNN #892

Merged
merged 6 commits into from
Oct 6, 2022

Conversation

Nyrio
Copy link
Contributor

@Nyrio Nyrio commented Oct 5, 2022

Solves point 9 of #711 (the observed errors were due to comparing distances at different scales).

This PR does two things:

  • Changes the naive BF KNN to not normalize int when converting to float and simply cast, resulting in distances in the same scale as the output of IVF-Flat (and solving errors observed in tests).
  • Changes IVF-PQ to output distances in the original scale and not the normalized scale, consistently with IVF-Flat.

@Nyrio Nyrio requested a review from a team as a code owner October 5, 2022 14:03
@github-actions github-actions bot added the cpp label Oct 5, 2022
@Nyrio Nyrio added improvement Improvement / enhancement to an existing function breaking Breaking change labels Oct 5, 2022
Copy link
Contributor

@achirkin achirkin left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I think we can make it a bit less complicated, see the couple comments

cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh Outdated Show resolved Hide resolved
@Nyrio
Copy link
Contributor Author

Nyrio commented Oct 5, 2022

There are quite a few IVF-PQ cases where this PR gives worse results than before, I'll look into those.

@Nyrio Nyrio added the 5 - DO NOT MERGE Hold off on merging; see PR for details label Oct 5, 2022
@Nyrio
Copy link
Contributor Author

Nyrio commented Oct 6, 2022

Note: the worse test results that I observed in IVF-PQ are due to how raft::CompareApprox works: some mismatches were previously tolerated because the absolute error was lower than eps, which could only happen in the normalized scale but doesn't happen anymore in the original scale. So there is not much more we can do. Note that the tests are passing anyway.

Also, I am removing the "breaking" flag, since IVF-PQ was added in the same release.

@Nyrio Nyrio added 3 - Ready for Review non-breaking Non-breaking change and removed 5 - DO NOT MERGE Hold off on merging; see PR for details breaking Breaking change labels Oct 6, 2022
Copy link
Contributor

@achirkin achirkin left a comment

Choose a reason for hiding this comment

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

Thanks, the changes seem nice and non-intrusive to me. Just couple of tiny suggestions.

cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh Outdated Show resolved Hide resolved
cpp/include/raft/spatial/knn/detail/ivf_pq_search.cuh Outdated Show resolved Hide resolved
Copy link
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

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

Thanks Louis for the PR, it looks good to me!

Copy link
Contributor

@achirkin achirkin left a comment

Choose a reason for hiding this comment

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

Thanks!

@cjnolet
Copy link
Member

cjnolet commented Oct 6, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit e2b6399 into rapidsai:branch-22.10 Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge cpp improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants