Iterative CAGRA-Q - #1810
Iterative CAGRA-Q#1810irina-resh-nvda wants to merge 78 commits into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
… search - Configurable growth-phase in-build search params (itopk_size, search_width, max_iterations) and internal/smem dtype; itopk auto-forced on the final full-size iteration. - Decouple compression params used during iterative construction from the target index compression. - Add shuffle_dataset option; fix out-of-bounds access from the in-place raft gather by switching to an out-of-place gather.
…around) The shuffle_dataset path used an out-of-place gather into a temporary buffer to work around an illegal memory access in raft's in-place gather overload when n_rows * row_len exceeded 2^31 (32-bit index overflow). That bug is now fixed upstream in raft (NVIDIA/raft#3059, closes #3055), which the cuvs raft pin now includes. Revert to the in-place gather to drop the extra full-size temporary allocation and copy.
8fc10ac to
4f4068a
Compare
|
/ok to test 100db4f |
|
It looks good to me |
|
/ok to test 19f7397 |
|
|
||
| auto cagra_graph = | ||
| raft::make_host_matrix<IdxT, int64_t>(dev_graph.extent(0), dev_graph.extent(1)); | ||
| raft::copy(cagra_graph.data_handle(), |
There was a problem hiding this comment.
Wait - this should be removed. We are doing a D2H of the entire graph. And then if you look at the caller we are doing H2D back again. update_graph member function does a copy to device.
cuvs/cpp/src/neighbors/cagra.cuh
Lines 328 to 331 in df7730d
cuvs/cpp/include/cuvs/neighbors/cagra.hpp
Lines 704 to 708 in 5191775
|
/ok to test ffd1a1d |
|
/ok to test abd796c |
|
/ok to test e218f9e |
tfeher
left a comment
There was a problem hiding this comment.
Thanks everyone for pushing it through the finish line, the PR looks good to me!
| reconstruct_vpq_queries<T, half, int64_t>( | ||
| res, | ||
| *vpq_queries, | ||
| static_cast<uint64_t>(offset), | ||
| static_cast<uint32_t>(batch_size), | ||
| raft::make_device_matrix_view<T, int64_t>( | ||
| reconstructed_batch_queries->data_handle(), batch_size, query_ld)); | ||
| auto batch_query_view = raft::make_device_matrix_view<const T, int64_t>( | ||
| reconstructed_batch_queries->data_handle(), batch_size, query_ld); |
There was a problem hiding this comment.
Nitpick, but we can construct the view first and use in two places
| reconstruct_vpq_queries<T, half, int64_t>( | |
| res, | |
| *vpq_queries, | |
| static_cast<uint64_t>(offset), | |
| static_cast<uint32_t>(batch_size), | |
| raft::make_device_matrix_view<T, int64_t>( | |
| reconstructed_batch_queries->data_handle(), batch_size, query_ld)); | |
| auto batch_query_view = raft::make_device_matrix_view<const T, int64_t>( | |
| reconstructed_batch_queries->data_handle(), batch_size, query_ld); | |
| auto batch_query_view = raft::make_device_matrix_view<const T, int64_t>( | |
| reconstructed_batch_queries->data_handle(), batch_size, query_ld); | |
| reconstruct_vpq_queries<T, half, int64_t>( | |
| res, | |
| *vpq_queries, | |
| static_cast<uint64_t>(offset), | |
| static_cast<uint32_t>(batch_size), | |
| batch_query_view); |
Most of Artem's comments were addressed, I have created issue #2610 to track the open question from Artem's review.
Build CAGRA on PQ datasets with Iterative CAGRA-Q
Iterative cagra graph construction using CAGRA-Q search.
This PR improves the iterative CAGRA build method by enabling PQ compression: the dataset is compressed before the iterative search starts, and CAGRA-Q is used to iteratively update the KNN graph.
This is the first time we are introducing building CAGRA on (PQ) quantized datasets directly.
This PR also adds support for C and Python APIs for creating a PQ dataset and building a cagra graph on it. We also add support to update_dataset from dense->PQ or PQ->dense. Serializing the index is also supported.
Example Runnable workflow