Skip to content

Conversation

@bkarsin
Copy link
Contributor

@bkarsin bkarsin commented Jan 7, 2025

Includes several fixes and improvements to Vamana, primarily:

  • Edge case and bug fixes for Vamana index build (details below)
  • Documentation added for Vamana
  • experimental namespace removed
  • Reduce device memory usage by splitting reverse edge work into batches

The edge case fix adds padding to all shared memory size and offset calculations so any dataset dimension is supported (tests added that verify this). A bug was also fixed with the L2 distance metric causing incorrect results in some rare cases.

This PR addresses the most pressing items in #393 and stabilize the index construction sufficiently to remove the experimental namespace.

@bkarsin bkarsin requested review from a team as code owners January 7, 2025 09:41
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 7, 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.

@github-actions github-actions bot added the cpp label Jan 7, 2025
@bkarsin bkarsin mentioned this pull request Jan 7, 2025
7 tasks
@bkarsin bkarsin added non-breaking Introduces a non-breaking change doc Improvements or additions to documentation improvement Improves an existing functionality and removed doc Improvements or additions to documentation labels Jan 7, 2025
@cjnolet
Copy link
Member

cjnolet commented Jan 8, 2025

/ok to test

Vamana builds a graph that is stored in device memory. However, in order to serialize the index and write it to a file for later use, it must be moved into host memory. If the `include_dataset` parameter is also set, then the dataset must be resident in host memory when calling serialize as well.

Device memory usage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised the docs built without error. I'm sure there's a warning in there about having the underlining for headings be longer the text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed all the DiskANN/vamana docs.


The built index represents the graph as fixed degree, storing a total of :math:`graph_degree * n_index_vectors` edges. Graph construction also requires the dataset be in device memory (or it copies it to device during build). In addition, device memory is used during construction to sort and create the reverse edges. Thus, the amount of device memory needed depends on the dataset itself, but it is bounded by a maximum sum of:

- vector dataset: :math:`n_index_vectors * n__dims * sizeof(T)`
Copy link
Member

Choose a reason for hiding this comment

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

I think you might need to escape all of the _'s in here. Have you checked to see how this formats?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did a quick scan but didn't look at all the formatting details. Thanks for checking, I'll do a pass over the format of the final built docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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 @bkarsin for the PR, it looks great! I have just a few small suggestions below.

T* s_coords = reinterpret_cast<T*>(&smem[sort_smem_size]);
DistPair<IdxT, accT>* new_nbh_list =
reinterpret_cast<DistPair<IdxT, accT>*>(&smem[dim * sizeof(T) + sort_smem_size]);
int align_padding = (((dim - 1) / alignof(ShmemLayout)) + 1) * alignof(ShmemLayout) - dim;
Copy link
Contributor

@tfeher tfeher Jan 28, 2025

Choose a reason for hiding this comment

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

Suggested change
int align_padding = (((dim - 1) / alignof(ShmemLayout)) + 1) * alignof(ShmemLayout) - dim;
// #include <raft/util/cuda_dev_essentials.cuh>
int align_padding = raft::alignTo<int>(dim, alignof(ShmemLayout)) - dim;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

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 @bkarsin for the updates, the PR looks good to me!

@cjnolet
Copy link
Member

cjnolet commented Jan 30, 2025

/merge

@rapids-bot rapids-bot bot merged commit 833f28c into rapidsai:branch-25.02 Jan 30, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cpp improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Development

Successfully merging this pull request may close these issues.

3 participants