Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9398042
Enable IVF train only mode where centroid are built but data is not
ibhati Nov 6, 2025
7505c68
Add cluster assignment functionality and tests
ibhati Nov 13, 2025
dbef61e
Add integration for train only scenario
ibhati Nov 14, 2025
44eb6d8
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Nov 14, 2025
05702a5
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Nov 19, 2025
6fa85c0
Minor fixes
ibhati Nov 19, 2025
149ff83
First attempt at dynamic index
ibhati Dec 2, 2025
3796c5d
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 2, 2025
8700c6d
Optimized search and add_points functions
ibhati Dec 3, 2025
fcc8d44
Clang tidy
ibhati Dec 5, 2025
769e7ea
Python bindings for dynamic IVF, first version
ibhati Dec 5, 2025
aef3044
Added get_distance and consolidate
ibhati Dec 6, 2025
8d24b99
Add get_distance support in static ivf index
ibhati Dec 6, 2025
3bf3310
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 8, 2025
60434e6
Entable intra_query_threads and separate clustering threads
ibhati Dec 9, 2025
da236b5
Add examples and support fp16 clusters from Python
ibhati Dec 9, 2025
9dcec84
Simplify get_distance implementation
ibhati Dec 10, 2025
8a2270c
progress
ibhati Dec 11, 2025
a89c3a1
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 11, 2025
74b2672
Restructured the Python APIs for dynamic IVF to match static
ibhati Dec 12, 2025
c373c1c
formatting
ibhati Dec 12, 2025
dbe2ae8
Make dynamic IVF APIs similar to static
ibhati Dec 12, 2025
0def7ab
Improve compact implementation
ibhati Dec 13, 2025
639ca08
Add support for SQDataset
ibhati Dec 13, 2025
2f714b2
clang format
ibhati Dec 13, 2025
595bfb4
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 15, 2025
52d9b47
Incorporated review comments
ibhati Dec 15, 2025
9ad794f
Add thread safety for get_distance function
ibhati Dec 16, 2025
d346c5e
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 16, 2025
76c68b6
formatting
ibhati Dec 16, 2025
080a869
Merge remote-tracking branch 'origin/main' into ib/dynamic_ivf
ibhati Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(CPP_FILES
# ivf
if (SVS_EXPERIMENTAL_ENABLE_IVF)
list(APPEND CPP_FILES
src/dynamic_ivf.cpp
src/ivf.cpp
)
endif()
Expand Down
39 changes: 39 additions & 0 deletions bindings/python/include/svs/python/dynamic_ivf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

// svs python bindings
#include "svs/python/core.h"

#include <pybind11/pybind11.h>

namespace svs::python::dynamic_ivf {

// Specializations
template <typename F> void for_standard_specializations(F&& f) {
#define X(Q, T, N) f.template operator()<Q, T, N>()
X(float, float, Dynamic);
X(float, float, Dynamic);
X(float, svs::Float16, Dynamic);
X(float, svs::Float16, Dynamic);
X(float, svs::BFloat16, Dynamic);
X(float, svs::BFloat16, Dynamic);
#undef X
}

void wrap(pybind11::module& m);
} // namespace svs::python::dynamic_ivf
38 changes: 38 additions & 0 deletions bindings/python/include/svs/python/ivf.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "svs/python/common.h"
#include "svs/python/core.h"

#include "svs/core/data/simple.h"
#include "svs/core/distance.h"
#include "svs/index/ivf/clustering.h"
#include "svs/lib/bfloat16.h"
#include "svs/lib/datatype.h"
#include "svs/lib/float16.h"
Expand All @@ -30,6 +32,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl/filesystem.h>

#include <variant>

namespace svs::python {
namespace ivf_specializations {
///
Expand Down Expand Up @@ -61,6 +65,18 @@ template <typename F> void for_standard_specializations(F&& f) {
} // namespace ivf_specializations

namespace ivf {

// The build process in IVF uses Kmeans to get centroids and assignments of data.
// This sparse clustering can be saved with centroids stored as float datatype.
// While assembling, the sparse clustering is used to create DenseClusters and
// centroids datatype can be changed as per the search specializations.
// Support both BFloat16 and Float16 centroids to match data types and leverage AMX.
using ClusteringBF16 =
svs::index::ivf::Clustering<svs::data::SimpleData<svs::BFloat16>, uint32_t>;
using ClusteringF16 =
svs::index::ivf::Clustering<svs::data::SimpleData<svs::Float16>, uint32_t>;
using Clustering = std::variant<ClusteringBF16, ClusteringF16>;

template <typename Manager> void add_interface(pybind11::class_<Manager>& manager) {
manager.def_property_readonly(
"experimental_backend_string",
Expand All @@ -82,6 +98,28 @@ template <typename Manager> void add_interface(pybind11::class_<Manager>& manage

See also: `svs.IVFSearchParameters`.)"
);

manager.def(
"get_distance",
[](const Manager& index, size_t id, const py_contiguous_array_t<float>& query) {
return index.get_distance(id, as_span(query));
},
pybind11::arg("id"),
pybind11::arg("query"),
R"(
Compute the distance between a query vector and a vector in the index.

Args:
id: The ID of the vector in the index.
query: The query vector as a numpy array.

Returns:
The distance between the query and the indexed vector.

Raises:
RuntimeError: If the ID doesn't exist or dimensions don't match.
)"
);
}

void wrap(pybind11::module& m);
Expand Down
Loading
Loading