feat: add diskann index#369
Open
richyreachy wants to merge 136 commits into
Open
Conversation
… feat/diskann_index
… feat/diskann_index
| -Wl,--whole-archive | ||
| $<TARGET_FILE:core_knn_flat_static> | ||
| $<TARGET_FILE:core_knn_flat_sparse_static> | ||
| $<TARGET_FILE:core_knn_hnsw_static> |
|
|
||
| virtual ~DiskAnnQueryParams() = default; | ||
|
|
||
| int list_size() const { |
… feat/diskann_index
egolearner
reviewed
Jun 2, 2026
| ::memcpy(&(vec_value[0]), node_fp_coords_copy, meta_.element_size()); | ||
|
|
||
| topk_heap.emplace(cached_neighbor.first, | ||
| VectorInfo(cur_expanded_dist, vec_value)); |
egolearner
reviewed
Jun 2, 2026
|
|
||
| std::string vec_value; | ||
| vec_value.resize(meta_.element_size()); | ||
| ::memcpy(&(vec_value[0]), data_buf, meta_.element_size()); |
Collaborator
There was a problem hiding this comment.
这里有两次copy,先拷贝到data_buf,再拷贝到vec_value,可以只拷贝到vec_value,用c_str()做距离计算吗?
egolearner
reviewed
Jun 2, 2026
| ::memcpy(&(vec_value[0]), data_buf, meta_.element_size()); | ||
|
|
||
| topk_heap.emplace(frontier_neighbor.first, | ||
| VectorInfo(cur_expanded_dist, vec_value)); |
egolearner
reviewed
Jun 2, 2026
| std::vector<AlignedRead> frontier_read_reqs; | ||
| frontier_read_reqs.reserve(2 * beam_width_); | ||
|
|
||
| std::vector<std::pair<diskann_id_t, std::pair<uint32_t, diskann_id_t *>>> |
egolearner
reviewed
Jun 2, 2026
| ::memcpy(&(vec_value[0]), node_fp_coords_copy, meta_.element_size()); | ||
|
|
||
| topk_heap.emplace(cached_neighbor.first, | ||
| VectorInfo(cur_expanded_dist, vec_value)); |
egolearner
reviewed
Jun 2, 2026
| void *node_fp_coords = node_disk_buf; | ||
| memcpy(data_buf, node_fp_coords, disk_bytes_per_point_); | ||
|
|
||
| float cur_expanded_dist = dc.dist(ctx->query(), data_buf); |
Collaborator
There was a problem hiding this comment.
可以直接用node_fp_coords做计算吗?是否可以不用拷贝到data_buf?
egolearner
reviewed
Jun 2, 2026
| ::memcpy(&(vec_value[0]), data_buf, meta_.element_size()); | ||
|
|
||
| topk_heap.emplace(frontier_neighbor.first, | ||
| VectorInfo(cur_expanded_dist, vec_value)); |
Collaborator
There was a problem hiding this comment.
move,更进一步可以提供一个helper
std::string make_vector_copy(const void* xxx) {
return {(const char*)xxx, meta_.element_size()};
}
topk_heap.emplace(frontier_neighbor.first,
VectorInfo(cur_expanded_dist, make_vector_copy(data_buf)));
egolearner
reviewed
Jun 2, 2026
|
|
||
| // Do Train | ||
| ailego::Params params; | ||
| params.set("zvec.cluster.multi_chunk_cluster.count", num_centers); |
| -Wl,--whole-archive | ||
| $<TARGET_FILE:core_knn_flat_static> | ||
| $<TARGET_FILE:core_knn_flat_sparse_static> | ||
| $<TARGET_FILE:core_knn_hnsw_static> |
|
|
||
| virtual ~DiskAnnQueryParams() = default; | ||
|
|
||
| int list_size() const { |
| const VectorData &query, const BaseIndexQueryParam::Pointer &search_param, | ||
| core::IndexContext::Pointer &context) override; | ||
|
|
||
| virtual int Add(const VectorData &vector, uint32_t doc_id) override; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add diskann index into Zvec to lower memory usage in vector search as per the description: #325