Skip to content
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

IVF-Flat: make adaptive-centers behavior optional #1019

Conversation

achirkin
Copy link
Contributor

Add an indexing parameter adaptive_centers (false by default) to control whether index.centers() should be kept up-to-date with the cluster data or remain immutable.

@github-actions github-actions bot added the cpp label Nov 15, 2022
@achirkin achirkin added 3 - Ready for Review feature request New feature or request breaking Breaking change labels Nov 15, 2022
@achirkin
Copy link
Contributor Author

NB: breaking change (changed default behavior and the signature of one of the constructors).

index(const handle_t& handle,
raft::distance::DistanceType metric,
uint32_t n_lists,
bool adaptive_centers,
Copy link
Member

@cjnolet cjnolet Nov 15, 2022

Choose a reason for hiding this comment

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

Rather than making this an option on the index params object itself, why not just make it an optional argument on the extend() function? That would enable the user to determine whether it should be done outside of the creation of the index. It's really not an index option, but a design detail based on a specific use-case / usage-pattern.

I was thinking of something like extend(....., update_centers=false);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I see it sounds more intuitive to keep the parameter in the extend, I'd disagree for two reasons:

  1. The update-centers routine does not go through the whole data (which would be costly), but only aggregates newly added data. For this to work, the centers() must always be up-to-date. Hence, we cannot allow doing an "updating" extend after a "non-updating" one. Also from the logical point of view, this would break both alternative invariants (centers are neither constant nor up-to-date).
  2. I hope to preserve the public API the same for all our (ANN) models: build gets all parameters through the struct, extend never accepts extra parameters (and gets them from the index). Besides, the build function would need to take update_centers as well, because it optionally calls extend.

@achirkin achirkin marked this pull request as ready for review November 16, 2022 08:51
@achirkin achirkin requested a review from a team as a code owner November 16, 2022 08:51
Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

LGTM. I just have some minor updates to the description of the new option.

cpp/include/raft/neighbors/ivf_flat_types.hpp Outdated Show resolved Hide resolved
cpp/include/raft/neighbors/ivf_flat_types.hpp Outdated Show resolved Hide resolved
cpp/include/raft/neighbors/ivf_flat_types.hpp Outdated Show resolved Hide resolved
cpp/include/raft/neighbors/ivf_flat_types.hpp Outdated Show resolved Hide resolved
achirkin and others added 2 commits November 16, 2022 17:39
Co-authored-by: Corey J. Nolet <cjnolet@users.noreply.github.com>
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 Artem, the PR looks good to me!

Copy link
Member

@cjnolet cjnolet left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks again Artem!

@cjnolet
Copy link
Member

cjnolet commented Nov 16, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit c7e74bd into rapidsai:branch-22.12 Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review breaking Breaking change cpp feature request New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

3 participants