[C API] Add svs_index_search_range (radius search)
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the existing svs_index_search_topk declaration in svs_c.h (around line 1316) and the CSR svs_search_results_t layout, then compare with DynamicVamanaIndexImpl::range_search in bindings/cpp/src/dynamic_vamana_index_impl.h. The new entry point must follow the same buffer-reuse and threadpool rules, add the max_results cap signal, and honour the per-metric radius contract. Done means a declared and implemented svs_index_search_range with tests for L2, dot product and cosine, including the cap-reached case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Please add a radius search to the C API: given a query and a threshold, return every vector within that threshold. Today the only C API search is svs_index_search_topk (svs_c.h:1316). C_API_Design.md (line 300) lists range search as a future extension, and the CSR layout of svs_search_results_t was designed to carry variable per-query result counts for it (svs_c.h:365-368).
Why now
valkey-search added range queries in valkey-io/valkey-search#985, FT.SEARCH ... @v:[VECTOR_RANGE <radius> $blob], merged 2026-10-02. Every vector index now has to implement VectorBase::SearchRange(query, radius, filter).
valkey-search's SVS_VAMANA index uses only the C API. Without a radius search there, it approximates one:
- Run
svs_index_search_topkwithkup to the configured cap,search.max-nonvector-search-results-fetched(100,000 by default). - Keep the results within the radius.
- When the cap is reached with its farthest result still in range, scan every stored vector exactly.
This works, but it sizes the search by the cap rather than by how many vectors are actually in range, and the exhaustive scan is O(N).
Ask
A C API entry point alongside svs_index_search_topk, for example:
SVS_API bool svs_index_search_range(
svs_index_h index,
const float* queries,
size_t num_queries,
float radius,
size_t max_results, /* per query; 0 = no limit */
svs_search_results_t* out_results,
svs_search_params_h search_params /*=NULL*/,
svs_id_filter_i id_filter /*=NULL*/,
svs_error_h out_err /*=NULL*/
);
with this contract:
- Results. Per-query counts vary, written in the existing CSR layout (
offsets,total_results). Ordering within a row doesn't matter to us. - Radius is in the index metric's own units, and documented per metric. For L2, results have distance
<= radius. For dot product and cosine, results have similarity>= radius. A non-positive threshold must be accepted for dot product and cosine: valkey-search's distance radiusrmaps to the similarity threshold1 - r, which is<= 0wheneverr >= 1. max_resultscap. When a query has more thanmax_resultsvectors in range, returnmax_resultsof them and report that the cap was reached, for example through a flag or a per-query count. valkey-search then falls back to an exact scan, so it needs to know the result is incomplete rather than get a silently truncated one.- Threading. Run on the threadpool installed with
svs_index_builder_set_threadpool_custom, assvs_index_search_topkdoes. valkey-search installs a pool that runs on the calling thread so SVS starts no threads of its own. - Filtering. Same
svs_id_filter_icontract assvs_index_search_topkwithfilter_rate() <= 0(intel/ScalableVectorSearch#415): no sampling, no early exit on hit rate, and return the matches found.
How this differs from the C++ range search
The C++ runtime bindings already provide range search: DynamicVamanaIndex::range_search (bindings/cpp/include/svs/runtime/vamana_index.h:88), implemented in DynamicVamanaIndexImpl::range_search (bindings/cpp/src/dynamic_vamana_index_impl.h:216). It walks batch_iterator in distance order, in batches of the search window size, and stops at the first result outside the radius. That traversal suits this request too. What differs is the contract around it:
C++ range_search |
This request (C API) | |
|---|---|---|
| Interface | C++ virtual method; results through a ResultsAllocator callback |
C function; results in svs_search_results_t CSR, with the buffer-reuse and struct_size rules svs_index_search_topk already follows |
| Radius validation | Rejects radius <= 0 for every metric (line 226) |
Accepts any finite threshold for dot product and cosine (similarity can be <= 0); keeps > 0 for L2 |
| Radius units | Not documented per metric | Documented per metric: distance <= for L2, similarity >= for dot product and cosine |
| Threading | Runs on default_threadpool() (line 297) |
Runs on the threadpool installed on the index, like svs_index_search_topk |
| Result size | Unbounded; reserves the search buffer's capacity per query and grows from there | Capped by max_results, with a signal when the cap was reached |
| Filter | IDFilter::is_member only |
svs_id_filter_i, with the filter_rate() <= 0 contract from #415 |
| Errors | Status / StatusException |
svs_error_h, like the other C API calls |
Consumer context
- valkey-search (
ALGORITHM SVS_VAMANA) is built on the C API submodule, pinned at8285340. - The current
SearchRangefallback is in eshenayo/valkey-search (src/indexes/vector_svs.cc), part of the upstream draft valkey-io/valkey-search#1577. - With a native call,
VectorSVS::SearchRangewould become a singlesvs_index_search_rangecall. It would fall back to the exact scan only when SVS reports the cap was reached.
- Ngôn ngữ chính
- C++
- Star
- 241
- Fork
- 48
- Merge trung bình
- 4 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của intel/ScalableVectorSearch
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
intel/ScalableVectorSearch#356 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
intel/ScalableVectorSearch#469 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Add CI test for C API on ARMĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 32/100
intel/ScalableVectorSearch#460 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
intel/ScalableVectorSearch#438 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
CI: tier the test matrix into PR / main / nightly to cut Actions minutesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
intel/ScalableVectorSearch#432 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của intel/ScalableVectorSearch
Issue tương tự
-
runtime: lf_f128_mod is documented as fmodq (truncating) but implements floor-based modulo; unusedĐang mởinternal correctness low priority rt_lib
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
-
PriorityNotificationQueue::wakeUpAll() loses the wake-up for a thread that is not waiting yetCó thể đã có người làm @matejk đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pocoproject/poco#5674 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug docs GUI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
sonic-pi-net/sonic-pi#3609 ·
-
Unreachable code warningĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SanderMertens/flecs#2395 ·
Maintainer thường phản hồi trong vòng 1 ngày