Auto select CAGRA build algorithm for hnsw::build#1719
Conversation
bb78635 to
23a0b16
Compare
mfoerste4
left a comment
There was a problem hiding this comment.
I did not go over all memory estimates in detail but suggest to align predictions with real data.
Is autotuning of ACE params part of a different PR? Besides the open question on the file location we might want to at least set the number of partitions dynamically.
| raft::make_host_matrix_view<const T, int64_t>(dataset, nrow, this->dim_)); | ||
| } | ||
|
|
||
| auto dataset_view = raft::make_host_matrix_view<const T, int64_t>(dataset, nrow, this->dim_); |
There was a problem hiding this comment.
Is the data expected to always reside in host memory?
There was a problem hiding this comment.
ACE only supports host memory right now. The main reasons is that we expect the data size to be large and memory-mapped. Further, we do the partitioning and reordering on the host since there is no benefit of moving it to the GPU only to write it to disk afterwards.
Anyways, I think we can support device datasets easily since these should not end up using ACE with this heuristic. @tfeher What do you think?
| // ACE build and search example. | ||
| cagra_build_search_ace(res); |
There was a problem hiding this comment.
maybe we want to rename this to something generic now that the selection is hidden from the user.
julianmi
left a comment
There was a problem hiding this comment.
I did not get a chance to fully review the memory heuristics yet. I wonder how we can test it though. Should max_host_memory_gb and max_gpu_memory_gb be optional HNSW parameters that we could use to test that the expected algorithm is used based on memory limits set?
Co-authored-by: Julian Miller <mail@julian-miller.de>
Co-authored-by: Julian Miller <mail@julian-miller.de>
julianmi
left a comment
There was a problem hiding this comment.
Thanks @mfoerste4. These are great improvements!
I agree that the host might stick to the percentage. We have much less control over the host which has many other processes running. Also, high memory pressure reduces the performance significantly. We might want to test with increasing the limit to 90% given the added 2 GB static memory. |
achirkin
left a comment
There was a problem hiding this comment.
Looks good overall. A few small suggestions below.
tfeher
left a comment
There was a problem hiding this comment.
Fixed few smaller issues.
KyleFromNVIDIA
left a comment
There was a problem hiding this comment.
Just one small request, otherwise looks good
KyleFromNVIDIA
left a comment
There was a problem hiding this comment.
Approving as I will be out for the first few days of next week and don't want to hold this up. Please address my above comment before merging.
achirkin
left a comment
There was a problem hiding this comment.
Thanks for the updates! lgtm
|
/merge |
Configuring HNSW graph build using CAGRA is complicated, because CAGRA offers multiple build algorithms. This PR implements an automatic algorithm selection. The goal is to have a simplified API, where the user needs to set only two parameters that control graph size and quality (
Mandef_constructionrespectively). This shall be familiar for HNSW users, and allows easier adaption of cuvs accelerated HNSW graph building.If we have enough memory (host and GPU) to do both the KNN graph building and optimization in memory, then we choose in memory build, and let
cagra::index_params::from_hnsw_paramsderive the additional configuration parameters.If the build would require more memory then available, then we choose ACE method and let the number of partitions derived using #1603.
For host we query the os for available memory, for GPU it is assumed that the whole device memory is available.