Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9fd71ef
add CAGRA ANN to replace brute force kmeans for prediction + test cas…
HowardHuang1 Mar 18, 2026
80070c4
fix test cases + fix threshold
HowardHuang1 Mar 18, 2026
fa6fd70
add test cases for entire IVF-PQ pipeline
HowardHuang1 Mar 18, 2026
d8543a6
rename variable to use_ann_for_extend since previous changes are only…
HowardHuang1 Mar 19, 2026
d26e916
Replace brute force with CAGRA ANN in build()
HowardHuang1 Mar 20, 2026
ad054af
add test cases
HowardHuang1 Mar 24, 2026
0f14da1
Merge remote-tracking branch 'upstream' into HH-ANNs-for-clustering-a…
HowardHuang1 Jun 25, 2026
e69259f
rename use_cagra and use_ann variables to use_cagra_for_cluster_assig…
HowardHuang1 Jun 25, 2026
1d76516
fix null list or empty trained indices error for IVF-PQ serialize cau…
HowardHuang1 Jun 25, 2026
8e62682
rename benchmark names so that Build_NearestCentroidLookup_Speedup mi…
HowardHuang1 Jun 25, 2026
167f0c4
refactor out common code shared by BM_IVFPQ_Build_NearestCentroidLook…
HowardHuang1 Jun 26, 2026
64586ad
add ann for cluster assignment to postfit. Added use_ann_for_build_po…
HowardHuang1 Jun 26, 2026
de80d26
Merge remote-tracking branch 'upstream' into HH-ANNs-for-clustering-a…
HowardHuang1 Jun 27, 2026
7daf9cb
add tuning script for ann_rebuild_interval balancing recall and speedup
HowardHuang1 Jun 27, 2026
76ebb73
Merge remote-tracking branch 'upstream' into HH-ANNs-for-clustering-a…
HowardHuang1 Jun 27, 2026
525cd4c
Merge remote-tracking branch 'upstream/main' into HH-ANNs-for-cluster…
HowardHuang1 Sep 5, 2026
1673e39
fix merge conflict with build now taking only dataset views and not d…
HowardHuang1 Sep 7, 2026
3951248
Replace hand-picked cluster-assignment bench args with controlled K s…
HowardHuang1 Sep 7, 2026
1daabbe
Add controlled fixed-K/vary-N, grid, search-only, dim, and rebuild-in…
HowardHuang1 Sep 8, 2026
52ddd3d
Merge remote-tracking branch 'upstream/main' into HH-ANNs-for-cluster…
HowardHuang1 Oct 27, 2026
3de0823
Fix benchmark plots and make fit-tuning quality metrics meaningful
HowardHuang1 Oct 28, 2026
73825bd
Read benchmark datasets from .fbin files and redesign plot panel 4
HowardHuang1 Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into HH-ANNs-for-cluster…
…ing-at-training
  • Loading branch information
HowardHuang1 committed Sep 5, 2026
commit 525cd4c8fff2b31dbe7ea012e09909e6707ca608
35 changes: 35 additions & 0 deletions cpp/include/cuvs/cluster/kmeans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,41 @@ struct balanced_params : base_params {
*/
uint32_t n_iters = 20;

/**
* Lower balance tolerance used during hierarchical training. Clusters smaller than
* `average_cluster_size * balance_lower_tolerance` are underfull. The default value of `0.333`
* targets clusters smaller than roughly one third of the average size.
*
* Valid range: (0, 1).
*/
float balance_lower_tolerance = 0.333f;

/**
* Upper balance tolerance used during hierarchical training. Clusters larger than
* `average_cluster_size * balance_upper_tolerance` are overfull donors. The default value of
* `3.0` targets clusters larger than roughly three times the average size. Very strict upper
* values around `1.4` or lower can be difficult for this heuristic rebalancing method to satisfy.
*
* Valid range: (1, infinity).
*/
float balance_upper_tolerance = 3.0f;

/**
* Offset used when reinitializing an underfull cluster near an overfull cluster. The new center
* is placed at `donor_center + centroid_offset * (donor_point - donor_center)`.
*
* Valid range: (0, 1].
*/
float centroid_offset = 0.01f;

/**
* Donor cluster selection strategy used when reinitializing underfull clusters. `SizeSorted`
* pairs the smallest clusters with the largest clusters and uses `balance_upper_tolerance` to
* identify overfull donors. `Random` selects donor points from clusters at least as large as the
* average cluster size; in that mode, `balance_upper_tolerance` does not control donor selection.
*/
balanced_donor_selection donor_selection = balanced_donor_selection::SizeSorted;

/**
* Use approximate nearest neighbor (CAGRA) for cluster assignment during k-means fit (E-step).
* When true and n_clusters is large, assignment uses a CAGRA index over centroids to speed
Expand Down
1 change: 1 addition & 0 deletions cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,7 @@ auto build(raft::resources const& handle,
cuvs::cluster::kmeans::balanced_params kmeans_params;
kmeans_params.n_iters = params.kmeans_n_iters;
kmeans_params.metric = coarse_clustering_metric(impl->metric());
// Use the default SizeSorted donor selection to prioritize balanced coarse partitions.
// Propagate use_ann_for_build_fit into k-means; CAGRA runs inside fit's E-step
// (balancing_em_iters → assign_nearest_centroid_cagra_with_index_reuse), not here.
if (params.use_ann_for_build_fit.value_or(false)) {
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/neighbors/ivf_pq/ivf_pq_serialize.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ void serialize(raft::resources const& handle_, Output& os, const index<IdxT>& in
raft::make_host_mdarray<uint32_t, uint32_t, raft::row_major>(index.list_sizes().extents());
raft::copy(handle_, sizes_host.view(), index.list_sizes());
raft::resource::sync_stream(handle_);
raft::serialize_mdspan(handle_, os, sizes_host.view());
cuvs::util::detail::serialize_mdspan(handle_, os, sizes_host.view());
// Pass shared_ptr to serialize_list so null (unallocated) lists write size=0 instead of crashing.
// NOTE: We use static_cast here because serialize_list requires the concrete list type
// to access the spec_type for determining the serialized data layout.
if (index.codes_layout() == list_layout::FLAT) {
auto list_store_spec = list_spec_flat<uint32_t, IdxT>{index.pq_bits(), index.pq_dim(), true};
for (uint32_t label = 0; label < index.n_lists(); label++) {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.