Systems & Data Infrastructure
Vectra
SIMD-Accelerated HNSW Vector Index Engine in Rust
Problem
Python-based vector search libraries impose runtime overhead and hidden abstraction costs. Applications needing sub-millisecond retrieval at high concurrency cannot afford managed external servers.
Solution
Built a complete HNSW graph construction and search engine in Rust with heuristic neighbor selection, SIMD-accelerated (AVX2) cosine and L2 distance kernels, and Product Quantization to compress embeddings. Packaged with PyO3 for native Python import.
Architecture
Multi-layer skip-list graph with heuristic pruning (HNSW Algorithm 4). Distance kernels dispatch to AVX2 intrinsics for 8-float/8-float SIMD lane parallelism. PQ splits 1536-dim vectors into 48 sub-spaces trained with Lloyds algorithm. Rayon for lock-free parallel graph construction.
Real-World Impact
Achieved 98.1% recall@10 on SIFT1M, 2.3x higher QPS than Python hnswlib, and 7.8x memory reduction with PQ compression vs flat float32 storage.
Challenges Faced
Memory ordering guarantees for concurrent graph insertion across Rayon threads; AVX2 alignment requirements for unaligned vector data.
Key Learnings
Rust ownership model for concurrent data structures, SIMD intrinsics programming, ANN recall-latency tradeoffs, and cross-language FFI via PyO3.