XVector
xvec_ivf_rabitq.h File Reference

IVF-RaBitQ (Inverted File with Random Bit Quantization) index interface. More...

#include "xvec_types.h"
Include dependency graph for xvec_ivf_rabitq.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xvecIvfRaBitQDescriptor
 FAISS-free description of an IVF-RaBitQ index. More...
 

Typedefs

typedef struct xvecIvfRaBitQSearchTiming xvecIvfRaBitQSearchTiming
 
typedef struct xvecIvfRaBitQDescriptor xvecIvfRaBitQDescriptor
 FAISS-free description of an IVF-RaBitQ index. More...
 

Functions

xvecStatus xvecIvfRaBitQLoadIndexFromFaissFile (xvecExecutionContextTag *context, const char *indexFilePath, xvecIvfRaBitQIndexTag **outIndexHandle)
 Loads an IVF-RaBitQ index from a Faiss index file. More...
 
xvecStatus xvecIvfRaBitQLoadIndexFromDescriptor (xvecExecutionContextTag *context, const xvecIvfRaBitQDescriptor *descriptor, xvecIvfRaBitQIndexTag **outIndexHandle)
 Loads an IVF-RaBitQ index from a FAISS-free descriptor. More...
 
xvecStatus xvecIvfRaBitQDestroyIndex (xvecExecutionContextTag *context, xvecIvfRaBitQIndexTag *indexHandle)
 Destroys an IVF-RaBitQ index handle and releases its host-side data. More...
 
xvecStatus xvecIvfRaBitQPrepareKernel (xvecExecutionContextTag *context)
 Pre-initializes PXL resources (Job, Module, Function) for IVF-RaBitQ search. More...
 
xvecStatus xvecIvfRaBitQSearchFineSearchOnly (xvecExecutionContextTag *context, xvecIvfRaBitQIndexTag *indexHandle, xvecIvfRaBitQFineSearchQueryFloat32 *fineSearchQuery, xvecBufferTag *resultsBufferHandle, xvecIvfRaBitQSearchTiming *outTiming)
 Performs an IVF-RaBitQ fine search only (skips coarse search). More...
 

Detailed Description

IVF-RaBitQ (Inverted File with Random Bit Quantization) index interface.

This header provides the API for loading and searching IVF-RaBitQ indices. IVF-RaBitQ uses binary quantization for ultra-compact vector representation, enabling very fast approximate nearest neighbor search with low memory footprint.

Definition in file xvec_ivf_rabitq.h.

Typedef Documentation

◆ xvecIvfRaBitQDescriptor

FAISS-free description of an IVF-RaBitQ index.

Fully describes an IVF-RaBitQ index using plain C arrays, with no dependency on FAISS types or ABI. Per-vector data (binary codes, factors, ids) is grouped by cluster: the first listSizes[0] vectors belong to cluster 0, the next listSizes[1] to cluster 1, and so on.

The binary codes and the distance factors are supplied as separate arrays (rather than the FAISS-packed code blob) so the layout carries no dependency on FAISS's internal factor representation.

A multi-bit index (nbBits > 1) additionally supplies exCodes and exFactors. These fields are appended at the end of the struct, so a caller that zero-initializes the descriptor and leaves them unset describes a 1-bit index exactly as before.

All pointers are borrowed for the duration of the load call only; the caller retains ownership and may free them once the call returns.

◆ xvecIvfRaBitQSearchTiming

Definition at line 1 of file xvec_ivf_rabitq.h.

Function Documentation

◆ xvecIvfRaBitQDestroyIndex()

xvecStatus xvecIvfRaBitQDestroyIndex ( xvecExecutionContextTag *  context,
xvecIvfRaBitQIndexTag *  indexHandle 
)

Destroys an IVF-RaBitQ index handle and releases its host-side data.

Note
Current limitation: device buffers allocated for the index remain owned by the execution context and are released by xvecDestroyContext(). Destroying the index does not yet reclaim its device memory.
See also
Index resource lifetime for destruction order and C++ wrapper behavior.
Parameters
[in]contextExecution context for device operations
[in]indexHandleHandle to the index to destroy
Returns
XVEC_SUCCESS on success, error code otherwise

◆ xvecIvfRaBitQLoadIndexFromDescriptor()

xvecStatus xvecIvfRaBitQLoadIndexFromDescriptor ( xvecExecutionContextTag *  context,
const xvecIvfRaBitQDescriptor *  descriptor,
xvecIvfRaBitQIndexTag **  outIndexHandle 
)

Loads an IVF-RaBitQ index from a FAISS-free descriptor.

Builds an IVF-RaBitQ index directly from caller-supplied arrays, with no FAISS dependency. This is the recommended way to construct an index from a custom or pre-extracted source. See xvecIvfRaBitQDescriptor for the required memory layout.

Note
An index loaded this way performs its IVF coarse search natively over the supplied centroids (no FAISS quantizer is consulted).
Parameters
[in]contextExecution context for device operations
[in]descriptorFully-populated index descriptor (borrowed for the call)
[out]outIndexHandlePointer to receive the handle to the loaded index. The caller is responsible for destroying this index using xvecIvfRaBitQDestroyIndex.
Returns
XVEC_SUCCESS on success, XVEC_ERROR_INVALID_PARAMETER for null/zero inputs and for an nbBits above the maximum of 9, XVEC_ERROR_INVALID_HEADER if the layout is inconsistent (e.g. listSizes do not sum to numVectors, binaryCodeSize != (dimension + 7) / 8, or an exCodeSize that does not match nbBits), XVEC_ERROR_OUT_OF_MEMORY_PXL when device memory for the index cannot be allocated, or other error code otherwise

◆ xvecIvfRaBitQLoadIndexFromFaissFile()

xvecStatus xvecIvfRaBitQLoadIndexFromFaissFile ( xvecExecutionContextTag *  context,
const char *  indexFilePath,
xvecIvfRaBitQIndexTag **  outIndexHandle 
)

Loads an IVF-RaBitQ index from a Faiss index file.

Loads an IndexIVFRaBitQ from a Faiss .faiss file, extracting binary codes, RaBitQ factors, coarse centroids, and inverted list structure.

Parameters
[in]contextExecution context for device operations
[in]indexFilePathPath to the Faiss .faiss index file
[out]outIndexHandlePointer to receive the handle to the loaded index. The caller is responsible for destroying this index using xvecIvfRaBitQDestroyIndex.
Returns
XVEC_SUCCESS on success, XVEC_ERROR_OUT_OF_MEMORY_PXL when the device memory for the index cannot be allocated (for example while another process holds most of the card's memory), or other error code otherwise

◆ xvecIvfRaBitQPrepareKernel()

xvecStatus xvecIvfRaBitQPrepareKernel ( xvecExecutionContextTag *  context)

Pre-initializes PXL resources (Job, Module, Function) for IVF-RaBitQ search.

Eagerly creates and caches the PXL Job and Function objects so that the first search call does not pay the lazy-initialization cost. Uses the same Sub count a search would: the "numSub" property if set, else whatever the device reports. Fails with XVEC_ERROR_DEVICE_NOT_SUPPORTED on a device that has no search path, rather than reserving Subs for a search that would then be refused. Fails with XVEC_ERROR_PXL_JOB_CREATE_FAILED when the device has fewer free Subs than the Job needs, because another process or context holds them. Safe to call more than once; subsequent calls are no-ops if numSub has not changed.

Parameters
[in]contextExecution context. Setting "numSub" is optional.
Returns
XVEC_SUCCESS on success, error code otherwise

◆ xvecIvfRaBitQSearchFineSearchOnly()

xvecStatus xvecIvfRaBitQSearchFineSearchOnly ( xvecExecutionContextTag *  context,
xvecIvfRaBitQIndexTag *  indexHandle,
xvecIvfRaBitQFineSearchQueryFloat32 *  fineSearchQuery,
xvecBufferTag *  resultsBufferHandle,
xvecIvfRaBitQSearchTiming *  outTiming 
)

Performs an IVF-RaBitQ fine search only (skips coarse search).

This function performs only the fine search phase using pre-computed nearest cluster IDs. Use this when the coarse search has already been performed externally (e.g., by FAISS) and only the fine search needs to be offloaded to XVector.

The typical use case is XFaiss integration where:

  1. FAISS performs coarse search on CPU to find nearest clusters
  2. XVector performs fine search on accelerator using the cluster IDs from step 1
Parameters
[in]contextExecution context for device operations
[in]indexHandleHandle to the IVF-RaBitQ index containing binary codes and factors
[in]fineSearchQueryFine search query containing query vectors and pre-computed nearest cluster IDs (from external coarse search)
[out]resultsBufferHandleBuffer to receive search results. Must be pre-allocated with size: queryVectorCount * topK * sizeof(xvecIvfRaBitQSearchResultFloat32)
[out]outTimingPointer to receive timing information (can be NULL)
Returns
XVEC_SUCCESS on success, XVEC_ERROR_OUT_OF_MEMORY_PXL when the per-search device buffers cannot be allocated (the search is not started), or other error code otherwise