|
XVector
|
HNSW-Flat (Hierarchical Navigable Small World) index interface. More...
#include "xvector/xvec_types.h"Go to the source code of this file.
Classes | |
| struct | xvecHnswFlatDescriptor |
| FAISS-free description of an HNSW-Flat index. More... | |
Typedefs | |
| typedef struct xvecHnswFlatSearchTiming | xvecHnswFlatSearchTiming |
| typedef struct xvecHnswFlatDescriptor | xvecHnswFlatDescriptor |
| FAISS-free description of an HNSW-Flat index. More... | |
Functions | |
| xvecStatus | xvecHnswFlatSearch (xvecExecutionContextTag *context, xvecHnswFlatIndexTag *indexHandle, xvecHnswFlatSearchQueryFloat32 *searchQuery, xvecBufferTag *resultsBufferHandle, xvecHnswFlatSearchTiming *outTiming) |
| Performs an HNSW-Flat search. More... | |
| xvecStatus | xvecHnswFlatPrepareKernel (xvecExecutionContextTag *context) |
| Warm-starts the HNSW-Flat search kernels on a context (optional). More... | |
| xvecStatus | xvecHnswFlatLoadIndexFromFaissFile (xvecExecutionContextTag *context, const char *indexFilePath, xvecHnswFlatIndexTag **outIndexHandle) |
| Loads an HNSW-Flat index from a Faiss index file and uploads it to the device. More... | |
| xvecStatus | xvecHnswFlatLoadIndexFromDescriptor (xvecExecutionContextTag *context, const xvecHnswFlatDescriptor *descriptor, xvecHnswFlatIndexTag **outIndexHandle) |
| Loads an HNSW-Flat index from a FAISS-free descriptor and uploads it to the device. More... | |
| xvecStatus | xvecHnswFlatDestroyIndex (xvecExecutionContextTag *context, xvecHnswFlatIndexTag *indexHandle) |
| Destroys an HNSW-Flat index handle and releases its host-side data. More... | |
HNSW-Flat (Hierarchical Navigable Small World) index interface.
This header provides the public API for loading, searching, and managing HNSW-Flat indices. HNSW is a graph-based approximate nearest neighbor algorithm that provides excellent search performance with a controllable accuracy/speed trade-off (efSearch).
Definition in file xvec_hnsw_flat.h.
| typedef struct xvecHnswFlatDescriptor xvecHnswFlatDescriptor |
FAISS-free description of an HNSW-Flat index.
Fully describes the hierarchical graph so an index can be built with no FAISS dependency. The neighbor layout mirrors FAISS's HNSW storage: per node, a contiguous slice of neighbors holds all of that node's levels – level 0 first (M0 slots) then each higher level (M slots) – with empty slots set to -1. neighborOffsets gives each node's start into that flat array, so node i occupies [neighborOffsets[i], neighborOffsets[i + 1]), which must equal M0 + nodeLevels[i] * M.
| typedef struct xvecHnswFlatSearchTiming xvecHnswFlatSearchTiming |
Definition at line 1 of file xvec_hnsw_flat.h.
| xvecStatus xvecHnswFlatDestroyIndex | ( | xvecExecutionContextTag * | context, |
| xvecHnswFlatIndexTag * | indexHandle | ||
| ) |
Destroys an HNSW-Flat index handle and releases its host-side data.
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the index to destroy |
| xvecStatus xvecHnswFlatLoadIndexFromDescriptor | ( | xvecExecutionContextTag * | context, |
| const xvecHnswFlatDescriptor * | descriptor, | ||
| xvecHnswFlatIndexTag ** | outIndexHandle | ||
| ) |
Loads an HNSW-Flat index from a FAISS-free descriptor and uploads it to the device.
Builds an HNSW-Flat 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 (e.g. XFaiss). See xvecHnswFlatDescriptor for the required memory layout. The graph and vectors are packed and transferred to device memory once here, like xvecHnswFlatLoadIndexFromFaissFile.
| [in] | context | Execution context for device operations |
| [in] | descriptor | Fully-populated index descriptor (borrowed for the call) |
| [out] | outIndexHandle | Receives the loaded index handle; destroy with xvecHnswFlatDestroyIndex. |
| xvecStatus xvecHnswFlatLoadIndexFromFaissFile | ( | xvecExecutionContextTag * | context, |
| const char * | indexFilePath, | ||
| xvecHnswFlatIndexTag ** | outIndexHandle | ||
| ) |
Loads an HNSW-Flat index from a Faiss index file and uploads it to the device.
The graph and vectors are packed and transferred to device memory once here (via the context), so subsequent xvecHnswFlatSearch calls reuse them without re-uploading.
| [in] | context | Execution context for device operations |
| [in] | indexFilePath | Path to the Faiss (.faiss) index file |
| [out] | outIndexHandle | Receives the loaded index handle; destroy with xvecHnswFlatDestroyIndex. |
| xvecStatus xvecHnswFlatPrepareKernel | ( | xvecExecutionContextTag * | context | ) |
Warm-starts the HNSW-Flat search kernels on a context (optional).
Pre-resolves the device kernel functions so the first xvecHnswFlatSearch() call does not pay the one-time module/function resolution cost. The single search kernel selects its layout (regular vs channel-striped gather) at runtime from the loaded index. xvecHnswFlatSearch() still resolves lazily if this is not called.
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.
| [in] | context | Execution context for device operations |
| xvecStatus xvecHnswFlatSearch | ( | xvecExecutionContextTag * | context, |
| xvecHnswFlatIndexTag * | indexHandle, | ||
| xvecHnswFlatSearchQueryFloat32 * | searchQuery, | ||
| xvecBufferTag * | resultsBufferHandle, | ||
| xvecHnswFlatSearchTiming * | outTiming | ||
| ) |
Performs an HNSW-Flat search.
Searches the index for the top-K nearest neighbors of each query vector, navigating the hierarchical graph from the entry point.
| [in] | context | Execution context for device operations |
| [in] | indexHandle | Handle to the HNSW-Flat index |
| [in] | searchQuery | Query vectors + parameters (efSearch controls accuracy/speed) |
| [out] | resultsBufferHandle | Caller-preallocated buffer, size queryVectorCount * topK * sizeof(xvecHnswFlatSearchResultFloat32) |
| [out] | outTiming | Pointer to receive timing information (can be NULL) |