Repository navigation
Make HadamardRotation depth configurable (1-3 rounds) - #5760
Draft
ranbenbasat wants to merge 7 commits into
Draft
ranbenbasat wants to merge 7 commits into
ranbenbasat wants to merge 7 commits into
Conversation
This branch has not been deployed
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.
Faiss's
HadamardRotationcurrently applies three sign-flip/FWHT roundsunconditionally. This change makes the depth selectable so users can measure
and tune the preprocessing-cost/quantization-quality tradeoff with one, two,
or three rounds. The default remains three rounds.
Existing
HRandHR42factory strings keep their current three-roundbehavior;
42remains the seed. NewHRr1,HRr2,HRr3, andHR42r2tokens explicitly select the count. Dense rotation and no preprocessing remain
available through the existing interfaces.
Implementation
with the matching inverse and count validation.
give nested sign prefixes for paired comparisons.
HRotserialization byte-for-byte compatible. Use adistinct counted format,
HRnd, for one/two rounds and validate it beforeallocation. Existing files read as three rounds.
legacy-compatibility, factory, IO, malformed-input, and search tests.
Motivation and reproducible evaluation
Quantizing With Randomized Hadamard Transforms: Efficient Heuristic Now
Proven distinguishes scalar marginal behavior
after two RHTs from fixed-block vector behavior after three. This motivates
measuring depth as an explicit choice; it is not a theorem about ANN recall.
benchs/bench_rht.pyand its reproduction guide compare RaBitQ and EDEN at2/3/4 stored bits under none, shared Haar URR, and 1/2/3 RHTs. They report:
its sign-only decoder.
and raw per-query recalls.
initialization, training, and encoding/add timings.
controls, and effective BLAS/OpenMP thread limits.
provenance, with a host guard for designated measurement machines.
The current runner covers flat compressed scans. IVF/FastScan measurements
and matched-recall QPS curves are follow-up evidence; flat results will not be
presented as validation of those structures. No adaptive routing is included.
Initial Amumu pilot
An optimized Arrow Lake/AVX2 build on Amumu completed a 150-case MSong flat-scan pilot: 4,096 training vectors, 20,000 base vectors, 200 queries, all five preprocessing modes, both quantizers, 2/3/4 bits, and five paired transform seeds. The table gives set Recall@100 and percentage-point deltas relative to 1RHT, with paired seed/query bootstrap 95% intervals.
Both added depths improve 2-bit RaBitQ recall in this subset. EDEN intervals include zero; higher-bit RaBitQ outcomes are mixed. Pooled NMSE and vNMSE, computed on the first 10,000 searched vectors, were higher with 2/3RHT than 1RHT for both quantizers at every tested budget. All three RHT depths use the same 512-coordinate output; native-size none/URR retain 420 coordinates and have a separate matched-padding control queued.
This pilot is not a replication of the paper's MSong figure. The archived experiment uses a 448-dimensional block-FHT/Kac construction, fixed Gaussian-calibrated code thresholds, 128 residual centers, full-precision queries and the full database. This contribution uses full 512-dimensional RHTs and native per-vector code scaling; its flat pilot uses one center and the RaBitQ query-bit setting of 4. The paper's best-scalar residual vNMSE also differs from the actual-score reconstruction diagnostic above.
A bounded quality audit on Amumu completed 216 transform/centering/quantizer cases and 90 native query-bit cases. With the same pilot data, 128 frozen centroids and historical thresholds, the block/Kac construction retained large depth gains, while full-512 started with higher one-round mean recall and gained little. This comparison changes transform construction and code dimension together (512 versus 448), so it does not isolate the Kac layer or establish an equal-storage advantage. It uses two NumPy transform seeds and is not a full historical replication. Changing qb=4 to qb=0 on identical native codes changed mean recall by at most 0.002 percentage points; all 45 qb=4 replays exactly matched the original pilot's per-query recalls. Query precision is therefore not a material explanation in this pilot.
This prefix subset has disjoint training/base source-row ranges but 21 exact-value overlaps. Results condition on its fixed data and five seeds. Speed remains provisional: 14/95 workload samples exceeded the declared desktop-activity threshold. No speedup is claimed from this pilot.
Full five-way results, metric definitions, uncertainty and provenance and the hash-verified raw evidence capsule are on the separate evidence branch. Native-dimension IVF/RaBitQ, IVF/EDEN and IVF/RaBitQFastScan nprobe sweeps have completed; matched-padding sweeps are running on Amumu. Their interpretation, broader datasets, randomized splits and quieter runtime replication remain in progress.
Validation
passed. One existing PCA overflow warning remains.
benchmark checks), including one-bit reconstruction/score validation.
all 13 helper tests pass in each staged layout.
full-code NMSE, Haar construction, and benchmark threading.
Draft status
The code, tests, benchmark tooling and qualified first pilot are ready for
early maintainer feedback. Amumu experiments are in progress, including
ANN, matched-padding, additional datasets and clean runtime replication.
The contribution remains a draft while that evidence is collected and reviewed.
Neutral and negative cases are retained. Historical rebuttal figures used a
different transform for some dimensions and are not treated as validation
of this implementation.