Repository navigation
fix(filter): preserve K-center sample counts and distinct selections - #590
Merged
SunnyHaze merged 1 commit intoNov 17, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
16 failures and three passes before the two performance regressions were added.
openpyxlabsent), using NumPy 1.26.4, pandas 2.3.3, PyArrow 20.0.0 and CPU Torch.git diff --checkpasses. Source lintcomparison 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