feat(hyperbolic-hnsw): Add Poincaré ball embeddings with HNSW integration#114
Merged
feat(hyperbolic-hnsw): Add Poincaré ball embeddings with HNSW integration#114
Conversation
…tion Implement hyperbolic vector search for hierarchy-aware applications using the Poincaré ball model of hyperbolic space. Core features: - Poincaré ball math operations (Möbius addition, exp/log maps) - Stable hyperbolic distance with acosh/log1p expansions - HNSW integration with tangent-space pruning optimization - Per-shard curvature registry with canary testing - Dual-space index for Euclidean fallback and fusion - WASM bindings via wasm-bindgen Key optimizations: - Precompute tangent coordinates at shard centroids for fast pruning - Use Euclidean distance in tangent space to filter candidates - Apply exact Poincaré distance only on top-N finalists Dependencies (exact versions as specified): - nalgebra 0.34.1 - ndarray 0.17.1 - wasm-bindgen 0.2.106 Includes 30 comprehensive tests covering: - Mathematical properties (symmetry, identity, triangle inequality) - Numerical stability (boundary, zero vector, curvature extremes) - HNSW operations (insert, search, pruning) - Shard management (curvature registry, canary) Crates excluded from workspace to avoid version conflicts.
Key optimizations for 27-73% speedup on core operations: - Fused norms: Compute ||u-v||², ||u||², ||v||² in single pass - Reduces memory bandwidth by 3x - Eliminates redundant iterations - Loop unrolling: Process 4 elements per iteration - Better SIMD auto-vectorization - Reduced loop overhead - In-place operations: Add project_to_ball_inplace, mobius_add_inplace - Eliminates allocation for frequently called operations - Fast acosh: Optimized with Taylor expansion for small deltas - Stable numerics with ln(x + sqrt(x²-1)) for normal range - ln(2x) approximation for very large values - Pre-computed norms: Add poincare_distance_from_norms for batch ops - Reuse query norm across multiple distance calculations Benchmark results (release build): - poincare_distance dim=128: 361ns → 137ns (62% faster) - poincare_distance dim=512: 1.7µs → 462ns (73% faster) - mobius_add dim=128: 552ns → 389ns (30% faster) - exp_map dim=32: 240ns → 215ns (10% faster)
ruvnet
added a commit
that referenced
this pull request
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement hyperbolic vector search for hierarchy-aware applications using
the Poincaré ball model of hyperbolic space.
Core features:
Key optimizations:
Dependencies (exact versions as specified):
Includes 30 comprehensive tests covering:
Crates excluded from workspace to avoid version conflicts.