Skip to content

Commit c549686

Browse files
authored
build(rabitq): upgrade to RaBitQ 0.7 modular targets (#814)
1 parent 60956b1 commit c549686

21 files changed

Lines changed: 135 additions & 293 deletions

‎.gitattributes‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
# Auto-generated files — collapsed in GitHub PR diffs
22
src/db/index/column/fts_column/gen/** linguist-generated=true
33
src/db/sqlengine/antlr/gen/** linguist-generated=true
4-
5-
# Unified diff context lines use a leading space by definition.
6-
thirdparty/RaBitQ-Library/*.patch whitespace=-blank-at-eol

‎.gitmodules‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
url = https://github.com/Neargye/magic_enum.git
3737
ignore = dirty
3838
[submodule "thirdparty/RaBitQ-Library/RaBitQ-Library-0.1"]
39-
path = thirdparty/RaBitQ-Library/RaBitQ-Library-0.3.8
39+
path = thirdparty/RaBitQ-Library/RaBitQ-Library-0.7.0
4040
url = https://github.com/VectorDB-NTU/RaBitQ-Library.git
4141
ignore = dirty
4242
[submodule "thirdparty/aio/libaio-0.3"]

‎CMakeLists.txt‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,11 @@ if(NOT ANDROID AND NOT IOS AND CMAKE_SIZEOF_VOID_P EQUAL 8
160160
set(RABITQ_AVX2_FLAGS "/arch:AVX2")
161161
set(RABITQ_AVX512_FLAGS "/arch:AVX512")
162162
set(RABITQ_AVX512_POPCNT_FLAGS "/arch:AVX512")
163-
set(RABITQ_HNSW_AVX512_CORE_FLAGS "/arch:AVX512")
164163
else()
165164
set(RABITQ_AVX2_FLAGS "-mavx2;-mfma")
166165
set(RABITQ_AVX512_FLAGS "-mavx512f;-mavx512bw;-mavx512dq;-mfma")
167166
set(RABITQ_AVX512_POPCNT_FLAGS
168167
"-mavx512f;-mavx512bw;-mavx512dq;-mavx512vpopcntdq;-mfma")
169-
set(RABITQ_HNSW_AVX512_CORE_FLAGS
170-
"-mavx512f;-mavx512bw;-mavx512dq;-mavx2;-mfma")
171168
endif()
172169

173170
# check_cxx_compiler_flag takes one argument, so the semicolon-separated
@@ -186,11 +183,6 @@ if(NOT ANDROID AND NOT IOS AND CMAKE_SIZEOF_VOID_P EQUAL 8
186183

187184
if(RABITQ_SUPPORTED)
188185
add_definitions(-DRABITQ_SUPPORTED=1)
189-
if(MSVC)
190-
# rabitqlib's AVX2 rotator calls FHT kernels that only exist as MASM on
191-
# MSVC; enable_language() must run in the top-level directory.
192-
enable_language(ASM_MASM)
193-
endif()
194186
else()
195187
add_definitions(-DRABITQ_SUPPORTED=0)
196188
message(STATUS "RaBitQ support disabled - compiler cannot build all runtime dispatch variants")

‎src/core/algorithm/hnsw_rabitq/hnsw_rabitq_entity.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
#include "hnsw_rabitq_entity.h"
15-
#include <rabitqlib/index/query.hpp>
15+
#include <rabitqlib/core/data_layout.hpp>
1616
#include "utility/sparse_utility.h"
1717
#include "zvec/core/framework/index_stats.h"
1818

‎src/core/algorithm/hnsw_rabitq/hnsw_rabitq_query_algorithm.cc‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <chrono>
1616
#include <iostream>
1717
#include <ailego/internal/cpu_features.h>
18-
#include <rabitqlib/index/estimator.hpp>
18+
#include <rabitqlib/core/estimator.hpp>
1919
#include "zvec/ailego/internal/platform.h"
2020
#include "hnsw_rabitq_entity.h"
2121
#include "hnsw_rabitq_query_entity.h"
@@ -46,7 +46,7 @@ int HnswRabitqQueryAlgorithm::cleanup() {
4646
int HnswRabitqQueryAlgorithm::search(HnswRabitqQueryEntity *entity,
4747
HnswRabitqContext *ctx) const {
4848
spin_lock_.lock();
49-
auto maxLevel = entity_.cur_max_level();
49+
auto max_level = entity_.cur_max_level();
5050
auto entry_point = entity_.entry_point();
5151
spin_lock_.unlock();
5252

@@ -57,7 +57,7 @@ int HnswRabitqQueryAlgorithm::search(HnswRabitqQueryEntity *entity,
5757
EstimateRecord curest;
5858
get_bin_est(entity_.get_vector(entry_point), curest, *entity);
5959

60-
for (level_t cur_level = maxLevel; cur_level >= 1; --cur_level) {
60+
for (level_t cur_level = max_level; cur_level >= 1; --cur_level) {
6161
select_entry_point(cur_level, &entry_point, &curest, ctx, entity);
6262
}
6363

@@ -170,10 +170,10 @@ void HnswRabitqQueryAlgorithm::search_neighbors(
170170

171171
if (ex_bits_ > 0) {
172172
// Check preliminary score against current worst full estimate.
173-
bool flag_update_KNNs =
173+
bool update_knns =
174174
(!topk.full()) || candest.low_dist < topk[0].second.est_dist;
175175

176-
if (flag_update_KNNs) {
176+
if (update_knns) {
177177
// Compute the full estimate if promising.
178178
get_full_est(cand_vector, candest, *query_entity);
179179
} else {

‎src/core/algorithm/hnsw_rabitq/hnsw_rabitq_query_entity.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <memory>
1818
#include <vector>
19-
#include <rabitqlib/index/query.hpp>
19+
#include <rabitqlib/core/query.hpp>
2020
namespace zvec::core {
2121

2222
struct HnswRabitqQueryEntity {

‎src/core/algorithm/hnsw_rabitq/rabitq_converter.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "rabitq_converter.h"
1616
#include <cstring>
1717
#include <memory>
18-
#include <rabitqlib/utils/rotator.hpp>
18+
#include <rabitqlib/core/rotator.hpp>
1919
#include <zvec/ailego/container/params.h>
2020
#include <zvec/ailego/parallel/thread_pool.h>
2121
#include <zvec/ailego/utility/string_helper.h>

‎src/core/algorithm/hnsw_rabitq/rabitq_converter.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <memory>
1717
#include <vector>
18-
#include <rabitqlib/utils/rotator.hpp>
18+
#include <rabitqlib/core/rotator.hpp>
1919
#include "zvec/core/framework/index_cluster.h"
2020
#include "zvec/core/framework/index_converter.h"
2121
#include "zvec/core/framework/index_reformer.h"

‎src/core/algorithm/hnsw_rabitq/rabitq_reformer.cc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "rabitq_reformer.h"
1616
#include <string>
1717
#include <vector>
18-
#include <rabitqlib/defines.hpp>
19-
#include <rabitqlib/index/query.hpp>
20-
#include <rabitqlib/quantization/rabitq.hpp>
21-
#include <rabitqlib/utils/rotator.hpp>
18+
#include <rabitqlib/core/encoder.hpp>
19+
#include <rabitqlib/core/metric.hpp>
20+
#include <rabitqlib/core/query.hpp>
21+
#include <rabitqlib/core/rotator.hpp>
2222
#include <zvec/ailego/logger/logger.h>
2323
#include <zvec/ailego/utility/string_helper.h>
2424
#include "core/algorithm/cluster/linear_seeker.h"

‎src/core/algorithm/hnsw_rabitq/rabitq_utils.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <memory>
1717
#include <vector>
18-
#include <rabitqlib/utils/rotator.hpp>
18+
#include <rabitqlib/core/rotator.hpp>
1919
#include "zvec/core/framework/index_dumper.h"
2020

2121
namespace zvec {

0 commit comments

Comments
 (0)