Skip to main content

Module qgraph

Module qgraph 

Source
Expand description

Quantized graph index for approximate nearest-neighbour search on angular data, and (the Graph and VGraph only, see Metric) on Euclidean data.

Vectors are normalized and rotated (random sign flips and fast Walsh-Hadamard transforms), and a Vamana-style graph with alpha pruning and a fixed out-degree is built on exact inner products, inserting in deterministic batches. Each vertex owns one contiguous block holding its rotated vector, its neighbours’ ids, and for every edge a 1-bit RaBitQ code of the edge residual (neighbour minus vertex) with per-edge correction factors.

Search keeps a pool of ef candidates ordered by estimated distance. Expanding a vertex scores it exactly (this is the re-rank) and estimates all of its neighbours in one batch from the edge codes against a 4-bit query code. The result is the top-k of the exactly scored vertices. max_exact caps the number of expansions (0 = no cap).

Estimator (RaBitQ, Gao & Long 2024, applied per edge as in SymphonyQG, Gou et al. 2025): with w = u - v and s = sign(w), <q, u> ~= <q, v> + <v, w> + M (<s, q> - <s, v>) where M = |w|^2 / |w|_1. <q, v> is exact at expansion time; <s, q> comes from the bit planes.

VGraph is the compact alternative on the same Graph: one 8-bit code per vertex instead of one 1-bit code per edge (see vertex.rs).

Structs§

BuildParams
ConsolidationPolicy
Advisory thresholds; callers schedule consolidation outside their commit latency.
Graph
A built proximity graph, before any encoding: over normalized vectors (angular) or the vectors as given (Euclidean). Holds a full-precision copy of the data, so it is a build-time object; the indexes keep only their encodings.
QGraph
SearchKnobs
Runtime knobs of the search loop, each off by default so that the results are those of the plain search. VGraph::searcher reads them once per process from the environment (SearchKnobs::from_env); VGraph::searcher_with takes them explicitly.
SearchParams
Searcher
Per-thread search state for one index.
UpdatableVGraph
A mapped base plus a mutable graph delta, with atomic durable batches. insert, delete, and replace publish immediately; commit makes the batch durable. Only one process may open a directory, while any number of threads may search it.
VGraph
VSearchParams
Search parameters of a VGraph.
VSearcher
Per-thread search state for one VGraph.

Enums§

Metric
Distance a graph is built and searched for.
Residency
Where the arrays of an index opened with VGraph::open live.
UpdateError
Failures at the update and persistence boundary.

Constants§

DEFAULT_DEGREE
Default out-degree of every vertex; one batch of edge codes per expansion.