Repository navigation
perf(hnsw,lvq,vec0): dense-ID slab HNSW, mean-centered LVQ, and opt-in RaBitQ vec0 - #3
Merged
Merged
Conversation
…n RaBitQ vec0 - Maintain contiguous dense_nodes_ table and parallel dense_edges in HNSWIndex/HNSWNode so greedy/beam/quantized search hops index flat std::vector without unordered_map lookups, preserving persistence, soft-deletion, compaction, and thread safety. - Add optional dataset mean-centering (centroid_) and QueryState pre-centering to LVQ8Store/LVQ4Store (Aguerrebere et al. 2023) with 3-op fused FMA inner loops across NEON, AVX2, x86 runtime dispatch, and scalar paths. - Add opt-in RaBitQ/LVQ quantized HNSW mode to vec0 (schema option + C++ helper, FP32 default preserved) and optimize vec0_run_exact_query with l2_squared_distance, bounded max-heap top-k, and small-filter SQL IN pushdown. - Add unit tests in tests/test_invariants.cpp covering dense-ID HNSW parity, mean-centered LVQ accuracy + SIMD parity, and RaBitQ/bounded-heap vec0 parity.
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.
Summary
hnsw.hpp,hnsw_node.hpp): Maintains a contiguousdense_nodes_pointer table and paralleldense_edgesadjacency lists updated on insert, single-threaded insert, parallel build, soft-delete isolation, compaction, clear, and persistence load. Hot-pathgreedy_search_layer_*,beam_search_layer_*, andbeam_search_layer_quantizedindexdense_nodes_[dense_id]directly with zerostd::unordered_maplookups per hop (including for sparse 64-bit external IDs).lvq.hpp,store.hpp,x86_dispatch.hpp,hnsw_quantized.hpp): Adds optional dataset mean-centering (centroid_,fit_centroid(),set_centroid(),build(snap, center_mean), and backward-compatibleadd()) plus query-sideprepare_query()and 3-op fused FMA inner loops (((q - offset) - c * scale)^2) across NEON, AVX2, x86-64 runtime dispatch, and scalar fallbacks.vec0& Bounded-Heap Exact Fast-Path (vec0_module.hpp): Adds opt-inquantization=rabitq|lvq8|lvq4|noneandrerank_factor=Nschema options (plusvec0_set_quantization()) keeping FP32 HNSW as the default. Replacesl2_distance+ fullstd::sortinvec0_run_exact_querywithl2_squared_distance+ bounded max-heap (only takingstd::sqrton the final top-k) and adds small-filterWHERE rowid IN (...)SQL pushdown.tests/test_invariants.cpp): Adds tests for dense-ID HNSW sparse-ID search/delete/isolate/compact/persistence parity, mean-centered LVQ8/LVQ4 accuracy on shifted/anisotropic clusters + SIMD-vs-scalar parity, and opt-in RaBitQvec0+ bounded-heap exact query parity.Verification
meson test -C build-round2— 12/12 passedSQLITE_VEC_X86_RUNTIME_DISPATCH):xcrun clang++ -std=c++20 -arch x86_64 -fsyntax-only— PASS-mavx -mavx2 -mfma):xcrun clang++ -std=c++20 -arch x86_64 -mavx -mavx2 -mfma -fsyntax-only— PASS