Asymmetric Distance Computation (ADC): for each query, precompute a pq_m x 256 table of query to centroid distances.
Imagine you have a million items in a warehouse, each described by 32 'category tags'. A new query arrives and you want to find the closest items. The slow way is to fully expand every tag back into its full description and compare. The clever way: first, for each query, compute once how 'close' the query is to each of the 256 possible values of each tag. Now you have a small cheat-sheet. To score any warehouse item, just look up its 32 tags in the cheat-sheet and add up the 32 numbers. No real math per item, just lookups and adds. That is **asymmetric distance computation**.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
This question separates candidates who memorized 'PQ is fast' from candidates who understand why. The mechanism is asymmetric distance computation: precompute a query to codebook distance table once, then reduce every database-vector distance to a handful of cache-friendly lookups plus adds. That is the actual unlock for billion-scale ANN on CPU.
The arithmetic reduction
Full float distance against one 1024-dim vector: 1024 multiplies + 1024 adds = ~2048 float ops. ADC reduces this to pq_m = 32 lookups + 32 adds per database vector. That is roughly 30-60x fewer operations per vector. Combined with the smaller memory footprint (32 bytes vs 4096 bytes per vector), the effective scan throughput jumps by two orders of magnitude.
The per query setup amortizes over the entire scan. For a typical IVF-PQ deployment scanning a few percent of a billion-vector corpus, the setup cost is sub-millisecond and the scan cost dominates.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| Approach | Per query setup | Per DB vector cost | Recall |
|---|---|---|---|
| Full float distance | 0 | O(d) multiplies + adds | Exact |
| Decode then compare PQ | 0 | O(d) multiplies + adds (after decode) | Approx (quantization) |
| SDC (symmetric) | 0 (table precomputed at index time) | pq_m lookups + adds | Approx (both sides quantized) |
| ADC (asymmetric) | pq_m * 256 distance ops | pq_m lookups + adds | Approx (only DB quantized; best of the three approx options) |
Real products, models, and research that use this idea.
- Faiss IndexIVFPQ uses ADC by default; the fast path is hand-tuned SIMD that hits sub-10 ns per database vector.
- Faiss PQ4 fast scan packs pq_m=64 nbits=4 codes for AVX-512, hitting >2 billion distance computations per second per core.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does ADC beat SDC on recall?
SDC quantizes both sides, introducing error on both. ADC keeps the query lossless. For the same code budget, ADC produces a more accurate distance estimate.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Assuming the speedup comes from compression alone. Smaller vectors do help with memory bandwidth, but the headline win is the table-lookup arithmetic: pq_m additions per vector instead of d float multiplies and adds.
60 second bullets to scan on the way to the call.
ADC = asymmetric distance computation
Query stays float; database stays in PQ codes
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.