IVF_RABITQ_FASTSCANCompatible with Milvus 3.0.x
IVF_RABITQ_FASTSCAN combines IVF partitioning, RaBitQ binary quantization, and FastScan batch processing. It stores one-bit RaBitQ codes for database vectors and processes the codes in SIMD-friendly blocks of 32 database vectors. This makes it a good choice for high-throughput, memory-constrained workloads that can accept approximate results.
Choose IVF_RABITQ_FASTSCAN over IVF_RABITQ when searches scan many candidates and throughput is the primary goal. FastScan’s per-query setup cost is amortized across packed code blocks, so it is typically more beneficial for large datasets or long IVF lists. For small collections or searches that inspect few candidates, use IVF_RABITQ instead. It also supports configurable query quantization, more refinement types, and iterators.
How it works
IVF_RABITQ_FASTSCAN uses the following stages:
- IVF partitioning: IVF groups vectors into
nlistclusters and searches thenprobeclosest clusters. - RaBitQ encoding: Each vector residual is encoded as a one-bit-per-dimension RaBitQ code.
- FastScan: The index packs codes for cache-friendly, SIMD batch processing. It evaluates 32 database vectors in each batch.
- Optional refinement: When enabled, an FP32 refiner re-scores candidates before Milvus returns the final results.
The underlying Faiss index is IndexIVFRaBitQFastScan. Knowhere wraps it with a random rotation transform and optionally adds an FP32 refiner.
FastScan performs per-query setup work, such as building and quantizing query-related lookup tables, before scanning packed code blocks. Benchmark both IVF_RABITQ and IVF_RABITQ_FASTSCAN with your data and search parameters.
Build index
To build an IVF_RABITQ_FASTSCAN index on a vector field in Milvus, use the add_index() method, specifying the index_type, metric_type, and additional parameters for the index.
from pymilvus import MilvusClient
# Prepare index building params
index_params = MilvusClient.prepare_index_params()
index_params.add_index(
field_name="your_vector_field_name", # Name of the vector field to be indexed
index_type="IVF_RABITQ_FASTSCAN", # Type of the index to create
index_name="vector_index", # Name of the index to create
metric_type="L2", # Metric type used to measure similarity
params={
"nlist": 1024, # Number of clusters for the index
"refine": True, # Enable refinement for higher recall
"refine_type": "FP32" # Refinement data format
} # Index building params
)
In this configuration:
index_type: The type of index to be built. In this example, set the value toIVF_RABITQ_FASTSCAN.metric_type: The method used to calculate the distance between vectors. Supported values includeCOSINE,L2, andIP. For details, refer to Metric Types.params: Additional configuration options for building the index. For details, refer to Index building params.
Once the index parameters are configured, you can create the index by using the create_index() method directly or passing the index params in the create_collection method. For details, refer to Create Collection.
Search on index
Once the index is built and entities are inserted, you can perform similarity searches on the index.
Set nprobe to control how many IVF clusters are searched. If the index was built with refinement, use refine_k to control the candidate pool passed to the FP32 refiner.
client = MilvusClient(uri="http://localhost:19530") # Replace with your Milvus server address
search_params = {
"params": {
"nprobe": 128, # Number of clusters to search
"refine_k": 2 # Refinement magnification factor
}
}
res = client.search(
collection_name="your_collection_name", # Collection name
anns_field="your_vector_field_name", # Vector field name
data=[[0.1, 0.2, 0.3, 0.4, 0.5]], # Query vector
limit=3, # TopK results to return
search_params=search_params
)
In this configuration:
params: Additional configuration options for searching on the index. For details, refer to Index-specific search params.
Unlike IVF_RABITQ, IVF_RABITQ_FASTSCAN does not accept the rbq_bits_query search parameter. FastScan always uses 8-bit query quantization internally, so omit rbq_bits_query or set it to 0; larger values are rejected.
Index params
This section provides an overview of the parameters used for building an index and performing searches on the index.
Index building params
The following table lists the parameters that can be configured in params when building an index.
Parameter |
Description |
Value Range |
Tuning Suggestion |
|
|---|---|---|---|---|
IVF |
|
The number of clusters to create using the k-means algorithm during index building. Each cluster, represented by a centroid, stores a list of vectors. Increasing this parameter reduces the number of vectors in each cluster, creating smaller, more focused partitions. |
Type: Integer |
Larger |
RaBitQ |
|
Enables the refine process and stores the refined data. |
Type: Boolean |
Set to |
|
Defines the data representation used for refining when |
Type: String |
|
Index-specific search params
The following table lists the parameters that can be configured in search_params.params when searching on the index.
Parameter |
Description |
Value Range |
Tuning Suggestion |
|
|---|---|---|---|---|
IVF |
|
The number of clusters to search for candidates. Higher values allow more clusters to be searched, improving recall by expanding the search scope but at the cost of increased query latency. |
Type: Integer |
Increasing this value improves recall but may slow down the search. Set |
RaBitQ |
|
The refining process uses higher quality quantization to pick the needed number of nearest neighbors from a |
Type: Float |
Higher |
|
Sets whether additional scalar quantization of a query vector is applied. Not supported on |
Type: Integer |
Leave it unset. For configurable query quantization, use IVF_RABITQ instead. |
Limitations
- FastScan uses a fixed 1-bit RaBitQ database encoding and 8-bit query quantization.
rbq_bits_querymust be omitted or set to0. - Only FP32 (equivalently
FLAT) refinement is supported. - Iterators are not supported.
- This is a CPU index. It does not run on GPU.
- Actual performance depends on CPU SIMD support, vector dimension,
nlist,nprobe, and data distribution. Benchmark it with your workload before deploying it to production.
For the non-FastScan RaBitQ variant and its additional refinement options, see IVF_RABITQ.