Product quantization
Compress cached vectors up to 32× with asymmetric distance.
S3 Vectors stores float32 and manages its own layout, so PQ does not change what it stores. PQ compresses
the vectors dynavec caches — the in-memory hot tier and local candidate caches — turning a
dim × 4 byte vector into m bytes.
from dynavec import ProductQuantizer
pq = ProductQuantizer(m=96, nbits=8).fit(training_vectors) # 768-d -> 96 bytes (32x)
codes = pq.encode(vectors) # uint8 codes
dists = pq.asymmetric_distances(query, codes) # ADC, fast at scale
print(pq.reconstruction_error(vectors))
| Param | Meaning |
|---|---|
m | Number of subspaces; must divide the vector dimension. |
nbits | Bits per subquantizer (8 → 256 centroids, uint8 codes). |