@@ -83,8 +83,16 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
83
83
84
84
// Index search parameters
85
85
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;
86
90
double epsilon;
87
91
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
+
88
96
// SVS thread pool
89
97
VecSimSVSThreadPool threadpool_;
90
98
svs::logging::logger_ptr logger_;
@@ -137,7 +145,7 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
137
145
138
146
// Construct SVS index initial storage with compression if needed
139
147
auto data = storage_traits_t::create_storage (points, this ->blockSize , threadpool_handle,
140
- this ->getAllocator ());
148
+ this ->getAllocator (), this -> leanvec_dim );
141
149
// Compute the entry point.
142
150
auto entry_point =
143
151
svs::index::vamana::extensions::compute_entry_point (data, threadpool_handle);
@@ -164,7 +172,7 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
164
172
165
173
// Configure default search parameters
166
174
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 });
168
176
impl_->set_search_parameters (sp);
169
177
impl_->reset_performance_parameters ();
170
178
}
@@ -289,14 +297,31 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
289
297
}
290
298
}
291
299
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
+
292
312
public:
293
313
SVSIndex (const SVSParams ¶ms, const AbstractIndexInitParams &abstractInitParams,
294
314
const index_component_t &components, bool force_preprocessing)
295
315
: Base{abstractInitParams, components}, forcePreprocessing{force_preprocessing},
296
316
changes_num{0 }, buildParams{svs_details::makeVamanaBuildParameters (params)},
297
317
search_window_size{svs_details::getOrDefault (params.search_window_size ,
298
318
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)},
299
323
epsilon{svs_details::getOrDefault (params.epsilon , SVS_VAMANA_DEFAULT_EPSILON)},
324
+ is_two_level_lvq{isTwoLevelLVQ (params.quantBits )},
300
325
threadpool_{std::max (size_t {SVS_VAMANA_DEFAULT_NUM_THREADS}, params.num_threads )},
301
326
impl_{nullptr } {
302
327
logger_ = makeLogger ();
@@ -351,6 +376,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
351
376
.numThreads = this ->getNumThreads (),
352
377
.numberOfMarkedDeletedNodes = this ->changes_num ,
353
378
.searchWindowSize = this ->search_window_size ,
379
+ .searchBufferCapacity = this ->search_buffer_capacity ,
380
+ .leanvecDim = this ->leanvec_dim ,
354
381
.epsilon = this ->epsilon };
355
382
return info;
356
383
}
@@ -427,7 +454,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
427
454
auto query = svs::data::ConstSimpleDataView<DataType>{
428
455
static_cast <const DataType *>(processed_query), 1 , this ->dim };
429
456
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);
431
459
432
460
auto timeoutCtx = queryParams ? queryParams->timeoutCtx : nullptr ;
433
461
auto cancel = [timeoutCtx]() { return VECSIM_TIMEOUT (timeoutCtx); };
@@ -472,7 +500,8 @@ class SVSIndex : public VecSimIndexAbstract<svs_details::vecsim_dt<DataType>, fl
472
500
this ->dim };
473
501
474
502
// 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);
476
505
// SVS BatchIterator handles the search in batches
477
506
// The batch size is set to the index search window size by default
478
507
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
535
564
NullSVS_BatchIterator (queryBlobCopyPtr, queryParams, this ->getAllocator ());
536
565
} else {
537
566
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 );
539
568
}
540
569
}
541
570
0 commit comments