pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feedFrom: mxfeinberg (@mxfeinberg) <noreply+mxfeinberg@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #989: Turboquant
Date: Thu, 02 Jul 2026 18:47:15 +0000
Message-ID: <gh-pgvector-pgvector-989-c4869448425@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-989@github.com>
References: <gh-pgvector-pgvector-989@github.com>
I just finished running a 100M vector test!
## Test data
- **Source:** [`Cohere/wikipedia-2023-11-embed-multilingual-v3`](https://huggingface.co/datasets/Cohere/wikipedia-2023-11-embed-multilingual-v3)
— Wikipedia passage embeddings, `float32`, **1024 dimensions**.
- **Base set:** **99,990,000** vectors, concatenated across five languages:
| Lang | Vectors |
|------|--------:|
| en | 41,488,110 |
| de | 20,772,081 |
| fr | 17,813,768 |
| ru | 13,734,543 |
| es | 6,191,498 |
- **Queries:** 10,000 vectors held out via reservoir sampling (seed 42), excluded
from the base set.
- **Metric:** cosine, top-**k = 10**. Mean L2 norm ≈ 1.0, so cosine and inner
product rank identically for these embeddings.
- **Ground truth:** exact brute-force cosine top-10 over all 99.99M base vectors
(chunked GEMM), so recall is measured against true nearest neighbors, not an
approximation.
## Hardware & software
- **Host:** dual-socket Intel Xeon (Sapphire Rapids-class, AVX-512 + AMX),
**96 physical cores / 192 threads**, 2 NUMA nodes, 180 MiB L3 (2 × 90 MiB).
- **Memory:** 881 GiB RAM.
- **Storage:** 3.6 TB RAID array (Linux md).
- **OS / DB:** Ubuntu 22.04, **PostgreSQL 18.4** built from source (gcc 11.4).
- **Key settings:** `shared_buffers = 96GB`; `dynamic_shared_memory_type = posix`
with `/dev/shm` raised to 750 GB so the float HNSW parallel build's DSM segment
(sized to `maintenance_work_mem`) fits in tmpfs.
## Index build configuration
All indexes built with **96 parallel maintenance workers** (hyperthreads past 96
add no memory bandwidth). Because 1024-dim vectors TOAST out-of-line and shrink
the main heap, the IVF build's worker heuristic was overridden with
`ALTER TABLE items SET (parallel_workers = 96)` so `tqivf` also got the full 96.
| Index | Parameters | `maintenance_work_mem` |
|-------|-----------|------------------------|
| `tqhnsw` | `m = 16`, `ef_construction = 200`, `fast_rotation = true` | 600 GB |
| `hnsw` | `m = 16`, `ef_construction = 200` | 600 GB |
| `tqivf` | `lists = 8192`, `fast_rotation = true` | 32 GB |
## Results
100M × 1024-dim, cosine, recall@10, 10,000 queries.
| Index | Query config | Index size | Build | Recall@10 | QPS | ms/query |
|-------|-------------|-----------:|------:|----------:|----:|---------:|
| `tqhnsw` | ef_search=100, rerank=200 | 76.3 GB | 10.7 h | 0.9332 | 37.1 | 27.0 |
| `tqhnsw` | ef_search=100, rerank=2000 | 76.3 GB | 10.7 h | 0.9332 | 92.6 | 10.8 |
| `tqhnsw` | ef_search=200, rerank=200 | 76.3 GB | 10.7 h | **0.9561** | 33.6 | 29.8 |
| `tqhnsw` | ef_search=200, rerank=2000 | 76.3 GB | 10.7 h | **0.9561** | 49.5 | 20.2 |
| `tqivf` | probes=128, rerank=200 | 49.7 GB | 7.0 h | **0.9689** | 1.44 | 692.9 |
| `hnsw` | ef_search=100 | 762.5 GB | 9.8 h | 0.9353 | 18.9 | 53.0 |
| `hnsw` | ef_search=200 | 762.5 GB | 9.8 h | 0.9567 | 17.9 | 55.8 |
## Interpreting the results
**`tqhnsw` vs float `hnsw` — apples to apples** (identical `m = 16`,
`ef_construction = 200`):
- At `ef_search = 200`: `tqhnsw` **0.9561** vs `hnsw` **0.9567** — statistically
identical recall, at **76.3 GB vs 762.5 GB (≈10.0×) smaller**.
- `tqhnsw` also answers in **20–30 ms vs ~56 ms** for `hnsw` — roughly **2× faster**
at equal recall.
- The `ef_search = 100` tier matches too (0.9332 vs 0.9353).
**`tqivf`** gives the highest recall (**0.9689**) in the smallest index
(**49.7 GB**, ~15× smaller than `hnsw`), but at **~0.69 s/query** it is ~25× slower.
IVF query cost grows with the base size at fixed recall, so **`tqivf` is a fit for
datasets up to ~10M rows; use `tqhnsw` at larger scale.**
view thread (9+ messages) latest in thread
Message-ID: <gh-pgvector-pgvector-989-c4869448425@github.com>
Permalink: ../gh-pgvector-pgvector-989-c4869448425@github.com/
·
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox