Skip to content

Add support for half in CAGRA+HNSW #813

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

Open
wants to merge 11 commits into
base: branch-25.06
Choose a base branch
from

Conversation

lowener
Copy link
Contributor

@lowener lowener commented Apr 8, 2025

This PR add support for half dtype for HNSW in C++, C and python, as well as some tests with it. I had to modify a bit the HNSW patch in order to enable computation on half data types.
I also added the support of inner-product distance for int8/uint8 data type.

Signed-off-by: Mickael Ide <[email protected]>
@lowener lowener added non-breaking Introduces a non-breaking change C++ feature request New feature or request labels Apr 8, 2025
@lowener lowener requested a review from a team as a code owner April 8, 2025 14:54
@lowener lowener requested a review from raydouglass April 8, 2025 14:54
Copy link
Member

@divyegala divyegala 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 your improvement to the docs! Looks like you caught a lot of typos.

} else if (metric == cuvs::distance::DistanceType::InnerProduct) {
space_ = std::make_unique<hnswlib::InnerProductSpace>(dim);
space_ =
std::make_unique<hnswlib::InnerProductSpace<T, typename hnsw_dist_t<T>::type>>(dim);
}
} else if constexpr (std::is_same_v<T, std::int8_t> or std::is_same_v<T, std::uint8_t>) {
Copy link
Member

Choose a reason for hiding this comment

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

With your changes to the template functions in hnswlib, I think we should be able to support int8 and uint8 for InnerProduct now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I added support for that in the PR

@lowener lowener requested a review from divyegala April 14, 2025 11:20
@divyegala divyegala removed request for a team and raydouglass April 14, 2025 18:12
Signed-off-by: Mickael Ide <[email protected]>
Copy link

copy-pr-bot bot commented Apr 17, 2025

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.

@rapidsai rapidsai deleted a comment from copy-pr-bot bot Apr 18, 2025
@lowener
Copy link
Contributor Author

lowener commented Apr 18, 2025

/ok to test 6660dff

@lowener lowener requested a review from divyegala April 24, 2025 13:10
Signed-off-by: Mickael Ide <[email protected]>
@rapidsai rapidsai deleted a comment from copy-pr-bot bot Apr 24, 2025
@lowener
Copy link
Contributor Author

lowener commented Apr 24, 2025

/ok to test c6a93c2

Comment on lines 91 to 92
# Note that inner_product tests use normalized input which we cannot
# represent in int8, therefore we test only sqeuclidean metric here.
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this comment now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ CMake cpp feature request New feature or request non-breaking Introduces a non-breaking change Python
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants