Skip to content

Add primary-only LeanVec storage kinds to C++ runtime#338

Open
ibhati wants to merge 1 commit into
mainfrom
ib/leanvec-primary-only
Open

Add primary-only LeanVec storage kinds to C++ runtime#338
ibhati wants to merge 1 commit into
mainfrom
ib/leanvec-primary-only

Conversation

@ibhati
Copy link
Copy Markdown
Member

@ibhati ibhati commented May 22, 2026

Supersedes #323 (which couldn't be reopened via API after force-push).

Summary

Adds the public C++ runtime surface for primary-only LeanVec. This is the public-side counterpart to the private re-architecture; see the private PR for the design discussion and rationale.

Changes

  • StorageKind enum: two new variants LeanVecLVQ4PrimaryOnly and LeanVecLVQ8PrimaryOnly.
  • is_leanvec_storage(): updated to recognize them.
  • LeanDatasetType alias + StorageType specializations: produce LeanDataset<UsingLVQ<N>, void, ...> for the new kinds (mapping to the private partial specialization).
  • StorageFactory specializations: build/load the primary-only LeanDataset (no secondary tier).
  • SVS_DISPATCH_STORAGE_KIND macro: add both new cases to the dispatch.

Architectural alignment

The private side now uses a partial specialization LeanDataset<T1, void, ...> (no runtime flag, no secondary member, no secondary methods) — mirroring how LVQ has separate one-level vs two-level classes. The public side exposes this through new StorageKind enum values, which is the same way LVQ4/LVQ8 variants are already exposed.

Diff

+100 / −1 across 5 files. All additive at the public surface: no existing enum values changed, no existing API signatures changed.

Add two new StorageKind enum values for primary-only LeanVec:
LeanVecLVQ4PrimaryOnly and LeanVecLVQ8PrimaryOnly. These select the
new LeanDataset<UsingLVQ<N>, void, ...> partial specialization which
omits the secondary (reranking) tier for ~50% memory savings at the
cost of reranking accuracy. Vamana-only (IVF support out of scope).

- api_defs.h: extend StorageKind enum
- svs_runtime_utils.h: extend is_leanvec_storage(), add
  LeanDatasetPrimaryOnlyType alias, StorageType specializations,
  new dispatch cases in SVS_DISPATCH_STORAGE_KIND
- vamana_index_impl.h, dynamic_vamana_index_leanvec_impl.h: new
  switch cases in dispatch_leanvec_storage_kind
- runtime_test.cpp: write/read round-trip tests for both new kinds
Copy link
Copy Markdown
Member

@rfsaliev rfsaliev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGFM

Just the question: aren't enum value names aka LeanVecLVQ4PrimaryOnly too long?

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