Skip to content

Add leanvec_primary_only build option to C++ runtime#323

Draft
ibhati wants to merge 1 commit intomainfrom
ib/leanvec-primary-only
Draft

Add leanvec_primary_only build option to C++ runtime#323
ibhati wants to merge 1 commit intomainfrom
ib/leanvec-primary-only

Conversation

@ibhati
Copy link
Copy Markdown
Member

@ibhati ibhati commented Apr 29, 2026

Summary

Adds a new leanvec_primary_only parameter (default false) to the LeanVec
build entry points in the C++ runtime API. When enabled, the LeanVec
secondary (full-precision) dataset is not allocated, roughly halving the
LeanVec memory footprint for workloads that don't need re-ranking.

API changes

A trailing bool leanvec_primary_only = false argument is added to:

  • VamanaIndexLeanVec::build (both overloads)
  • DynamicVamanaIndexLeanVec::build (the DynamicIndexParams overloads)

Existing call sites are source- and ABI-compatible: the parameter is
defaulted, and the legacy back-compat overloads are unchanged.

Plumbing

The flag is stored in {Vamana,DynamicVamana}IndexLeanVecImpl and forwarded
through init_implbuild_implStorageFactory<LeanVec>::init
LeanDataset::reduce, where it skips secondary-dataset allocation and
disables re-ranking at search time.

Adds a new `leanvec_primary_only` parameter (default false) to the
LeanVec build entry points in the C++ runtime API:

- VamanaIndexLeanVec::build (both overloads)
- DynamicVamanaIndexLeanVec::build (DynamicIndexParams overloads)

The flag is stored in {Vamana,DynamicVamana}IndexLeanVecImpl and
forwarded through init_impl -> build_impl -> StorageFactory<LeanVec>::init
-> LeanDataset::reduce, where it skips secondary-dataset allocation
and disables reranking. ABI back-compat overloads are unchanged.

Compiles standalone with SVS_RUNTIME_HAVE_LVQ_LEANVEC=OFF (stub returns
NOT_IMPLEMENTED). When enabled, requires the matching LeanDataset::reduce
overload that accepts the primary_only argument (added in the private
repository alongside the LeanDataset save/load support).
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