Skip to content

[FEA] View Type PQ Preprocessor#1764

Open
tarang-jain wants to merge 45 commits intorapidsai:mainfrom
tarang-jain:view-pq-quantizer
Open

[FEA] View Type PQ Preprocessor#1764
tarang-jain wants to merge 45 commits intorapidsai:mainfrom
tarang-jain:view-pq-quantizer

Conversation

@tarang-jain
Copy link
Copy Markdown
Contributor

@tarang-jain tarang-jain commented Feb 3, 2026

Separate VPQ codebooks from encoded data by introducing vpq_codebooks<MathT> (PIMPL with owning/view variants). vpq_dataset is now a simple {codebooks, data} struct. quantizer<T> holds only vpq_codebooks since it doesn't need encoded data. Adds a view-type pq::build() overload for pre-computed external codebooks.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Feb 3, 2026

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 Feb 3, 2026
@tarang-jain tarang-jain added feature request New feature or request non-breaking Introduces a non-breaking change labels Feb 3, 2026
@cjnolet cjnolet moved this to In Progress in Unstructured Data Processing Feb 6, 2026
@tarang-jain tarang-jain changed the base branch from main to release/26.04 March 13, 2026 23:21
@tarang-jain tarang-jain marked this pull request as ready for review March 13, 2026 23:28
@tarang-jain tarang-jain requested review from a team as code owners March 13, 2026 23:28
Copy link
Copy Markdown
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.

Hi Tarang, thank you for the PR! Overall looks good, but there is an issue with a copy operation that should be fixed before we can merge this.

Nitpick, but I find 'View Type PQ preprocessor' expression confusing. Could you please update the PR description to explain that this PR provides an owning and non owning variants of the vpq_dataset?

Comment on lines +524 to +531
// Copy the data from the source (data type is uint8_t, independent of MathT)
auto data_view = src.data();
auto data = raft::make_device_matrix<uint8_t, IdxT, raft::row_major>(
res, data_view.extent(0), data_view.extent(1));
raft::copy(data.data_handle(),
data_view.data_handle(),
data_view.size(),
raft::resource::get_cuda_stream(res));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

src.data() is the whole dataset. Although it is already compressed, it can still be HUGE in size. We definitely do not want to copy it. Note that the function takes src as rvalue reference, so we can just move src.data() to the new vpq_dataset and take ownership of it.

@aamijar aamijar changed the base branch from release/26.04 to main April 2, 2026 03:10
@tarang-jain tarang-jain added breaking Introduces a breaking change and removed non-breaking Introduces a non-breaking change labels Apr 3, 2026
tarang-jain and others added 2 commits April 2, 2026 18:30
Co-authored-by: Tamas Bela Feher <tfeher@nvidia.com>
Co-authored-by: Tamas Bela Feher <tfeher@nvidia.com>
@tarang-jain
Copy link
Copy Markdown
Contributor Author

@tfeher I have updated the PR desc

@tarang-jain tarang-jain requested review from lowener and tfeher April 6, 2026 22:12
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.

Looks very good, thanks! Just have a remark on build()

Comment on lines 186 to +190
cuvs::preprocessing::quantize::pq::quantizer<float> quantizer{
pq_params,
cuvs::neighbors::vpq_dataset<float, int64_t>{
std::move(vq_codebook), std::move(pq_codebook_copy), std::move(empty_data)}};
cuvs::preprocessing::quantize::pq::vpq_codebooks<float>{
std::make_unique<cuvs::preprocessing::quantize::pq::vpq_codebooks_owning<float>>(
std::move(vq_codebook), std::move(pq_codebook_copy))}};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the new pq::build() with views that you're introducing in this PR. That will also get rid of the relative include of src

Comment on lines 648 to +653
auto quantizer = cuvs::preprocessing::quantize::pq::quantizer<float>(
pq_params,
cuvs::neighbors::vpq_dataset<float, int64_t>{
raft::make_device_matrix<float, uint32_t, raft::row_major>(res, 0, 0),
std::move(pq_codebook),
raft::make_device_matrix<uint8_t, int64_t, raft::row_major>(res, 0, 0)});
cuvs::preprocessing::quantize::pq::vpq_codebooks<float>{
std::make_unique<cuvs::preprocessing::quantize::pq::vpq_codebooks_owning<float>>(
raft::make_device_matrix<float, uint32_t, raft::row_major>(res, 0, 0),
std::move(pq_codebook))});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the new pq::build() with views

Comment on lines +17 to +18
vpq_codebooks_owning(raft::device_matrix<math_type, uint32_t, raft::row_major>&& vq_code_book,
raft::device_matrix<math_type, uint32_t, raft::row_major>&& pq_code_book)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick: Would it make sense to have the vq as optional in both struct? It would follow the other functions parameter order too if it's by default nullopt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change feature request New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants