[MOD-14957] Add tiered SQ8 mean training (3/3) - #1029
Open
dor-forer wants to merge 46 commits into
Open
Conversation
dor-forer
force-pushed
the
dor-forer-MOD-14957-tiered-hnsw-sq8
branch
from
September 2, 2026 10:15
72c1fc1 to
19cb099
Compare
* SQ8 for Tired HNSW Index * Fix after rebase Don't recreate tiered hnsw backend index Make isInAccumulationPhase atomic Add SQAccumulationState Tiered hnsw fixes * Add transition tests * clean up * Address review * defered backend index init * clean up * fix lock
dor-forer
force-pushed
the
dor-forer-MOD-14957-tiered-hnsw-sq8
branch
3 times, most recently
from
September 2, 2026 11:30
79d3e41 to
2e98a0e
Compare
dor-forer
force-pushed
the
dor-forer-MOD-14957-tiered-hnsw-sq8
branch
from
September 2, 2026 11:40
2e98a0e to
173b6a0
Compare
dor-forer
marked this pull request as ready for review
September 6, 2026 11:44
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dor-forer-MOD-14957-tiered-sq8-backend #1029 +/- ##
==========================================================================
+ Coverage 97.41% 97.45% +0.04%
==========================================================================
Files 141 141
Lines 8716 8856 +140
==========================================================================
+ Hits 8491 8631 +140
Misses 225 225 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Sep 7, 2026
dor-forer
changed the base branch from
main
to
dor-forer-MOD-14957-tiered-sq8-backend
September 7, 2026 07:40
4 tasks
2 tasks
Tiered accumulation builds the SQ8 HNSW backend with a zero mean and installs the learned mean later through setQuantizationMean(). Until now that contract was exercised only through the tiered index. Cover it standalone: an index that received its mean through the setter must match an index constructed with the same mean in stored bytes, both distance modes, top-k ids and scores, and label distances, for FP32 and FP16 over L2 and IP. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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
Add mean training to tiered SQ8 while keeping the real HNSW backend present from construction. With a positive
QuantNormalizationSetSize, vectors remain searchable in FLAT until the threshold is reached. Tiered then installs the learned mean in the existing SQ8 components and starts migration.Stack 3/3, based on #1035 (
dor-forer-MOD-14957-tiered-sq8-backend): #1034 → #1035 → #1029. The first two PRs contain the FLAT overwrite fix and immediate-backend SQ8 support.A zero threshold skips training and preserves a supplied
quantParamsmean, if any. Positive thresholds override a supplied mean, take precedence overflatBufferLimit, and are capped at 102400 vectors. Emptying a trained graph does not restart training. SQ8getDataByLabel()returns no vectors in every phase, including when a label is buffered in FLAT.Initialization contract and known behavior
addVector()migrates the accumulated set before returning. This can perform up to 102400 insertions in one call.Which issues this PR fixes
MOD-14957: tiered SQ8 mean accumulation and initialization.
Validation
Validated
fb2c5b0426134c525c4af02c916112197b9c9477after merging base4c2f7509, ondorer-intelwith GCC 13.3, Debug, and SVS v0.3.2 enabled:test_hnsw: 158 focused tiered tests passed, including the SQ8 training cases intest_hnsw_tiered.cpp.test_hnsw_sq8: all 133 tests passed.test_svs: all 4 selectedgetDataByLabeltests passed; this binary includes standalone and tiered SVS retrieval tests.All three test targets built successfully with no compiler warnings.
All 463 tracked-file checksums matched the tested source snapshot. Repository-wide
make check-formatandgit diff --checkpassed.The conflict resolution preserves the updated base's SVS retrieval implementation; focused standalone and tiered SVS retrieval tests cover the shared header.
Historical full-suite validation at
fa472126: 3,050 Debug CTest cases passed with 8 expected SVS skips; withFP64_TESTS=ON, 3,316 passed with 9 expected skips. Those full suites, RediSearch integration, and ThreadSanitizer were not rerun at this head.Mark if applicable
Note
Medium Risk
Changes tiered HNSW write paths, locking around quantization finalization, and SQ8 distance/preprocess state; mistakes could affect search correctness or concurrency during the training transition.
Overview
Adds deferred SQ8 mean training for tiered HNSW via new
TieredHNSWParams.QuantNormalizationSetSize. When set > 0, inserts stay in the FLAT tier (searchable there) while a double-precision running sum tracks component means; HNSW migration jobs are held until the threshold is hit, even if that exceedsflatBufferLimit. At finalization, tiered callsHNSWIndex::setQuantizationMean()under the exclusive main lock to update the existing SQ8 WithNorm preprocessor and distance calculator in place, then submits or synchronously runs the batched insert jobs.Tiered factory now builds the SQ8 backend immediately with a placeholder zero mean when training is required;
0skips accumulation and keeps prior immediate-SQ8 behavior (optionalquantParamsmean). HNSW gainssetQuantizationMean,acquireSharedIndexDataGuard, and mutable mean hooks onQuantPreprocessor::setMean/DistanceCalculatorWithNorm::setMeanSumSquares, pluswith_meanoverloads for memory estimation.Supporting changes: RAII main/index data locks in tiered paths,
getPreprocessorsContainer()exposure, and broad unit coverage for accumulation, finalization, write modes, and concurrent query/migration edge cases.Reviewed by Cursor Bugbot for commit fb2c5b0. Bugbot is set up for automated code reviews on this repo. Configure here.