Skip to content

Add leanvec_primary_only build option to C++ runtime#323

Open
ibhati wants to merge 2 commits intomainfrom
ib/leanvec-primary-only
Open

Add leanvec_primary_only build option to C++ runtime#323
ibhati wants to merge 2 commits 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.

ibhati added 2 commits April 29, 2026 09:49
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).
@ibhati ibhati marked this pull request as ready for review May 4, 2026 21:16
@ethanglaser
Copy link
Copy Markdown
Member

Is there a corresponding FAISS update?

@ibhati
Copy link
Copy Markdown
Member Author

ibhati commented May 5, 2026

Is there a corresponding FAISS update?

Yes, I will publish it as well once we have this PR merged

@ethanglaser
Copy link
Copy Markdown
Member

ethanglaser commented May 5, 2026

I'd recommend drafting a FAISS update and pointing the FAISS install in this PR to your FAISS branch, otherwise our CI will be failing

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.

2 participants