Skip to content

IVF Index Support in SVS #156

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

IVF Index Support in SVS #156

wants to merge 13 commits into from

Conversation

ibhati
Copy link
Member

@ibhati ibhati commented Jul 8, 2025

This update introduces IVF (Inverted File) index support in SVS, allowing for index construction using either standard one-level clustering or a faster two-level hierarchical clustering approach. The clustering algorithm is optimized to utilize AMX (Advanced Matrix Extensions) on supported Intel® Xeon® systems, enhancing performance on compatible hardware. Additionally, support for the BF16 (bfloat16) data type has been introduced, broadening the range of data formats that can be efficiently processed.

Tasks

  • IVF (Inverted File) index support: Adds both standard one-level and fast two-level hierarchical clustering methods for index construction.
  • Optimized Clustering: Leverages AMX (Advanced Matrix Extensions) for improved performance on supported Intel® Xeon® hardware.
  • BF16 Data Type Support: Enables efficient processing of bfloat16-formatted data.
  • Python Bindings: Extends IVF functionality to Python.
  • Benchmarks and C++ Tests: Benchmarks and C++ test coverage are enabled.
  • Documentation for IVF (TBD in follow-up PR)
  • Add regression benchmarking for IVF (TBD in follow-up PR)
  • Python Tests (TBD in follow-up PR)
  • Add dynamic (add/delete) in IVF index (TBD in follow-up PR)

}

struct CreateDenseCluster {
using This = CreateDenseCluster;
Copy link
Member

Choose a reason for hiding this comment

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

What is This for?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are used in the extensions of compressed datasets (LVQ/Leanvec)

, distance_{std::move(distance_function)}
, threadpool_{threads::as_threadpool(std::move(threadpool_proto))}
, n_inner_threads_{n_inner_threads} {
// Initialize threadpools for intra-query parallelism
Copy link
Member

Choose a reason for hiding this comment

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

We need to be careful about nested parallelism. From this constructor, it's not obvious that the threadpool_ and n_inner_threads will be nested (i.e., two-level parallelism). Could we maybe have better naming? Also, how do we handle custom threadpool in this case?


Clustering clustering(std::move(centroids), std::move(clusters));
auto build_time = svs::lib::time_difference(tic);
fmt::print("IVF build time: {} seconds\n", build_time);
Copy link
Member

Choose a reason for hiding this comment

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

This print should be moved to logger

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, I will move all these prints in the logger with appropriate verbosity levels

final_assignments_time.finish();
kmeans_timer.finish();
svs::logging::debug("{}", timer);
fmt::print("kmeans clustering time: {}\n", lib::as_seconds(timer.elapsed()));
Copy link
Member

Choose a reason for hiding this comment

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

This print should be moved to logger


// On GCC, we need to add this attribute so that BFloat16 members can appear inside
// packed structs.
class __attribute__((packed)) BFloat16 {
Copy link
Member

Choose a reason for hiding this comment

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

What's the different between Float16 and BFloat16?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here is a short write-up explaining these formats and the differences: https://nhigham.com/2018/12/03/half-precision-arithmetic-fp16-versus-bfloat16/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants