Repository navigation
Conversation
1 of 2 tasks
Add TurboQuant 2-bit and 3-bit MSE quantization for FP32 inner-product and normalized cosine HNSW indexes, standalone and tiered. - VecSimQuant_TQ2/TQ3 and an optional VecSimTurboQuantParams (mean, seed; default seed 42 and a zero mean). - A dense-rotation codec with projection-match scaling and a mean-error correction. Encoding and scoring never throw; only construction and loading validate. - TurboQuantPreprocessor and TurboQuantCalculator share one codec; the calculator returns a stateful dispatch bound to it. - Tiered training reuses SQ8TrainingState and installs the trained mean through HNSWIndex::setQuantizationMean. - Serialization V5 writes the fitted state (including the full rotation) after quantType. SQ8 and SQ4 bytes are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dor-forer
force-pushed
the
codex/tq23-rabitq-draft
branch
from
November 15, 2026 12:57
204ac18 to
bc5ed80
Compare
3 of 4 tasks
Collaborator
Author
|
Moved to RediSearch/RediSearch#12352, since VecSim now lives in RediSearch under |
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.
Describe the changes in the pull request
This adds TQ2 and TQ3 (TurboQuant, 2-bit and 3-bit codes) as HNSW quantization types, using the hooks SQ8 and SQ4 already use. There is no new framework and no change to existing APIs, SQ8/SQ4 behavior or serialized bytes.
quantization/turboquant.hholds an MSE TurboQuant estimator for FP32 inner product, with a projection-match scale and a mean-error correction. Records are the packed codes plus 8 bytes. Queries hold the rotated query and its dot product with the mean. The rotation is a seeded dense random orthogonal matrix (seed 42 by default). TQ2/TQ3: Replace the dense rotation with a block Hadamard rotation #1124 replaces it with a block Hadamard rotation.quantization/turboquant_components.hadds a TQ preprocessor and a TQ calculator that share one codec. The calculator uses the existing stateful distance dispatch.HNSWIndex::setQuantizationMeanpasses the mean to the TQ codec when the index is TQ, otherwise to SQ8 as before.quantTypeis followed by the TQ fitted state (rotation, centroids and mean terms) instead of the SQ8 mean.Public API:
VecSimQuant_TQ2 = 3,VecSimQuant_TQ3 = 4, andVecSimTurboQuantParams {mean, seed}passed throughHNSWParams.quantParams.Compared with the previous version of this PR, this drops the storage-context layer (
getQuantizationRuntime,storage_context.h,quantization_runtime.h), the V6 format, new exceptions on add/update/query, new info fields, the submit-path changes, the SVE2 kernel, the research docs and the benchmark harness. It goes from 5,002 to 1,445 added lines.Validation (dorer-intel Xeon 8375C, and dorer-arm-big Neoverse V2, Release)
test_hnsw_turboquant16/16,test_hnsw_sq8209/209,test_hnsw_sq4all pass,test_components59/59,test_allocator7/7, andtest_hnswpasses on both machines.test_commoncrashes atUint8CosineSelfDistanceAtLargeDimensionon main as well, so it is unrelated to this PR.test_hnsw_sq4used the raw value 3 as an "unknown quantizer". It now uses 5.Benchmark (this commit, DBpedia 768-dim, cosine through normalized IP; 100,000 base rows and 500 held-out queries; fixture checksum verified; one pinned core, Release)
Not done here
Which issues this PR fixes
Main objects this PR modified
src/VecSim/quantization/turboquant*.handsrc/VecSim/types/turboquant.h.hnsw_factory.cpp,tiered_factory.cpp,hnsw.h(setQuantizationMean) andhnsw_serializer_impl.h.tests/unit/test_hnsw_turboquant.cpp.Mark if applicable
🤖 Generated with Claude Code