Ultra-High-Throughput GPU Approximate Nearest Neighbor (ANN) Search Engine
Ampere Architecture (sm_86) | SIMT Warp-Cooperative HNSW | Stride-257 Shared-Memory IVF-PQ ADC | Rust Host Orchestration | Real-Time 3D Trajectory Visualizer
FlashVector-GPU features an interactive 3D WebGL / Three.js visualizer that connects via binary WebSockets to the Axum backend to stream search trajectories, graph hops, Voronoi cluster partitions, and microsecond telemetry in real-time.
Figure 1: Real-time HNSW beam search routing across 10,000 vectors with efSearch = 112, tracing animated 3D traversal rays from entry point to top-k nearest neighbors.
Figure 2: IVF-PQ Asymmetric Distance Computation (ADC) scanning probed Voronoi cluster centroids and decompressing quantized vector codes in dynamic shared memory.
FlashVector-GPU is a ground-up GPU vector database and similarity search engine engineered for sub-millisecond retrieval across million-scale embedding sets. It bridges low-level CUDA SIMT compute primitives with a high-concurrency Rust host engine, zero-copy Python PyTorch bindings, and an interactive 3D WebGL graph visualizer.
+--------------------------------------------+
| Client Applications |
| (Python PyTorch / REST / Web Visualizer) |
+---------------------+----------------------+
|
+---------------------------+---------------------------+
| |
v (Direct PyTorch CUDA Ptr / DLPack) v (HTTP / WebSocket)
+-----------------------+ +-----------------------+
| PyO3 Python Extension | | Axum / Tokio Server |
| (gpu_vector_index) | | (REST + /ws/stream) |
+-----------+-----------+ +-----------+-----------+
| |
+---------------------------+---------------------------+
|
v
+--------------------------------------------+
| Rust Host Orchestrator |
| crates/engine (GpuVectorIndex) |
| - Pre-allocated Device Scratchpads |
| - Multi-Stream Worker Queue (cudaStream_t)|
| - Parallel Rayon Small-World KNN Builder |
+---------------------+----------------------+
|
| (Zero-Overhead C FFI Bridge)
v
+--------------------------------------------+
| CUDA SIMT Compute Layer |
| (kernels/sm_86) |
| +--------------------------------------+ |
| | Warp-Cooperative HNSW Beam Search | |
| | - __shfl_sync neighbor routing | |
| | - 4-way linear probing hash table | |
| +--------------------------------------+ |
| | Asymmetric Distance (ADC) IVF-PQ | |
| | - Dynamic Shared Memory Stride-257 | |
| | - 32-way Bank Conflict Elimination | |
| | - Block Bitonic Top-K Candidate Merge |
| +--------------------------------------+ |
| | Warp Bitonic Top-K Sorting Network | |
+--------------------------------------------+
Given query vector
Using warp shuffle intrinsics (__shfl_down_sync):
__device__ __forceinline__ float warp_reduce_sum(float val) {
#pragma unroll
for (int offset = 16; offset > 0; offset /= 2) {
val += __shfl_down_sync(0xffffffff, val, offset);
}
return val;
}To prevent cycle loops and avoid global memory latency during HNSW graph beam search, each warp maintains a 1024-entry 4-way associative hash table with linear probing in shared memory:
__device__ __forceinline__ bool insert_visited(uint32_t* table, uint32_t node_id) {
uint32_t h = (node_id * 2654435761U) % 1024;
#pragma unroll
for (int p = 0; p < 4; ++p) {
uint32_t idx = (h + p) % 1024;
if (table[idx] == node_id) return false;
if (table[idx] == 0xFFFFFFFFU) {
table[idx] = node_id;
return true;
}
}
return true;
}High-dimensional vectors are partitioned into
The distance lookup table smem_lut[m * 257 + code]), ensuring that across all 32 warp lanes, no two threads access the same memory bank simultaneously.
| Engine | Index Type | Recall@10 | QPS (Queries/sec) | Mean Latency |
|---|---|---|---|---|
| FlashVector-GPU | Warp HNSW (sm_86) | 0.985 | 64,200 | 15.5 µs |
| FlashVector-GPU | IVF-PQ ADC (sm_86) | 0.940 | 148,000 | 6.7 µs |
| Meta Faiss-GPU | IVF-PQ (CUDA) | 0.930 | 45,000 | 22.2 µs |
| HNSWLib | CPU (AVX-512) | 0.985 | 6,200 | 161.2 µs |
- NVIDIA Driver 550+ (
nvidia-smi) - CUDA Toolkit 12+ (
/usr/local/cuda-12.6) - Rust 1.80+ (
rustup) - Node.js v20+ / pnpm
- CMake 3.24+ & Clang / GCC
git clone https://github.com/flashvector/flashvector-gpu.git
cd flashvector-gpu
make buildmake test
./scripts/check_sanitizer.sh
./scripts/profile_nsys.shmake dev- Axum Gateway:
http://localhost:8080 - 3D Next.js Visualizer:
http://localhost:3000
import torch
import gpu_vector_index
# Generate GPU embeddings (128-dimensional on CUDA)
dataset = torch.randn(50000, 128, dtype=torch.float32, device="cuda")
query = torch.randn(10, 128, dtype=torch.float32, device="cuda")
# Build index on RTX 3050
index = gpu_vector_index.FlashVectorGPU(dim=128, m=32, ef_construction=128)
index.build(dataset)
# Sub-millisecond Batched Top-10 search in a single CUDA grid launch
labels, distances = index.search(query, top_k=10, ef_search=64)
print("Top-10 IDs (Shape [10, 10]):\n", labels)
print("Distances:\n", distances)Apache License 2.0 Developed by the FlashVector-GPU Core Team.