Skip to main content

oxirs_vec/gpu/
index_builder.rs

1//! GPU-accelerated HNSW index construction
2//!
3//! This module implements GPU-based HNSW graph construction using CUDA kernels
4//! (feature-gated behind the `cuda` feature). When CUDA is not available, it
5//! falls back to an efficient CPU implementation.
6//!
7//! # Architecture
8//!
9//! The GPU index builder works in phases:
10//! 1. **Vector Upload**: Transfer vectors to GPU memory in batches
11//! 2. **Distance Matrix Computation**: Compute all-pairs distances via CUDA kernels
12//! 3. **Neighbor Selection**: Apply heuristic neighbor selection on GPU
13//! 4. **Graph Assembly**: Assemble the HNSW graph structure from GPU results
14//!
15//! # Pure Rust Policy
16//!
17//! All CUDA code is gated with `#[cfg(feature = "cuda")]` so the default build
18//! is 100% Pure Rust.
19//!
20//! # Module Layout
21//!
22//! - [`crate::gpu::index_builder_types`]: Config types, distance metrics, graph structures
23//! - [`crate::gpu::index_builder_phases`]: Builder implementations and pipeline stages
24
25// Re-export all public types from sub-modules so the public API is unchanged.
26pub use crate::gpu::index_builder_phases::{
27    BatchSizeCalculator, ComputedBatch, GpuBatchDistanceComputer, GpuHnswIndexBuilder,
28    GpuIndexOptimizer, GpuMemoryBudget, IncrementalGpuIndexBuilder, IndexedBatch,
29    PipelinedIndexBuilder, PreparedBatch,
30};
31pub use crate::gpu::index_builder_types::{
32    ComputationCache, GpuDistanceMetric, GpuIndexBuildStats, GpuIndexBuilderConfig, HnswGraph,
33    HnswNode,
34};