Skip to main content

Module index_builder

Module index_builder 

Source
Expand description

GPU-accelerated HNSW index construction

This module implements GPU-based HNSW graph construction using CUDA kernels (feature-gated behind the cuda feature). When CUDA is not available, it falls back to an efficient CPU implementation.

§Architecture

The GPU index builder works in phases:

  1. Vector Upload: Transfer vectors to GPU memory in batches
  2. Distance Matrix Computation: Compute all-pairs distances via CUDA kernels
  3. Neighbor Selection: Apply heuristic neighbor selection on GPU
  4. Graph Assembly: Assemble the HNSW graph structure from GPU results

§Pure Rust Policy

All CUDA code is gated with #[cfg(feature = "cuda")] so the default build is 100% Pure Rust.

Structs§

BatchSizeCalculator
Calculates optimal batch sizes for GPU index construction based on available GPU memory and vector dimensionality.
ComputedBatch
A batch for which GPU distance computation has been (simulated as) completed.
GpuBatchDistanceComputer
GPU-accelerated batch distance computation
GpuHnswIndexBuilder
GPU-accelerated HNSW index builder
GpuIndexBuildStats
Build statistics for the GPU index builder
GpuIndexBuilderConfig
Configuration for GPU-accelerated HNSW index building
GpuIndexOptimizer
Optimises GPU memory usage during index construction by computing ideal batch sizes and checking memory feasibility.
GpuMemoryBudget
GPU memory budget tracker for index construction.
HnswGraph
The assembled HNSW graph structure
HnswNode
A node in the HNSW graph
IncrementalGpuIndexBuilder
Incremental GPU index builder for streaming ingestion
IndexedBatch
A fully indexed batch: neighbor IDs have been selected and are ready to be merged into the final HNSW graph.
PipelinedIndexBuilder
Overlaps CPU preparation work with simulated GPU compute to build an index in a three-stage pipeline: prepare → compute → finalize.
PreparedBatch
A batch of vectors prepared (normalised / packed) on the CPU, ready to be dispatched to a GPU compute stage.

Enums§

GpuDistanceMetric
Distance metric type for GPU kernels