XFaiss
Faiss is Meta’s open-source library for efficient similarity search and clustering of dense vectors, widely used for large-scale ANN (approximate nearest neighbor) search.
XFaiss adds MU device acceleration on top of Faiss. Based on Faiss 1.13.2, it works as a drop-in replacement — accelerate search on MX1 with minimal code changes and existing .faiss index files. Internally, XFaiss uses libxvector-dev (the XVector API Reference) for device communication and kernel execution.
Supported Index Types
| Index | Base Class | Description |
|---|---|---|
| MuIndexIVFFlat | faiss::IndexIVFFlat | IVF-Flat with device-accelerated fine search |
| MuIndexIVFRaBitQ | faiss::IndexIVFRaBitQ | IVF-RaBitQ with device-accelerated fine search |
| MuIndexFlat | faiss::IndexFlat | Brute-force exact KNN with device-accelerated search |
| MuIndexHNSWFlat | faiss::IndexHNSWFlat | HNSW-Flat graph search on the device [experimental] |
How It Works
Faiss supports GPU offloading — wrapping a CPU index with a GPU index class to accelerate search on NVIDIA GPUs. XFaiss applies the same pattern for MU (MX1): wrap a CPU index with an MU index class to offload the compute-intensive fine search to the MU device.
| Faiss GPU | XFaiss MU | Role |
|---|---|---|
GpuResources | MuResources | Device resource management |
GpuIndexIVFFlat | MuIndexIVFFlat | IVF-Flat index with device acceleration |
index_cpu_to_gpu() | Constructor + syncToMuDevice() | Transfer index data to device |
Setup
Before search, the application initializes MU resources and transfers index data to the device:
makeMuResources()— connect to the MU device and load XVector kernels- Construct an MU index (e.g.,
MuIndexIVFFlat) from an existing Faiss CPU index syncToMuDevice()— copy index data from CPU memory to device memory
Once setup is complete, the MU index is ready to handle search requests.
Search
For the IVF indexes (MuIndexIVFFlat, MuIndexIVFRaBitQ), each search executes in two phases:
- Coarse search (CPU) — the Faiss quantizer selects the top-nprobe candidate clusters
- Fine search (MU device) — XVector kernels compute distances for all vectors within the selected clusters and return the top-k results
MuIndexIVFRaBitQ supports 1–9 bits per dimension. Use nb_bits = 1 for compact indexes, or more bits to trade additional memory for accuracy. See the IVF-RaBitQ tutorial for an example.
Build XFaiss against matching XVector headers and libraries. For upgrade and rebuild requirements, see the XVector changelog.
The non-IVF indexes run entirely on the device:
MuIndexFlat— a full brute-force scan over all vectors on the MU device.MuIndexHNSWFlat(experimental) — HNSW graph traversal on the MU device. The graph is built on the CPU duringadd()and uploaded bysyncToMuDevice(). Both k andefSearchmust be in the range [1, 256];efSearchis raised to at least k.
Library version
Query the linked XFaiss library without initializing a device:
#include <cstdio>
#include <xfaiss/version.h>
std::printf("XFaiss %s (%s)\n", xfaiss::get_version(), xfaiss::get_git_commit());
Link the usual Faiss library target. Returned strings are library-owned; do not modify or free them. The commit is "unknown" when Git metadata is unavailable. XFAISS_VERSION and XFAISS_GIT_COMMIT describe the build headers. faiss::get_version() reports the upstream Faiss version.
Next Steps
- Quick Start — build, prepare data, and run benchmarks