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:

  1. IVF partitioning: IVF groups vectors into nlist clusters and searches the nprobe closest clusters.
  2. RaBitQ encoding: Each vector residual is encoded as a one-bit-per-dimension RaBitQ code.
  3. FastScan: The index packs codes for cache-friendly, SIMD batch processing. It evaluates 32 database vectors in each batch.
  4. 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 to IVF_RABITQ_FASTSCAN.

  • metric_type: The method used to calculate the distance between vectors. Supported values include COSINE, L2, and IP. 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:

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

nlist

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
Range: [1, 65536]
Default value: 128

Larger nlist values improve recall by creating more refined clusters but increase index building time. Optimize based on dataset size and available resources. In most cases, we recommend you set a value within this range: [32, 4096].

RaBitQ

refine

Enables the refine process and stores the refined data. IVF_RABITQ_FASTSCAN supports FP32 refinement only.

Type: Boolean
Range: [true, false]
Default value: false

Set to true if a 0.9+ recall rate is needed. Enabling refinement improves accuracy but increases storage requirements and index building time.

refine_type

Defines the data representation used for refining when refine is enabled. Required only when refine is true.

Type: String
Range: [FP32, FLAT]
Default value: None

IVF_RABITQ_FASTSCAN supports FP32 refinement only, and FLAT is identical to FP32. Value matching is case-insensitive.

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

nprobe

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
Range: [1, nlist]
Default value: 8

Increasing this value improves recall but may slow down the search. Set nprobe proportionally to nlist to balance speed and accuracy. In most cases, we recommend you set a value within this range: [1, nlist].

RaBitQ

refine_k

The refining process uses higher quality quantization to pick the needed number of nearest neighbors from a refine_k times larger pool of candidates chosen using IVF_RABITQ_FASTSCAN. Has no effect if refinement is disabled.

Type: Float
Range: [1, float_max)
Default value: 1

Higher refine_k values decrease QPS but increase recall rate. Start with 1 and test values 2, 3, 4, and 5 to find the optimal trade-off between QPS and recall for your dataset.

rbq_bits_query

Sets whether additional scalar quantization of a query vector is applied. Not supported on IVF_RABITQ_FASTSCAN: the index always uses 8-bit query quantization internally. Omit this parameter or set it to 0; values greater than 0 are rejected.

Type: Integer
Range: [0, 0]
Default value: 0

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_query must be omitted or set to 0.
  • 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.

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?