Skip to content

[CPP Runtime] Refactor storage tags and add static Vamana index support#297

Merged
rfsaliev merged 6 commits intomainfrom
rfsaliev/cpp-runtime-static-vamana
Mar 26, 2026
Merged

[CPP Runtime] Refactor storage tags and add static Vamana index support#297
rfsaliev merged 6 commits intomainfrom
rfsaliev/cpp-runtime-static-vamana

Conversation

@rfsaliev
Copy link
Member

Enable static Vamana index functionality support in CPP Runtime API.

This PR includes following changes:

  1. Refactored CPP Runtime storage factory utils to support configurable storage allocator.
  • StorageKindTag<Kind> is removed and replaced with StorageType<Kind, Alloc> in usages
  • Storagefactory::init() block_size argument is replaced with allocator - to be constructed in index implementation code (with appropriate block size)
  1. [static] VamanaIndex interface implementation.
  2. Refactored IVF storage factory utils to match changes made in step 1.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the C++ runtime storage/tag dispatch to be allocator-aware and introduces a concrete “static” VamanaIndex runtime API/implementation (plus LeanVec-specialized builders), updating existing IVF/Flat/Dynamic-Vamana code to the new storage plumbing and extending the C++ runtime test suite accordingly.

Changes:

  • Refactor runtime storage dispatch from StorageKindTag to StorageType<Kind, Alloc> and pass allocators into storage factories.
  • Add static VamanaIndex implementation (build/load/save/search/range_search) and LeanVec build specializations.
  • Update IVF/Flat/Dynamic-Vamana implementations + add runtime tests for static Vamana variants.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
include/svs/core/data/simple.h Adds is_blocked_v trait to detect blocked allocator wrappers.
bindings/cpp/src/svs_runtime_utils.h Reworks storage type mapping/factory APIs to be allocator-aware and tagless.
bindings/cpp/src/vamana_index_impl.h New static Vamana implementation (including LeanVec specialization).
bindings/cpp/src/vamana_index.cpp Implements the new VamanaIndex/VamanaIndexLeanVec runtime interfaces.
bindings/cpp/include/svs/runtime/vamana_index.h Expands VamanaIndex public API for static Vamana and LeanVec builders.
bindings/cpp/include/svs/runtime/dynamic_vamana_index.h Adapts DynamicVamana to the updated VamanaIndex base interface.
bindings/cpp/src/dynamic_vamana_index_impl.h Updates storage dispatch/build path for allocator-based storage factory.
bindings/cpp/src/dynamic_vamana_index_leanvec_impl.h Updates LeanVec tag dispatch to StorageType<Kind, Alloc>.
bindings/cpp/src/ivf_index_impl.h Refactors IVF storage dispatch to the new StorageType<Kind, Alloc> approach.
bindings/cpp/src/dynamic_ivf_index_impl.h Refactors Dynamic-IVF storage dispatch similarly.
bindings/cpp/src/flat_index_impl.h Updates Flat index storage type/tag usage to StorageType<Kind, Alloc>.
bindings/cpp/tests/runtime_test.cpp Adds static Vamana read/write/search/range-search tests and LeanVec training-path test.
bindings/cpp/CMakeLists.txt Gates link_mkl_static() behind SVS_EXPERIMENTAL_LINK_STATIC_MKL.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

@rfsaliev rfsaliev requested a review from Copilot March 23, 2026 18:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Comment on lines +121 to +127
// Selective search with IDSelector
auto old_sp = get_impl()->get_search_parameters();
auto sp_restore = svs::lib::make_scope_guard([&]() noexcept {
get_impl()->set_search_parameters(old_sp);
});
get_impl()->set_search_parameters(sp);

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

In the filtered-search path, this temporarily mutates the underlying index’s search parameters (set_search_parameters) inside a const method. This is not thread-safe if the same index instance is searched concurrently (different calls can race and restore the wrong parameters). Prefer an API that passes search parameters directly to the iterator/search, or protect the mutation with synchronization (or clearly document that concurrent searches are unsupported when using filters/params).

Copilot uses AI. Check for mistakes.
// Return type defined to simple to allow substitution in templates.
template <> struct StorageFactory<UnsupportedStorageType> {
using StorageType = SimpleDatasetType<float>;
template <typename Alloc> struct StorageFactory<UnsupportedStorageType<Alloc>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is possible to unify StorageFactory with IVFStorageFactory?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is possible, but I would like to do such refactoring in a separate PR - this one is big enough already :)
@ibhati, your comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reported the issue #303

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it is definitely possible. But I agree, let's do it in a separate PR.

@rfsaliev rfsaliev merged commit 9ab0180 into main Mar 26, 2026
18 of 19 checks passed
@rfsaliev rfsaliev deleted the rfsaliev/cpp-runtime-static-vamana branch March 26, 2026 11:08
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.

4 participants