Skip to content

[FEA] IVF-PQ Build Factories for Precomputed Centroids and Codebooks#1483

Merged
rapids-bot[bot] merged 256 commits intorapidsai:mainfrom
tarang-jain:build-from-args
Jan 7, 2026
Merged

[FEA] IVF-PQ Build Factories for Precomputed Centroids and Codebooks#1483
rapids-bot[bot] merged 256 commits intorapidsai:mainfrom
tarang-jain:build-from-args

Conversation

@tarang-jain
Copy link
Copy Markdown
Contributor

@tarang-jain tarang-jain commented Oct 31, 2025

IVF-PQ Index Build API Enhancements and PIMPL Refactoring

Summary

This PR adds new build APIs for IVF-PQ indices using precomputed centroids and implements a complete PIMPL refactoring with owning/view semantics

Key Changes

  1. New Build APIs for Precomputed Centroids
    Added cuvs::neighbors::ivf_pq::build() overloads that accept precomputed cluster centroids, PQ codebooks, and rotation matrices
    Enables building indices from pre-trained models without re-training
    Supports both device and host input data with automatic memory transfer
  2. PIMPL Refactoring with Owning/View Semantics
    owning_impl: Owns centroid and codebook data (traditional behavior)
    view_impl: References external centroid data without copying
    Maintains identical search behavior with zero data copying
  3. Enhanced Helper Functions
    Removed mutator functions that directly modify the state of the index. Instead we have helpers for the user to fetch and own the transformed data

View indices avoid copying large centroid arrays
Backward Compatibility: All existing APIs work unchanged

[Updates] (as of 12/23/2025):
The non-const getters that allow direct modification of the state of the index:
pq_centers(), centers(), centers_rot() and rotation_matrix() have been removed from the interface and the user-facing class.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Oct 31, 2025

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.

@tarang-jain tarang-jain self-assigned this Oct 31, 2025
@tarang-jain tarang-jain added feature request New feature or request non-breaking Introduces a non-breaking change labels Oct 31, 2025
@tarang-jain tarang-jain changed the title [FEA] IVF_PQ build_from_args API [WIP] [FEA] IVF_PQ build_from_args API Oct 31, 2025
@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test 2aae6c1

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test 9d2dc10

Copy link
Copy Markdown
Contributor

@lowener lowener left a comment

Choose a reason for hiding this comment

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

LGTM

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test 94a88d9

@tarang-jain
Copy link
Copy Markdown
Contributor Author

@lowener the current approach is causing test failures. By default, when doing something like index.pq_centers(), the non-const getters get called, and we throw errors there in the view_impl. Furthermore, I have had to change the noexcept status in the interface for the non-const getters. I personally don't see a problem with allowing the user to access and modify their own data. I think something like this:
std::as_const(index).pq_centers() would force the const getters to get called, but having to do this for only view type indexes would beat purpose of the polymorphism.

Copy link
Copy Markdown
Contributor

@lowener lowener left a comment

Choose a reason for hiding this comment

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

LGTM, having the non-const getter not accessible in the virtual interface should make it less prone to errors for end-users.

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test 5921585

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test e9aaca3

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test fc3e4eb

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/ok to test b95c5ff

@tarang-jain
Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot rapids-bot Bot merged commit e1d127c into rapidsai:main Jan 7, 2026
180 of 182 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Unstructured Data Processing Jan 7, 2026
rapids-bot Bot pushed a commit that referenced this pull request Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request non-breaking Introduces a non-breaking change

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants