Skip to content

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)
  • Add support for compressed datasets (SQDataset, LVQ, Leanvec)

}

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

I update and clarified the inter (outer) and intra (inner) query parallelism and threadpools used in this commit @dian-lun-lin please have a look at IVFIndex class again. Thanks


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/

ibhati added 2 commits August 27, 2025 10:44
   IVFIndex class
2. Add docstring in the high level class and methods
3. Use logging instead of fmt::print
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