XVector
xvec_ivf_rabitq.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2026 XCENA Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
26 #pragma once
27 
28 #include "xvec_types.h"
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
35 
36  // =============================================================================
37  // Index Loading and Management
38  // =============================================================================
39 
56  xvecStatus xvecIvfRaBitQLoadIndexFromFaissFile(xvecExecutionContextTag* context,
57  const char* indexFilePath,
58  xvecIvfRaBitQIndexTag** outIndexHandle);
59 
79  typedef struct xvecIvfRaBitQDescriptor
80  {
85  uint32_t binaryCodeSize;
86  uint8_t defaultQb;
89  const uint8_t* binaryCodes;
95  /* Multi-bit fields. Appended for backward compatibility: leave them zeroed for a
96  1-bit index. */
97  uint8_t nbBits;
99  uint32_t exCodeSize;
101  const uint8_t* exCodes;
107 
131  xvecStatus xvecIvfRaBitQLoadIndexFromDescriptor(xvecExecutionContextTag* context,
132  const xvecIvfRaBitQDescriptor* descriptor,
133  xvecIvfRaBitQIndexTag** outIndexHandle);
134 
149  xvecStatus xvecIvfRaBitQDestroyIndex(xvecExecutionContextTag* context,
150  xvecIvfRaBitQIndexTag* indexHandle);
151 
152  // =============================================================================
153  // Kernel Preparation
154  // =============================================================================
155 
173  xvecStatus xvecIvfRaBitQPrepareKernel(xvecExecutionContextTag* context);
174 
175  // =============================================================================
176  // Search APIs
177  // =============================================================================
178 
202  xvecStatus xvecIvfRaBitQSearchFineSearchOnly(xvecExecutionContextTag* context,
203  xvecIvfRaBitQIndexTag* indexHandle,
204  xvecIvfRaBitQFineSearchQueryFloat32* fineSearchQuery,
205  xvecBufferTag* resultsBufferHandle,
206  xvecIvfRaBitQSearchTiming* outTiming);
207 
208 #ifdef __cplusplus
209 }
210 #endif
FAISS-free description of an IVF-RaBitQ index.
xvecVectorIdType numVectors
Total number of vectors; must equal the sum of listSizes.
const uint8_t * exCodes
Ex-bit codes grouped by cluster [numVectors * exCodeSize].
const xvecFloat32 * exFactors
Three factors per vector [numVectors * 3], grouped by cluster: {fError, fAddEx, fRescaleEx} for each ...
const xvecFloat32 * factors
Two factors per vector [numVectors * 2], grouped by cluster: {orMinusCL2sqr, dpMultiplier} for each v...
const xvecFloat32 * centroids
Coarse centroids, row-major [numClusters * dimension].
const xvecVectorIdType * ids
Original id per vector [numVectors], in the same grouped order.
const uint8_t * binaryCodes
Binary codes grouped by cluster [numVectors * binaryCodeSize].
xvecClusterIdType numClusters
Number of IVF clusters (nlist).
uint8_t nbBits
Bits per dimension: 1 sign bit + (nbBits - 1) magnitude bits.
uint32_t exCodeSize
Bytes of ex-bit code per vector; must equal (dimension * (nbBits - 1) + 7) / 8.
uint8_t defaultQb
Default query quantization bits (0 = no query quantization).
uint32_t binaryCodeSize
Bytes of binary code per vector; must equal (dimension + 7) / 8.
const xvecVectorIdType * listSizes
Vectors per cluster [numClusters]; entries sum to numVectors.
xvecDistanceType distanceType
Distance metric (L2 or DOT_PRODUCT).
xvecDimensionType dimension
Dimension of each vector (d).
Search query parameters for IVF-RaBitQ fine search only.
Definition: xvec_types.h:376
struct xvecIvfRaBitQDescriptor xvecIvfRaBitQDescriptor
FAISS-free description of an IVF-RaBitQ index.
struct xvecIvfRaBitQSearchTiming xvecIvfRaBitQSearchTiming
xvecStatus xvecIvfRaBitQPrepareKernel(xvecExecutionContextTag *context)
Pre-initializes PXL resources (Job, Module, Function) for IVF-RaBitQ search.
xvecStatus xvecIvfRaBitQLoadIndexFromDescriptor(xvecExecutionContextTag *context, const xvecIvfRaBitQDescriptor *descriptor, xvecIvfRaBitQIndexTag **outIndexHandle)
Loads an IVF-RaBitQ index from a FAISS-free descriptor.
xvecStatus xvecIvfRaBitQDestroyIndex(xvecExecutionContextTag *context, xvecIvfRaBitQIndexTag *indexHandle)
Destroys an IVF-RaBitQ index handle and releases its host-side data.
xvecStatus xvecIvfRaBitQLoadIndexFromFaissFile(xvecExecutionContextTag *context, const char *indexFilePath, xvecIvfRaBitQIndexTag **outIndexHandle)
Loads an IVF-RaBitQ index from a Faiss index file.
xvecStatus xvecIvfRaBitQSearchFineSearchOnly(xvecExecutionContextTag *context, xvecIvfRaBitQIndexTag *indexHandle, xvecIvfRaBitQFineSearchQueryFloat32 *fineSearchQuery, xvecBufferTag *resultsBufferHandle, xvecIvfRaBitQSearchTiming *outTiming)
Performs an IVF-RaBitQ fine search only (skips coarse search).
Core types, enums, and structures for the XVector library.
uint64_t xvecClusterIdType
Type for cluster identifiers in IVF indices.
Definition: xvec_types.h:204
uint32_t xvecDimensionType
Type for vector dimension.
Definition: xvec_types.h:194
xvecStatus
Status codes returned by XVector API functions.
Definition: xvec_types.h:133
xvecDistanceType
Distance/similarity metrics for vector search.
Definition: xvec_types.h:172
float xvecFloat32
32-bit floating point type for vector components.
Definition: xvec_types.h:111
uint64_t xvecVectorIdType
Type for vector identifiers.
Definition: xvec_types.h:209