Skip to content

fix(filter): preserve K-center sample counts and distinct selections - #590

Merged
SunnyHaze merged 1 commit into
OpenDCAI:mainfrom
JustinBinber:codex/fix-kcenter-unique-sampling
Nov 17, 2026
Merged

SunnyHaze merged 1 commit into
OpenDCAI:mainfrom
JustinBinber:codex/fix-kcenter-unique-sampling

Conversation

@JustinBinber

Copy link
Copy Markdown
Contributor

K-center filtering can silently underfill an integer request: asking for five
rows from 77 returns four after a floating-point ratio round trip. Zero-distance
ties can also reselect a row, and preselected centers are not handled consistently.

This change preserves the filter's integer budget, caps it to the available
rows, and handles empty/zero selections without an embedding request. The sampler
initializes distances from all existing centers and masks selected indices so
each new index is distinct. Distance updates remain one center at a time, with
no unused final update or pairwise distance matrix. The existing ratio interface,
initial random-anchor strategy and output row order are preserved.

Validation:

  • New offline regression file: 21 passed. The original implementation produced
    16 failures and three passes before the two performance regressions were added.
  • Explicit new and related storage files: 73 passed, one skipped (optional
    openpyxl absent), using NumPy 1.26.4, pandas 2.3.3, PyArrow 20.0.0 and CPU Torch.
  • Independent distance-reference checks across 96 cases passed.
  • New test file passes Black and Ruff; git diff --check passes. Source lint
    comparison found no newly introduced diagnostic categories; existing
    import/type-annotation warnings remain outside this fix.

Tests use deterministic local embeddings and exercise the public operator with
real FileStorage. No hosted model calls or GPU validation were used.

Closes #589

@SunnyHaze
SunnyHaze merged commit 68a78f0 into OpenDCAI:main Nov 17, 2026
6 checks passed
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.

KCenterGreedyFilter underfills sample counts and mishandles existing centers

2 participants