Skip to content

Commit 97f2030

Browse files
committed
Merge remote-tracking branch 'origin/main' into omer-add-save-load-check
2 parents d5055f9 + e1d0334 commit 97f2030

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+962
-634
lines changed

cmake/svs.cmake

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,34 @@ if(USE_SVS)
4242

4343
# detect if build environment is using glibc
4444
include(CheckSymbolExists)
45-
unset(GLIBC_FOUND CACHE)
4645
check_symbol_exists(__GLIBC__ "features.h" GLIBC_FOUND)
47-
if(NOT GLIBC_FOUND)
48-
message(STATUS "GLIBC is not detected - SVS shared library is not supported")
46+
if(GLIBC_FOUND)
47+
include(CheckCXXSourceRuns)
48+
check_cxx_source_runs("#include <features.h>
49+
int main(){ return __GLIBC__ == 2 && __GLIBC_MINOR__ >= 28 ?0:1; }"
50+
GLIBC_2_28_FOUND)
51+
check_cxx_source_runs("#include <features.h>
52+
int main(){ return __GLIBC__ == 2 && __GLIBC_MINOR__ >= 26 ?0:1; }"
53+
GLIBC_2_26_FOUND)
4954
endif()
5055

5156
cmake_dependent_option(SVS_SHARED_LIB "Use SVS pre-compiled shared library" ON "USE_SVS AND GLIBC_FOUND AND SVS_LVQ_SUPPORTED" OFF)
5257
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
53-
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.0.8-dev/svs-shared-library-0.0.8-NIGHTLY-20250629-clang.tar.gz" CACHE STRING "SVS URL")
58+
if (GLIBC_2_28_FOUND)
59+
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.0.8-dev/svs-shared-library-0.0.8-NIGHTLY-20250629-clang.tar.gz" CACHE STRING "SVS URL")
60+
else()
61+
message(STATUS "GLIBC>=2.28 is required for Clang build - disabling SVS_SHARED_LIB")
62+
set(SVS_SHARED_LIB OFF)
63+
endif()
5464
else()
55-
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.0.8-dev/svs-shared-library-0.0.8-NIGHTLY-20250630.tar.gz" CACHE STRING "SVS URL")
65+
if (GLIBC_2_28_FOUND)
66+
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.0.8-dev/svs-shared-library-0.0.8-NIGHTLY-20250630.tar.gz" CACHE STRING "SVS URL")
67+
elseif(GLIBC_2_26_FOUND)
68+
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.0.8-dev/svs-shared-library-0.0.8-NIGHTLY-20250701-glibc-2_26.tar.gz" CACHE STRING "SVS URL")
69+
else()
70+
message(STATUS "GLIBC>=2.26 is required for SVS shared library - disabling SVS_SHARED_LIB")
71+
set(SVS_SHARED_LIB OFF)
72+
endif()
5673
endif()
5774

5875
if(SVS_SHARED_LIB)

src/VecSim/algorithms/svs/svs.h

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,16 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
8383

8484
// Index search parameters
8585
size_t search_window_size;
86+
size_t search_buffer_capacity;
87+
// LeanVec dataset dimension
88+
// This parameter allows to tune LeanVec dimension if LeanVec is enabled
89+
size_t leanvec_dim;
8690
double epsilon;
8791

92+
// Check if the dataset is Two-level LVQ
93+
// This allows to tune default window capacity during search
94+
bool is_two_level_lvq;
95+
8896
// SVS thread pool
8997
VecSimSVSThreadPool threadpool_;
9098
svs::logging::logger_ptr logger_;
@@ -137,7 +145,7 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
137145

138146
// Construct SVS index initial storage with compression if needed
139147
auto data = storage_traits_t::create_storage(points, this->blockSize, threadpool_handle,
140-
this->getAllocator());
148+
this->getAllocator(), this->leanvec_dim);
141149
// Compute the entry point.
142150
auto entry_point =
143151
svs::index::vamana::extensions::compute_entry_point(data, threadpool_handle);
@@ -164,7 +172,7 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
164172

165173
// Configure default search parameters
166174
auto sp = impl_->get_search_parameters();
167-
sp.buffer_config({this->search_window_size});
175+
sp.buffer_config({this->search_window_size, this->search_buffer_capacity});
168176
impl_->set_search_parameters(sp);
169177
impl_->reset_performance_parameters();
170178
}
@@ -289,14 +297,31 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
289297
}
290298
}
291299

300+
bool isTwoLevelLVQ(const VecSimSvsQuantBits &qbits) {
301+
switch (qbits) {
302+
case VecSimSvsQuant_4x4:
303+
case VecSimSvsQuant_4x8:
304+
case VecSimSvsQuant_4x8_LeanVec:
305+
case VecSimSvsQuant_8x8_LeanVec:
306+
return true;
307+
default:
308+
return false;
309+
}
310+
}
311+
292312
public:
293313
SVSIndex(const SVSParams &params, const AbstractIndexInitParams &abstractInitParams,
294314
const index_component_t &components, bool force_preprocessing)
295315
: Base{abstractInitParams, components}, forcePreprocessing{force_preprocessing},
296316
changes_num{0}, buildParams{svs_details::makeVamanaBuildParameters(params)},
297317
search_window_size{svs_details::getOrDefault(params.search_window_size,
298318
SVS_VAMANA_DEFAULT_SEARCH_WINDOW_SIZE)},
319+
search_buffer_capacity{
320+
svs_details::getOrDefault(params.search_buffer_capacity, search_window_size)},
321+
leanvec_dim{
322+
svs_details::getOrDefault(params.leanvec_dim, SVS_VAMANA_DEFAULT_LEANVEC_DIM)},
299323
epsilon{svs_details::getOrDefault(params.epsilon, SVS_VAMANA_DEFAULT_EPSILON)},
324+
is_two_level_lvq{isTwoLevelLVQ(params.quantBits)},
300325
threadpool_{std::max(size_t{SVS_VAMANA_DEFAULT_NUM_THREADS}, params.num_threads)},
301326
impl_{nullptr} {
302327
logger_ = makeLogger();
@@ -351,6 +376,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
351376
.numThreads = this->getNumThreads(),
352377
.numberOfMarkedDeletedNodes = this->changes_num,
353378
.searchWindowSize = this->search_window_size,
379+
.searchBufferCapacity = this->search_buffer_capacity,
380+
.leanvecDim = this->leanvec_dim,
354381
.epsilon = this->epsilon};
355382
return info;
356383
}
@@ -427,7 +454,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
427454
auto query = svs::data::ConstSimpleDataView<DataType>{
428455
static_cast<const DataType *>(processed_query), 1, this->dim};
429456
auto result = svs::QueryResult<size_t>{query.size(), k};
430-
auto sp = svs_details::joinSearchParams(impl_->get_search_parameters(), queryParams);
457+
auto sp = svs_details::joinSearchParams(impl_->get_search_parameters(), queryParams,
458+
is_two_level_lvq);
431459

432460
auto timeoutCtx = queryParams ? queryParams->timeoutCtx : nullptr;
433461
auto cancel = [timeoutCtx]() { return VECSIM_TIMEOUT(timeoutCtx); };
@@ -472,7 +500,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
472500
this->dim};
473501

474502
// Base search parameters for the SVS iterator schedule.
475-
auto sp = svs_details::joinSearchParams(impl_->get_search_parameters(), queryParams);
503+
auto sp = svs_details::joinSearchParams(impl_->get_search_parameters(), queryParams,
504+
is_two_level_lvq);
476505
// SVS BatchIterator handles the search in batches
477506
// The batch size is set to the index search window size by default
478507
const size_t batch_size = sp.buffer_config_.get_search_window_size();
@@ -535,7 +564,7 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
535564
NullSVS_BatchIterator(queryBlobCopyPtr, queryParams, this->getAllocator());
536565
} else {
537566
return new (this->getAllocator()) SVS_BatchIterator<impl_type, data_type>(
538-
queryBlobCopyPtr, impl_.get(), queryParams, this->getAllocator());
567+
queryBlobCopyPtr, impl_.get(), queryParams, this->getAllocator(), is_two_level_lvq);
539568
}
540569
}
541570

src/VecSim/algorithms/svs/svs_batch_iterator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ class SVS_BatchIterator : public VecSimBatchIterator {
7171

7272
public:
7373
SVS_BatchIterator(void *query_vector, const Index *index, const VecSimQueryParams *queryParams,
74-
std::shared_ptr<VecSimAllocator> allocator)
74+
std::shared_ptr<VecSimAllocator> allocator, bool is_two_level_lvq)
7575
: VecSimBatchIterator{query_vector, queryParams ? queryParams->timeoutCtx : nullptr,
7676
std::move(allocator)},
7777
done{false}, dim{index->dimensions()}, index_{index},
7878
impl_{std::make_unique<impl_type>(index->make_batch_iterator(
7979
std::span{static_cast<const DataType *>(query_vector), dim}))},
8080
curr_it{impl_->begin()} {
81-
auto sp = svs_details::joinSearchParams(index->get_search_parameters(), queryParams);
81+
auto sp = svs_details::joinSearchParams(index->get_search_parameters(), queryParams,
82+
is_two_level_lvq);
8283
batch_size = queryParams && queryParams->batchSize
8384
? queryParams->batchSize
8485
: sp.buffer_config_.get_search_window_size();

0 commit comments

Comments
 (0)