Skip to content

[DO NOT MERGE] Reproduce flaky KmeansFitBatched test - #2787

Closed
bdice wants to merge 6 commits into
NVIDIA:mainfrom
bdice:flaky-kmeans-batched
Closed

bdice wants to merge 6 commits into
NVIDIA:mainfrom
bdice:flaky-kmeans-batched

Conversation

@bdice

@bdice bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Reproduces the flaky KmeansFitBatchedTestF.Result/N centroid mismatch (#2657) in CI on H100 with a reduced CI matrix. Part of #2783.

@copy-pr-bot

copy-pr-bot Bot commented Oct 10, 2026

Copy link
Copy Markdown

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.

@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test df1aaee

@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5e70463

bdice added 2 commits October 10, 2026 15:50
Sum the rows and weights of each cluster in a fixed order instead of with
atomics, and use cub::DeviceReduce for the centroid shift and the weight
sum. Identical fits now return bitwise-identical centroids, so the
convergence check no longer stops at a different iteration from run to run.
@bdice
bdice force-pushed the flaky-kmeans-batched branch from 5e70463 to 04e5635 Compare October 10, 2026 20:13
@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 04e5635

Use the environment-based cub::DeviceReduce with an explicit
cuda::execution::determinism::run_to_run requirement for the cluster
cost, the weight sum and the centroid shift. Temporary storage comes
from the caller's workspace buffer through a small memory resource, so
the reductions do not allocate on every call. Also let the per-cluster
row sums take any data iterator and optional weights, and process the
rows in passes of at most 2^22 to bound the workspace.
@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a4418e0

@bdice
bdice force-pushed the flaky-kmeans-batched branch from 04e5635 to a4418e0 Compare October 10, 2026 21:26
@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 81c966e

@bdice
bdice force-pushed the flaky-kmeans-batched branch 2 times, most recently from 81c966e to 92165b5 Compare October 10, 2026 23:49
@bdice

bdice commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 92165b5

@bdice
bdice force-pushed the flaky-kmeans-batched branch from 92165b5 to 50a452d Compare October 11, 2026 00:36
@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 50a452d

@bdice
bdice force-pushed the flaky-kmeans-batched branch from 50a452d to b181c97 Compare October 11, 2026 01:19
@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b181c97

@bdice
bdice force-pushed the flaky-kmeans-batched branch from b181c97 to dad0f83 Compare October 11, 2026 01:59
@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test dad0f83

bdice added 3 commits October 11, 2026 02:40
Sum the rows of each cluster exactly with fixed-point integer atomics
instead of floating-point atomics: the result does not depend on the
order of the atomics, and the M step still takes two kernels, because the
per-column scales are computed once per EM loop. Also derive the random
donor candidates from the receiver cluster instead of a shared atomic
counter (with a stride coprime with the number of rows, so that every
receiver still finds a donor), and rotate the donor offset with the
balancing step instead of a process-wide static counter. Group the IVF-PQ
training rows by cluster with a stable sort, so the per-cluster codebook
training sets do not depend on scheduling.
@bdice
bdice force-pushed the flaky-kmeans-batched branch from dad0f83 to caf42ce Compare October 11, 2026 02:40
@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test caf42ce

@bdice

bdice commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Closing: this was a reproducer/diagnostic PR for workstream E of #2783. The fix is in #2801 (k-means fit) and #2804 (balanced k-means).

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant