[C API] Expose leanvec ood - #358
Open
ethanglaser wants to merge 5 commits into
Open
Conversation
rfsaliev
requested changes
Aug 3, 2026
| /// time. Pass NULL to clear a previously attached training data. | ||
| /// @param out_err An optional error handle to capture errors | ||
| /// @return true on success, false on failure | ||
| SVS_API bool svs_index_builder_set_leanvec_training_data( |
Member
There was a problem hiding this comment.
It seems like the "training data" belongs to LeanVec storage kind only.
The proper API call should be connected to LeanVec storage only:
Preffered:
SVS_API svs_storage_h svs_storage_create_leanvec_pre_trained(
svs_leanvec_training_data_h training_data, // leanvec_dims to be extracted from there
svs_data_type_t primary,
svs_data_type_t secondary,
svs_error_h out_err /*=NULL*/
);alternative:
SVS_API bool svs_storage_set_leanvec_training_data(
svs_storage_h leanvec_storage,
svs_leanvec_training_data_h training_data, // leanvec_dims to be extracted from there and compared with previously defined
svs_error_h out_err /*=NULL*/
);
Member
Author
There was a problem hiding this comment.
Updated, but named it svs_storage_create_leanvec_trained
ethanglaser
marked this pull request as ready for review
August 4, 2026 23:28
ethanglaser
requested review from
ahuber21,
homksei,
ibhati,
mihaic and
yuejiaointel
as code owners
August 4, 2026 23:28
|
Tick the box to add this pull request to the merge queue (same as
|
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.
Summary
Exposes LeanVec out-of-distribution (OOD) training to the C API. Callers can train dimensionality-reduction matrices from a data sample plus a sample of queries, then build an index that uses those matrices instead of computing PCA matrices at build time.
API
Training data is attached at storage construction rather than via an index-builder setter (per review):
leanvec_dimshas a single source of truth, storage configs stay immutable and safely shareable across builders, and misuse on a non-LeanVecstorage is a compile-time error instead of a runtime one.
Tests
c_api_index.cpp: OOD build + search, in-distribution pre-trained build + search (freeing the training data before build, to exercise shared ownership of the matrices), and NULL-training-data rejection. All sections no-op gracefully on builds or hardware without LeanVec support.Notes
StorageLeanVec::lenavec_dims→leanvec_dims.SVS_URLpredatesMemoryBreakdown(the C++ bindings were bumped in Update SVS_URL to nightly with get_memory_breakdown #357, the C ones weren't), and the only nightly that has it is LTO-built and won't link against local GCC 11.4. Relying on CI with private sources here.