Big graphs, small vectors: HNSW at a billion

A Hornet engineering post (19 November 2026) on why Hornet keeps HNSW graphs as large as one machine’s memory allows instead of sharding, and how it makes a billion vectors fit: quantize them to 2 bits for the graph search, keep full-precision vectors on local NVMe, and rescore. It is the first of two posts; the recall measurements are promised for the second.

Source: https://hornet.dev/blog/big-graphs-small-vectors-hnsw-at-a-billion


The requirements

Hornet wanted embedding retrieval over billions of vectors with: true real time (a write is visible to every query that follows), high query rate with low, predictable latency, balanced use of memory, CPU and disk, and good recall. Brute-Force Vector Search is exact but does not scale — at 1B vectors of 1,024 dimensions in bfloat16, each query would read about 2 TB and compute 1B distances.

Why HNSW

  • Cost per query ≈ top-K × max-links distance computations, on average (not a bound). Hornet’s names: max-links is M in the HNSW paper and R in DiskANN; top-K is ef / efSearch / DiskANN’s search list size L.
  • Measured on Hornet’s data (1B vectors, 2-bit, 32 max-links): a top-K of about a thousand costs about 25,000 distance computations.
  • Stable and incremental. Each vector’s top layer is drawn at random, so the structure does not depend on insertion order; an insert is a graph search plus link updates, with no training step. DiskANN and IVF variants, as first described, need knowledge of the data up front; of those briefly tested, “most failed the real-time requirement”.

Where HNSW is bad

Memory is “the Achilles heel”: graph and searched vectors must stay in RAM, because each step waits on the previous one and random disk reads at ~25,000 per query would be too costly at thousands of queries per second. On AWS x8g (16 GB per core), a 1 TB machine holding 2B+ 2-bit vectors gives 64 cores — far more CPU than graph search needs, so the spare CPU has to be useful (rescoring, lexical search) or HNSW is the wrong choice. Two workloads are better served otherwise: few queries (IVF on cheaper storage, even object storage) and naturally partitioned, multi-tenant data (brute force or a small IVF per tenant).

Why not shard

In an inverted index, twice the documents means roughly twice the posting-list work. In a graph at fixed top-K, finding the top hundred barely costs more as the graph grows — if recall holds. Sharding breaks that: every query searches every shard, and every graph pays the base cost of a search. The same applies to an index built as many merged segments.

Setup (32 max-links, 1,000 queries, recall@100 ≈ 65% before rescoring)Distance computations per query
One graph, 1B 2-bit vectors, top-K 1,024~25,000
Ten graphs of ~100M, top-K ~600 each~150,000 (≈6×)

“Once you shard, latency stays put and efficiency drops” — the reverse of sharding a text index. The post is explicitly about efficiency, not latency.

Making it fit: quantize the vector, not the graph

Memory per vector at 1,024 dimensions and 32 max-links (graph ≈150 bytes; ≈110 at 24 max-links, ≈240 at 64, data-dependent):

VectorsPer vectorPer billion
bfloat16~2.2 KB~2.2 TB
4-bit~660 B~660 GB
2-bit~400 B~400 GB

Quantization uses TurboQuant: a random rotation (the idea shown by RaBitQ) followed by per-coordinate quantization with levels fixed in advance, so each vector is encoded on arrival with no training — “RaBitQ made it possible, and TurboQuant made real time simple.”

Rescoring from NVMe

2-bit distances are rough, so search runs in two steps (Full-Precision Rescoring): graph search on quantized vectors in memory, then each top-K candidate rescored against its full vector read from local NVMe. At top-K ≈1,000 that is ~25,000 in-memory computations plus ~1,000 disk reads. The full vectors can live on disk because rescoring reads them together, once candidates are known — small random reads SSDs handle well. On Hornet’s data, 2-bit vectors needed rescoring to reach 95% recall. Rescoring only reorders candidates the graph found; it cannot recover a true neighbor the search missed.

Global merge across machines (an illustration, not a measurement): with ten machines, each sends its best 1,000 from a 2-bit search; a merge keeps e.g. 2,000 of the 10,000 and sends only those back for rescoring — about 200 per machine instead of 1,000. How many the merge keeps is another quality/cost lever.

The open question

Whether recall holds as one graph grows from 100M to 1B. The ParlayANN paper (PPoPP 2024) reported that a search with the same settings is less accurate on a larger graph; Hornet’s bet is that this depends more on the data than the algorithm, and that good embeddings form “many small, separate villages”. Early tests with Qwen3-Embedding-0.6B from 1M to 100M showed recall deteriorating faster than hoped; more bits and rescoring regained it. The follow-up post is to report the recall ceiling for 2-bit and 4-bit, how much rescoring regains, and how much top-K must grow from 100M to 1B — if linearly, HNSW loses its advantage.

Counterpoint

Published the same day, Text, Filters, and Now Vectors in One Postgres Index argues the opposite design choice: ParadeDB picked a cluster-based index because HNSW hops become random disk reads once the index outgrows memory, and says it is “skeptical of any HNSW-based vector index’s ability to scale”. Hornet’s answer is to never let the graph leave memory.

Topics