Merged
Conversation
3c02fb5 to
3381152
Compare
3381152 to
0e5727a
Compare
Collaborator
Author
|
Depends on VectorDB-NTU/RaBitQ-Library#36 |
Collaborator
Author
|
@Greptile |
Collaborator
Author
|
@greptile |
Collaborator
Author
|
@greptile |
Collaborator
Author
|
@greptile |
Collaborator
Author
|
@greptile |
richyreachy
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolve #42
Greptile Summary
This PR introduces a new HNSW-RaBitQ index type (
HNSW_RABITQ) to zvec, combining the HNSW graph structure with RaBitQ scalar quantization for approximate nearest-neighbor search. The implementation spans a newhnsw_rabitqalgorithm directory (~7000 lines), full builder/searcher/streamer support, Python bindings, DB-layer integration, and tests.Key changes:
RabitqConverter(K-means clustering + rotation) andRabitqReformer(quantization + centroid look-up) components implement the two-phase offline/online quantization pipeline.HnswRabitqBuilderperforms a two-phase build: first quantizes all vectors viaRabitqReformer::convert, then builds the HNSW graph in parallel.HnswRabitqSearcherandHnswRabitqStreamersupport all three search modes (standard, brute-force, and p-keys), including group-by and filter operations.HNSW_RABITQcorrectly gates on platform (Linux x86_64), CPU capabilities (AVX2/AVX512F), and data type (FP32).Issues found:
schema.cc) lists onlyFLAT|HNSW|IVFand does not mentionHNSW_RABITQ, which was added to the supported set in this PR.hnsw_rabitq_query_algorithm.cc, afterget_full_estis computed, nodes are unconditionally added to thecandidatesheap without re-checking the full estimate against the topk threshold, leading to unnecessary heap operations on the hot search path.search_bf_by_p_keys_implbeing a no-op,cluster->mount()return value ignored) have been addressed. Thetrain(IndexTrainer::Pointer)overload leavingreformer_null (and thus causing a crash inbuild()) remains unresolved per prior thread history.Confidence Score: 3/5
train(IndexTrainer::Pointer)path leavesreformer_null and will crash on any subsequentbuild()call; this should be resolved before merging.train(IndexTrainer::Pointer)→build()null dereference (tracked in prior review threads with no "fixed" reply) represents a crash-level regression on a documented public API path. The remaining open issues (unused<execinfo.h>include, stale error message, minor candidates-heap performance) are lower severity.src/core/algorithm/hnsw_rabitq/hnsw_rabitq_builder.cc— specifically thetrain(const IndexTrainer::Pointer &)overload (lines 333–348) which does not initializereformer_, and the subsequentbuild()call at line 401 that dereferences it.Important Files Changed
train(IndexTrainer::Pointer)path still leavesreformer_null, which causes a crash inbuild()at thereformer_->convert()call — flagged in prior review threads.get_full_est, nodes are unconditionally added to candidates even when the full estimate is already worse than the topk boundary.search_bf_by_p_keys_implbody is now properly implemented. All three search modes are present and check context validity.add_with_id_implcorrectly serializes graph updates under a shared_mutex. An "orphaned vector" (vector added to entity but graph update fails) edge case exists but is common to all graph index streamers.<execinfo.h>include (line 16) was flagged in prior review threads; no other structural issues.Sequence Diagram
sequenceDiagram participant Caller participant HnswRabitqBuilder participant RabitqConverter participant RabitqReformer participant HnswRabitqEntity participant HnswRabitqAlgorithm Caller->>HnswRabitqBuilder: init(meta, params) HnswRabitqBuilder->>RabitqConverter: init(meta, params) HnswRabitqBuilder->>HnswRabitqEntity: init() HnswRabitqBuilder->>HnswRabitqAlgorithm: init() Caller->>HnswRabitqBuilder: train(holder) HnswRabitqBuilder->>RabitqConverter: train(holder) [K-means clustering] HnswRabitqBuilder->>RabitqConverter: dump(MemoryDumper) HnswRabitqBuilder->>RabitqReformer: init + load(MemoryReadStorage) Note over HnswRabitqBuilder: reformer_ now ready Caller->>HnswRabitqBuilder: build(threads, holder) loop For each vector HnswRabitqBuilder->>RabitqReformer: convert(vec) → quantized_vec HnswRabitqBuilder->>HnswRabitqEntity: add_vector(level, key, quantized_vec) end loop Parallel threads HnswRabitqBuilder->>HnswRabitqAlgorithm: add_node(id, level, ctx) end Caller->>HnswRabitqBuilder: dump(dumper) HnswRabitqBuilder->>RabitqConverter: dump(dumper) [centroids + rotator] HnswRabitqBuilder->>HnswRabitqEntity: dump(dumper) [graph data] Note over Caller: Search path Caller->>HnswRabitqSearcher: load(storage) HnswRabitqSearcher->>RabitqReformer: load(storage) HnswRabitqSearcher->>HnswRabitqEntity: load(storage) Caller->>HnswRabitqSearcher: search(query, count, ctx) HnswRabitqSearcher->>RabitqReformer: transform_to_entity(query) → QueryEntity HnswRabitqSearcher->>HnswRabitqQueryAlgorithm: search(QueryEntity, ctx)Last reviewed commit: "Merge remote-trackin..."