Skip to content

Selectivity-adaptive filtered search: sparse filters get exact results - #5

Merged
JonathanKash merged 1 commit into
mainfrom
filtered-search
Sep 2, 2026
Merged

Selectivity-adaptive filtered search: sparse filters get exact results#5
JonathanKash merged 1 commit into
mainfrom
filtered-search

Conversation

@JonathanKash

Copy link
Copy Markdown
Owner

Sparse allow-bitmaps now take a zero-allocation exact scan of the allowed set (when popcount(allow) <= 16*ef) instead of degraded graph traversal — cheaper and recall-1.0 by construction, with tie order matching brute force exactly. Larger filters keep the routed traversal. Applies to all three search modes.

Tests gate sparse-filter results equal to brute force (ids + distances); benchmark gains a filtered table across 0.1%/1%/10% selectivities vs exact filtered ground truth.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ULiWeodALX2ZQiLKvTw25

A sparse allow-bitmap makes graph traversal the wrong algorithm: too
few eligible nodes enter the beam, pruning never engages, and the walk
decays toward an expensive, approximate scan of the reachable graph.
The provably right strategy at high selectivity is a direct scan of
the allowed ids - cheaper AND exact.

All three search modes now route their candidate pool through
collect_pool(): when popcount(allow) <= 16*ef (the popcount is a
microsecond pass, bits beyond capacity masked), a zero-allocation
exact scan of the allowed set fills the pool - recall 1.0 over the
filter by construction, with ascending-id iteration reproducing the
brute-force (distance, id) tie order exactly. Larger filters keep the
existing traversal with filtered-out nodes routing.

Tests: sparse-filter results gated EQUAL to brute force (ids and
distances), re-ranked modes stay within the filter, empty bitmap
returns 0. Benchmark gains a filtered-search table across 0.1%/1%/10%
selectivities measured against exact filtered ground truth.

Windows: 6/6 suites green both configs; cross-platform validation via
CI (local WSL is congested by unrelated workload load-avg ~30 today -
measured numbers for the README follow from a detached run).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ULiWeodALX2ZQiLKvTw25
@JonathanKash
JonathanKash merged commit a9c8ed7 into main Sep 2, 2026
7 checks passed
@JonathanKash
JonathanKash deleted the filtered-search branch September 2, 2026 04:34
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.

1 participant