faiss 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/ext/faiss/index.cpp +8 -0
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/IVFlib.cpp +25 -49
- data/vendor/faiss/faiss/Index.cpp +11 -0
- data/vendor/faiss/faiss/Index.h +24 -1
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +1 -0
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +5 -1
- data/vendor/faiss/faiss/IndexFastScan.cpp +1 -1
- data/vendor/faiss/faiss/IndexFastScan.h +3 -8
- data/vendor/faiss/faiss/IndexFlat.cpp +374 -4
- data/vendor/faiss/faiss/IndexFlat.h +80 -0
- data/vendor/faiss/faiss/IndexHNSW.cpp +90 -1
- data/vendor/faiss/faiss/IndexHNSW.h +57 -1
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.cpp +34 -149
- data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +86 -2
- data/vendor/faiss/faiss/IndexIVFRaBitQ.h +3 -1
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +293 -115
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +52 -16
- data/vendor/faiss/faiss/IndexPQ.cpp +4 -1
- data/vendor/faiss/faiss/IndexPreTransform.cpp +14 -0
- data/vendor/faiss/faiss/IndexPreTransform.h +9 -0
- data/vendor/faiss/faiss/IndexRaBitQ.cpp +96 -16
- data/vendor/faiss/faiss/IndexRaBitQ.h +5 -1
- data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +238 -93
- data/vendor/faiss/faiss/IndexRaBitQFastScan.h +35 -9
- data/vendor/faiss/faiss/IndexRefine.cpp +49 -0
- data/vendor/faiss/faiss/IndexRefine.h +17 -0
- data/vendor/faiss/faiss/clone_index.cpp +2 -0
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +3 -1
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +1 -1
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +1 -1
- data/vendor/faiss/faiss/impl/DistanceComputer.h +74 -3
- data/vendor/faiss/faiss/impl/HNSW.cpp +294 -15
- data/vendor/faiss/faiss/impl/HNSW.h +31 -2
- data/vendor/faiss/faiss/impl/IDSelector.h +3 -3
- data/vendor/faiss/faiss/impl/Panorama.cpp +193 -0
- data/vendor/faiss/faiss/impl/Panorama.h +204 -0
- data/vendor/faiss/faiss/impl/RaBitQStats.cpp +29 -0
- data/vendor/faiss/faiss/impl/RaBitQStats.h +56 -0
- data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +54 -6
- data/vendor/faiss/faiss/impl/RaBitQUtils.h +183 -6
- data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +269 -84
- data/vendor/faiss/faiss/impl/RaBitQuantizer.h +71 -4
- data/vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.cpp +362 -0
- data/vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.h +112 -0
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +6 -9
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +1 -3
- data/vendor/faiss/faiss/impl/index_read.cpp +156 -12
- data/vendor/faiss/faiss/impl/index_write.cpp +142 -19
- data/vendor/faiss/faiss/impl/platform_macros.h +12 -0
- data/vendor/faiss/faiss/impl/svs_io.cpp +86 -0
- data/vendor/faiss/faiss/impl/svs_io.h +67 -0
- data/vendor/faiss/faiss/index_factory.cpp +182 -15
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +1 -1
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +1 -1
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +18 -109
- data/vendor/faiss/faiss/invlists/InvertedLists.h +2 -18
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +1 -1
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSFaissUtils.h +261 -0
- data/vendor/faiss/faiss/svs/IndexSVSFlat.cpp +117 -0
- data/vendor/faiss/faiss/svs/IndexSVSFlat.h +66 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamana.cpp +245 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamana.h +137 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLVQ.cpp +39 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLVQ.h +42 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.cpp +149 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.h +58 -0
- data/vendor/faiss/faiss/utils/distances.cpp +0 -3
- data/vendor/faiss/faiss/utils/utils.cpp +4 -0
- metadata +18 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Portions Copyright 2025 Intel Corporation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#pragma once
|
|
25
|
+
|
|
26
|
+
#include <faiss/Index.h>
|
|
27
|
+
#include <faiss/svs/IndexSVSFaissUtils.h>
|
|
28
|
+
|
|
29
|
+
#include <svs/runtime/api_defs.h>
|
|
30
|
+
|
|
31
|
+
#include <iostream>
|
|
32
|
+
|
|
33
|
+
namespace faiss {
|
|
34
|
+
|
|
35
|
+
struct SearchParametersSVSVamana : public SearchParameters {
|
|
36
|
+
size_t search_window_size = 0;
|
|
37
|
+
size_t search_buffer_capacity = 0;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// redefinition for swig export
|
|
41
|
+
enum SVSStorageKind {
|
|
42
|
+
SVS_FP32,
|
|
43
|
+
SVS_FP16,
|
|
44
|
+
SVS_SQI8,
|
|
45
|
+
SVS_LVQ4x0,
|
|
46
|
+
SVS_LVQ4x4,
|
|
47
|
+
SVS_LVQ4x8,
|
|
48
|
+
SVS_LeanVec4x4,
|
|
49
|
+
SVS_LeanVec4x8,
|
|
50
|
+
SVS_LeanVec8x8,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
inline svs_runtime::StorageKind to_svs_storage_kind(SVSStorageKind kind) {
|
|
54
|
+
switch (kind) {
|
|
55
|
+
case SVS_FP32:
|
|
56
|
+
return svs_runtime::StorageKind::FP32;
|
|
57
|
+
case SVS_FP16:
|
|
58
|
+
return svs_runtime::StorageKind::FP16;
|
|
59
|
+
case SVS_SQI8:
|
|
60
|
+
return svs_runtime::StorageKind::SQI8;
|
|
61
|
+
case SVS_LVQ4x0:
|
|
62
|
+
return svs_runtime::StorageKind::LVQ4x0;
|
|
63
|
+
case SVS_LVQ4x4:
|
|
64
|
+
return svs_runtime::StorageKind::LVQ4x4;
|
|
65
|
+
case SVS_LVQ4x8:
|
|
66
|
+
return svs_runtime::StorageKind::LVQ4x8;
|
|
67
|
+
case SVS_LeanVec4x4:
|
|
68
|
+
return svs_runtime::StorageKind::LeanVec4x4;
|
|
69
|
+
case SVS_LeanVec4x8:
|
|
70
|
+
return svs_runtime::StorageKind::LeanVec4x8;
|
|
71
|
+
case SVS_LeanVec8x8:
|
|
72
|
+
return svs_runtime::StorageKind::LeanVec8x8;
|
|
73
|
+
default:
|
|
74
|
+
FAISS_ASSERT(!"not supported SVS storage kind");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
struct IndexSVSVamana : Index {
|
|
79
|
+
size_t graph_max_degree;
|
|
80
|
+
size_t prune_to;
|
|
81
|
+
float alpha = 1.2;
|
|
82
|
+
size_t search_window_size = 10;
|
|
83
|
+
size_t search_buffer_capacity = 10;
|
|
84
|
+
size_t construction_window_size = 40;
|
|
85
|
+
size_t max_candidate_pool_size = 200;
|
|
86
|
+
bool use_full_search_history = true;
|
|
87
|
+
|
|
88
|
+
SVSStorageKind storage_kind;
|
|
89
|
+
|
|
90
|
+
IndexSVSVamana();
|
|
91
|
+
|
|
92
|
+
IndexSVSVamana(
|
|
93
|
+
idx_t d,
|
|
94
|
+
size_t degree,
|
|
95
|
+
MetricType metric = METRIC_L2,
|
|
96
|
+
SVSStorageKind storage = SVSStorageKind::SVS_FP32);
|
|
97
|
+
|
|
98
|
+
~IndexSVSVamana() override;
|
|
99
|
+
|
|
100
|
+
// static member that exposes whether or not LVQ/LeanVec are enabled for
|
|
101
|
+
// this build and runtime.
|
|
102
|
+
static bool is_lvq_leanvec_enabled();
|
|
103
|
+
|
|
104
|
+
void add(idx_t n, const float* x) override;
|
|
105
|
+
|
|
106
|
+
void search(
|
|
107
|
+
idx_t n,
|
|
108
|
+
const float* x,
|
|
109
|
+
idx_t k,
|
|
110
|
+
float* distances,
|
|
111
|
+
idx_t* labels,
|
|
112
|
+
const SearchParameters* params = nullptr) const override;
|
|
113
|
+
|
|
114
|
+
void range_search(
|
|
115
|
+
idx_t n,
|
|
116
|
+
const float* x,
|
|
117
|
+
float radius,
|
|
118
|
+
RangeSearchResult* result,
|
|
119
|
+
const SearchParameters* params = nullptr) const override;
|
|
120
|
+
|
|
121
|
+
size_t remove_ids(const IDSelector& sel) override;
|
|
122
|
+
|
|
123
|
+
void reset() override;
|
|
124
|
+
|
|
125
|
+
/* Serialization and deserialization helpers */
|
|
126
|
+
void serialize_impl(std::ostream& out) const;
|
|
127
|
+
virtual void deserialize_impl(std::istream& in);
|
|
128
|
+
|
|
129
|
+
/* The actual SVS implementation */
|
|
130
|
+
svs_runtime::DynamicVamanaIndex* impl{nullptr};
|
|
131
|
+
|
|
132
|
+
protected:
|
|
133
|
+
/* Initializes the implementation*/
|
|
134
|
+
virtual void create_impl();
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
} // namespace faiss
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Portions Copyright 2025 Intel Corporation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#include <faiss/svs/IndexSVSVamanaLVQ.h>
|
|
25
|
+
|
|
26
|
+
namespace faiss {
|
|
27
|
+
|
|
28
|
+
IndexSVSVamanaLVQ::IndexSVSVamanaLVQ() : IndexSVSVamana() {
|
|
29
|
+
storage_kind = SVSStorageKind::SVS_LVQ4x0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
IndexSVSVamanaLVQ::IndexSVSVamanaLVQ(
|
|
33
|
+
idx_t d,
|
|
34
|
+
size_t degree,
|
|
35
|
+
MetricType metric,
|
|
36
|
+
SVSStorageKind storage)
|
|
37
|
+
: IndexSVSVamana(d, degree, metric, storage) {}
|
|
38
|
+
|
|
39
|
+
} // namespace faiss
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Portions Copyright 2025 Intel Corporation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#pragma once
|
|
25
|
+
|
|
26
|
+
#include <faiss/svs/IndexSVSVamana.h>
|
|
27
|
+
|
|
28
|
+
namespace faiss {
|
|
29
|
+
|
|
30
|
+
struct IndexSVSVamanaLVQ : IndexSVSVamana {
|
|
31
|
+
IndexSVSVamanaLVQ();
|
|
32
|
+
|
|
33
|
+
IndexSVSVamanaLVQ(
|
|
34
|
+
idx_t d,
|
|
35
|
+
size_t degree,
|
|
36
|
+
MetricType metric = METRIC_L2,
|
|
37
|
+
SVSStorageKind storage = SVSStorageKind::SVS_LVQ4x4);
|
|
38
|
+
|
|
39
|
+
~IndexSVSVamanaLVQ() override = default;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
} // namespace faiss
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Portions Copyright 2025 Intel Corporation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#include <faiss/svs/IndexSVSFaissUtils.h>
|
|
25
|
+
#include <faiss/svs/IndexSVSVamanaLeanVec.h>
|
|
26
|
+
|
|
27
|
+
#include <svs/runtime/dynamic_vamana_index.h>
|
|
28
|
+
#include <svs/runtime/training.h>
|
|
29
|
+
#include <svs/runtime/vamana_index.h>
|
|
30
|
+
|
|
31
|
+
#include <memory>
|
|
32
|
+
#include <span>
|
|
33
|
+
#include "faiss/svs/IndexSVSVamana.h"
|
|
34
|
+
|
|
35
|
+
namespace faiss {
|
|
36
|
+
|
|
37
|
+
IndexSVSVamanaLeanVec::IndexSVSVamanaLeanVec() : IndexSVSVamana() {
|
|
38
|
+
is_trained = false;
|
|
39
|
+
storage_kind = SVSStorageKind::SVS_LeanVec4x4;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
IndexSVSVamanaLeanVec::IndexSVSVamanaLeanVec(
|
|
43
|
+
idx_t d,
|
|
44
|
+
size_t degree,
|
|
45
|
+
MetricType metric,
|
|
46
|
+
size_t leanvec_dims,
|
|
47
|
+
SVSStorageKind storage_kind)
|
|
48
|
+
: IndexSVSVamana(d, degree, metric, storage_kind) {
|
|
49
|
+
is_trained = false;
|
|
50
|
+
leanvec_d = leanvec_dims == 0 ? d / 2 : leanvec_dims;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
IndexSVSVamanaLeanVec::~IndexSVSVamanaLeanVec() {
|
|
54
|
+
if (training_data) {
|
|
55
|
+
auto status = svs_runtime::LeanVecTrainingData::destroy(training_data);
|
|
56
|
+
FAISS_ASSERT(status.ok());
|
|
57
|
+
training_data = nullptr;
|
|
58
|
+
}
|
|
59
|
+
IndexSVSVamana::~IndexSVSVamana();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void IndexSVSVamanaLeanVec::add(idx_t n, const float* x) {
|
|
63
|
+
FAISS_THROW_IF_MSG(
|
|
64
|
+
!is_trained, "Index not trained: call train() before add().");
|
|
65
|
+
IndexSVSVamana::add(n, x);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void IndexSVSVamanaLeanVec::train(idx_t n, const float* x) {
|
|
69
|
+
FAISS_THROW_IF_MSG(
|
|
70
|
+
training_data || impl, "Index already trained or contains data.");
|
|
71
|
+
|
|
72
|
+
FAISS_THROW_IF_NOT_MSG(
|
|
73
|
+
IndexSVSVamana::is_lvq_leanvec_enabled(),
|
|
74
|
+
"LVQ/LeanVec support not available on this platform or build");
|
|
75
|
+
|
|
76
|
+
auto status = svs_runtime::LeanVecTrainingData::build(
|
|
77
|
+
&training_data, d, n, x, leanvec_d);
|
|
78
|
+
if (!status.ok()) {
|
|
79
|
+
FAISS_THROW_MSG(status.message());
|
|
80
|
+
}
|
|
81
|
+
FAISS_THROW_IF_NOT_MSG(
|
|
82
|
+
training_data, "Failed to build leanvec training info.");
|
|
83
|
+
is_trained = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void IndexSVSVamanaLeanVec::serialize_training_data(std::ostream& out) const {
|
|
87
|
+
FAISS_THROW_IF_NOT_MSG(
|
|
88
|
+
training_data, "Cannot serialize: Training data not initialized.");
|
|
89
|
+
|
|
90
|
+
auto status = training_data->save(out);
|
|
91
|
+
if (!status.ok()) {
|
|
92
|
+
FAISS_THROW_MSG(status.message());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void IndexSVSVamanaLeanVec::deserialize_training_data(std::istream& in) {
|
|
97
|
+
svs_runtime::LeanVecTrainingData* tdata = nullptr;
|
|
98
|
+
auto status = svs_runtime::LeanVecTrainingData::load(&tdata, in);
|
|
99
|
+
if (!status.ok()) {
|
|
100
|
+
FAISS_THROW_MSG(status.message());
|
|
101
|
+
}
|
|
102
|
+
FAISS_THROW_IF_NOT_MSG(tdata, "Failed to load leanvec training data.");
|
|
103
|
+
training_data = tdata;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void IndexSVSVamanaLeanVec::create_impl() {
|
|
107
|
+
ntotal = 0;
|
|
108
|
+
auto svs_metric = to_svs_metric(metric_type);
|
|
109
|
+
auto svs_storage_kind = to_svs_storage_kind(storage_kind);
|
|
110
|
+
auto build_params = svs_runtime::VamanaIndex::BuildParams{
|
|
111
|
+
.graph_max_degree = graph_max_degree,
|
|
112
|
+
.prune_to = prune_to,
|
|
113
|
+
.alpha = alpha,
|
|
114
|
+
.construction_window_size = construction_window_size,
|
|
115
|
+
.max_candidate_pool_size = max_candidate_pool_size,
|
|
116
|
+
.use_full_search_history = use_full_search_history,
|
|
117
|
+
};
|
|
118
|
+
auto search_params = svs_runtime::VamanaIndex::SearchParams{
|
|
119
|
+
.search_window_size = search_window_size,
|
|
120
|
+
.search_buffer_capacity = search_buffer_capacity,
|
|
121
|
+
};
|
|
122
|
+
auto status = svs_runtime::Status_Ok;
|
|
123
|
+
if (training_data) {
|
|
124
|
+
status = svs_runtime::DynamicVamanaIndexLeanVec::build(
|
|
125
|
+
&impl,
|
|
126
|
+
d,
|
|
127
|
+
svs_metric,
|
|
128
|
+
svs_storage_kind,
|
|
129
|
+
training_data,
|
|
130
|
+
build_params,
|
|
131
|
+
search_params);
|
|
132
|
+
} else {
|
|
133
|
+
status = svs_runtime::DynamicVamanaIndexLeanVec::build(
|
|
134
|
+
&impl,
|
|
135
|
+
d,
|
|
136
|
+
svs_metric,
|
|
137
|
+
svs_storage_kind,
|
|
138
|
+
leanvec_d,
|
|
139
|
+
build_params,
|
|
140
|
+
search_params);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!status.ok()) {
|
|
144
|
+
FAISS_THROW_MSG(status.message());
|
|
145
|
+
}
|
|
146
|
+
FAISS_THROW_IF_NOT(impl);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
} // namespace faiss
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Portions Copyright 2025 Intel Corporation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#pragma once
|
|
25
|
+
|
|
26
|
+
#include <faiss/svs/IndexSVSVamana.h>
|
|
27
|
+
|
|
28
|
+
namespace faiss {
|
|
29
|
+
|
|
30
|
+
struct IndexSVSVamanaLeanVec : IndexSVSVamana {
|
|
31
|
+
IndexSVSVamanaLeanVec();
|
|
32
|
+
|
|
33
|
+
IndexSVSVamanaLeanVec(
|
|
34
|
+
idx_t d,
|
|
35
|
+
size_t degree,
|
|
36
|
+
MetricType metric = METRIC_L2,
|
|
37
|
+
size_t leanvec_dims = 0,
|
|
38
|
+
SVSStorageKind storage = SVSStorageKind::SVS_LeanVec4x4);
|
|
39
|
+
|
|
40
|
+
~IndexSVSVamanaLeanVec() override;
|
|
41
|
+
|
|
42
|
+
void add(idx_t n, const float* x) override;
|
|
43
|
+
|
|
44
|
+
void train(idx_t n, const float* x) override;
|
|
45
|
+
|
|
46
|
+
void serialize_training_data(std::ostream& out) const;
|
|
47
|
+
void deserialize_training_data(std::istream& in);
|
|
48
|
+
|
|
49
|
+
size_t leanvec_d;
|
|
50
|
+
|
|
51
|
+
/* Training information */
|
|
52
|
+
svs_runtime::LeanVecTrainingData* training_data{nullptr};
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
void create_impl() override;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace faiss
|
|
@@ -321,7 +321,6 @@ void exhaustive_L2sqr_blas_default_impl(
|
|
|
321
321
|
ip_block.get(),
|
|
322
322
|
&nyi);
|
|
323
323
|
}
|
|
324
|
-
#pragma omp parallel for
|
|
325
324
|
for (int64_t i = i0; i < i1; i++) {
|
|
326
325
|
float* ip_line = ip_block.get() + (i - i0) * (j1 - j0);
|
|
327
326
|
|
|
@@ -423,7 +422,6 @@ void exhaustive_L2sqr_blas_cmax_avx2(
|
|
|
423
422
|
ip_block.get(),
|
|
424
423
|
&nyi);
|
|
425
424
|
}
|
|
426
|
-
#pragma omp parallel for
|
|
427
425
|
for (int64_t i = i0; i < i1; i++) {
|
|
428
426
|
float* ip_line = ip_block.get() + (i - i0) * (j1 - j0);
|
|
429
427
|
|
|
@@ -633,7 +631,6 @@ void exhaustive_L2sqr_blas_cmax_sve(
|
|
|
633
631
|
ip_block.get(),
|
|
634
632
|
&nyi);
|
|
635
633
|
}
|
|
636
|
-
#pragma omp parallel for
|
|
637
634
|
for (int64_t i = i0; i < i1; i++) {
|
|
638
635
|
const size_t count = j1 - j0;
|
|
639
636
|
float* ip_line = ip_block.get() + (i - i0) * count;
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faiss
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -249,6 +249,8 @@ files:
|
|
|
249
249
|
- vendor/faiss/faiss/impl/NNDescent.h
|
|
250
250
|
- vendor/faiss/faiss/impl/NSG.cpp
|
|
251
251
|
- vendor/faiss/faiss/impl/NSG.h
|
|
252
|
+
- vendor/faiss/faiss/impl/Panorama.cpp
|
|
253
|
+
- vendor/faiss/faiss/impl/Panorama.h
|
|
252
254
|
- vendor/faiss/faiss/impl/PanoramaStats.cpp
|
|
253
255
|
- vendor/faiss/faiss/impl/PanoramaStats.h
|
|
254
256
|
- vendor/faiss/faiss/impl/PolysemousTraining.cpp
|
|
@@ -259,10 +261,14 @@ files:
|
|
|
259
261
|
- vendor/faiss/faiss/impl/ProductQuantizer.cpp
|
|
260
262
|
- vendor/faiss/faiss/impl/ProductQuantizer.h
|
|
261
263
|
- vendor/faiss/faiss/impl/Quantizer.h
|
|
264
|
+
- vendor/faiss/faiss/impl/RaBitQStats.cpp
|
|
265
|
+
- vendor/faiss/faiss/impl/RaBitQStats.h
|
|
262
266
|
- vendor/faiss/faiss/impl/RaBitQUtils.cpp
|
|
263
267
|
- vendor/faiss/faiss/impl/RaBitQUtils.h
|
|
264
268
|
- vendor/faiss/faiss/impl/RaBitQuantizer.cpp
|
|
265
269
|
- vendor/faiss/faiss/impl/RaBitQuantizer.h
|
|
270
|
+
- vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.cpp
|
|
271
|
+
- vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.h
|
|
266
272
|
- vendor/faiss/faiss/impl/ResidualQuantizer.cpp
|
|
267
273
|
- vendor/faiss/faiss/impl/ResidualQuantizer.h
|
|
268
274
|
- vendor/faiss/faiss/impl/ResultHandler.h
|
|
@@ -296,6 +302,8 @@ files:
|
|
|
296
302
|
- vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp
|
|
297
303
|
- vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h
|
|
298
304
|
- vendor/faiss/faiss/impl/simd_result_handlers.h
|
|
305
|
+
- vendor/faiss/faiss/impl/svs_io.cpp
|
|
306
|
+
- vendor/faiss/faiss/impl/svs_io.h
|
|
299
307
|
- vendor/faiss/faiss/impl/zerocopy_io.cpp
|
|
300
308
|
- vendor/faiss/faiss/impl/zerocopy_io.h
|
|
301
309
|
- vendor/faiss/faiss/index_factory.cpp
|
|
@@ -313,6 +321,15 @@ files:
|
|
|
313
321
|
- vendor/faiss/faiss/invlists/OnDiskInvertedLists.h
|
|
314
322
|
- vendor/faiss/faiss/python/python_callbacks.cpp
|
|
315
323
|
- vendor/faiss/faiss/python/python_callbacks.h
|
|
324
|
+
- vendor/faiss/faiss/svs/IndexSVSFaissUtils.h
|
|
325
|
+
- vendor/faiss/faiss/svs/IndexSVSFlat.cpp
|
|
326
|
+
- vendor/faiss/faiss/svs/IndexSVSFlat.h
|
|
327
|
+
- vendor/faiss/faiss/svs/IndexSVSVamana.cpp
|
|
328
|
+
- vendor/faiss/faiss/svs/IndexSVSVamana.h
|
|
329
|
+
- vendor/faiss/faiss/svs/IndexSVSVamanaLVQ.cpp
|
|
330
|
+
- vendor/faiss/faiss/svs/IndexSVSVamanaLVQ.h
|
|
331
|
+
- vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.cpp
|
|
332
|
+
- vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.h
|
|
316
333
|
- vendor/faiss/faiss/utils/AlignedTable.h
|
|
317
334
|
- vendor/faiss/faiss/utils/Heap.cpp
|
|
318
335
|
- vendor/faiss/faiss/utils/Heap.h
|