How-toSelected

Milvus explains SQ, PQ and PRQ compression in HNSW indexes

Why we picked it

Quantization does not just shrink memory; it changes which vectors get connected during graph build and how candidates are ranked at query time, so accuracy trade-offs are not obvious from bit-widths alone. Teams sizing Milvus deployments should set a recall target first, then compare loaded memory, throughput and build time including refinement costs. PRQ buys back accuracy that PQ loses, at the price of extra compute and storage.

Milvus details how its three quantized HNSW variants compress vectors to cut memory use.

Body

SQ encodes each dimension separately, with SQ8 and SQ6 using 8 and 6 bits per dimension and SQ4U using 4-bit unsigned values with one shared uniform range.

PQ splits vectors into subvectors, each represented by a codebook index, while PRQ starts from PQ and encodes residual error in stages at higher training, build and distance-calculation cost.

All three variants share the same HNSW framework, though quantization can change graph connectivity during construction and candidate ranking during retrieval, and optional higher-precision refinement can rerank candidates to improve recall.

Original · Milvus

SQ, PQ, or PRQ: how do they compress vectors in Milvus HNSW? HNSW can deliver high recall, but its full precision vectors and layered graph consume substantial memory. Milvus offers HNSW_SQ, HNSW_PQ, and HNSW_PRQ to compress the vectors used in graph construction and distance calculations. Each method encodes vectors differently: • SQ quantizes each dimension. SQ8 and SQ6 use 8 and 6 bits per dimension, with independently estimated ranges. SQ4U uses 4-bit unsigned values and one shared uniform range. • PQ splits the vector into subvectors. Each subvector is represented by a codebook index. • PRQ starts with PQ, then encodes residual error in stages. It retains additional information beyond the initial approximation, with additional training, build, and distance calculation costs. All three quantized index variants use the same HNSW framework, but quantization can change which vectors are connected during construction and how candidates are ranked during retrieval. They can also use higher precision refinement to rerank candidates and potentially improve recall, while adding compute, storage, and memory costs. To compare SQ, PQ, and PRQ, set a recall target first, then measure memory after loading, throughput, and build time—including the cost of any refinement needed to reach that target.

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk, focusing on China's AI industry and domestic foundation model ecosystem. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Milvus, HNSW, vector search, quantization.

Source attribution: curated from Milvus (@milvusio).