Skip to main content

oxirs_vec/gpu/
index_builder.rs

1//! GPU-accelerated HNSW index construction
2//!
3//! This module implements HNSW graph construction with a GPU-oriented batched
4//! pipeline that runs as an efficient Pure Rust CPU implementation. Real CUDA
5//! kernels live in the quarantined `oxirs-vec-adapter-cuda` crate.
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//! This module is 100% Pure Rust. Real CUDA code is quarantined in the
18//! `oxirs-vec-adapter-cuda` crate (publish = false).
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};