Add BMSSP WASM integration and j-Tree optimizations (ADR-002 addendum)#135
Merged
Add BMSSP WASM integration and j-Tree optimizations (ADR-002 addendum)#135
Conversation
Proposes two-tier dynamic cut architecture based on arXiv:2601.09139 (Goranci, Henzinger, Kiss, Momeni, Zöcklein, SODA 2026): - Tier 1: j-Tree hierarchy for O(n^ε) approximate cut queries - Tier 2: Existing exact min-cut (arXiv:2512.13105) for verification Key benefits: - Broader query support (sparsest cut, multi-way cut, multi-cut) - Vertex-split-tolerant cut sparsifier with poly-log recourse - Two-tier strategy: fast approximate + exact verification - Integration path with coherence gate (ADR-001)
Extends ADR-002 with cutting-edge techniques: - Predictive dynamics: SNN predicts updates before they happen - Neural sparsification: SpecNet + DSpar for 90% edge reduction - Lazy hierarchical evaluation: demand-paged j-tree levels - Warm-start cut-matching: reuse computation across updates - 256-core parallel distribution: leverage agentic chip - Streaming sketch fallback: O(n log n) space for n > 100K Target: sub-microsecond approximate queries, <100μs exact verification
Integrates @ruvnet/bmssp for j-tree acceleration: - O(m·log^(2/3) n) via path-cut duality (beats O(n log n)) - WasmNeuralBMSSP for learned edge importance/sparsification - Multi-source queries for terminal-based operations - 27KB WASM enables browser/edge deployment - 10-84x speedup over JavaScript implementations Key integration points: - BmsspJTreeLevel: WASM-backed j-tree levels - BmsspNeuralSparsifier: embedding-based edge selection - Hybrid deployment: BMSSP queries + native exact verification
Implements SOTA optimizations from ADR-002-addendum: - dspar.rs: Degree-based presparse (DSpar algorithm) - Effective resistance approximation via degree product - 5.9x speedup for initial sparsification - Configurable sparsity ratio and thresholds - cache.rs: LRU cache for path/cut distances - Prefetch based on access patterns - SIMD-ready distance array operations - Configurable capacity and eviction policy - mod.rs: Module exports and unified interface
- jtree_bench.rs: Comprehensive benchmarks for j-tree implementation - Query benchmarks (point-to-point, multi-terminal, all-pairs) - Update benchmarks (insert, delete, batch) - Scaling benchmarks (verify O(n^ε) complexity) - Memory benchmarks (full vs lazy hierarchy) - Cargo.toml: Add benchmark configuration and dependencies - Cargo.lock: Update lockfile with new dependencies
Security: - BMSSP-SECURITY-REVIEW.md: Comprehensive WASM security audit - Risk assessment matrix for FFI boundary - Input validation recommendations - Resource exhaustion mitigations Optimization: - simd_distance.rs: SIMD-accelerated distance array operations - Vectorized min/max/sum operations - Cache-line aligned memory access Tests: - jtree_tests.rs: Comprehensive test suite - Unit tests for LazyLevel transitions - Integration tests for TwoTierCoordinator - Property-based tests for approximation guarantees
- pool.rs: Pool allocator for frequent allocations - Reduces allocation overhead in hot paths - Configurable pool size and growth factor - jtree_tests.rs: Enhanced test coverage - Additional edge cases for hierarchy operations - Improved property-based test assertions
Core implementation of ADR-002 dynamic hierarchical j-tree: - mod.rs: Module exports, JTreeConfig, feature gates - level.rs: BmsspJTreeLevel with path-cut duality - min_cut(s, t) via shortest path in dual - multi_terminal_cut for k terminals - LRU cache for distance queries - hierarchy.rs: LazyJTreeHierarchy - Demand-paged level materialization - Warm-start recomputation from dirty state - O(n^ε) amortized updates - sparsifier.rs: DynamicCutSparsifier - Vertex-split-tolerant with poly-log recourse - Forest packing for edge sampling - Degree-based presparse integration - coordinator.rs: TwoTierCoordinator - Routes between approximate (Tier 1) and exact (Tier 2) - Configurable escalation triggers - Cross-tier result caching - lib.rs: Add jtree module with feature gate
- parallel.rs: Rayon-based parallel level updates - Lock-free cache updates with atomic operations - Work-stealing for imbalanced levels - Configurable thread pool size
- wasm_batch.rs: Batch WASM operations for reduced FFI overhead - Pre-allocate WASM memory for bulk transfers - TypedArray batching for distance arrays - Minimizes JS-WASM boundary crossings - lib.rs: Update module exports for optimization features
- benchmark.rs: Benchmark utilities for performance profiling - Throughput measurement helpers - Latency histogram tracking - Memory usage estimation - coordinator.rs: Additional safety checks and error handling - hierarchy.rs: Refined level management - lib.rs: Export new optimization modules
- optimization_bench.rs: Benchmarks for optimization components - DSpar presparse performance - Cache hit/miss ratios - SIMD distance operations - Pool allocator throughput - Parallel level update scaling - lib.rs: Update exports
- coordinator.rs: Fixed to work with JTreeHierarchy - Lazy initialization pattern with ensure_built() - EscalationPolicy enum (Never, Always, LowConfidence, etc.) - TierMetrics for usage tracking - 14 coordinator-specific tests passing - mod.rs: Export coordinator types - benchmark.rs: Minor refinements - parallel.rs: Minor refinements All 50 jtree tests now passing.
ruvnet
added a commit
that referenced
this pull request
Feb 20, 2026
Reviewed and verified: - All CI builds pass (linux, darwin, windows) - Crates published: ruvector-mincut@0.1.30, ruvector-mincut-wasm@0.1.29, ruvector-mincut-node@0.1.29 - NPM packages published: @ruvnet/bmssp@1.0.0 - Code compiles cleanly with workspace version 2.0.1 - BMSSP WASM integration and j-Tree optimizations verified
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.
Summary
This PR integrates the
@ruvnet/bmssp(Bounded Multi-Source Shortest Path) WASM module to accelerate j-tree minimum cut operations, implementing the BMSSP integration addendum to ADR-002. The changes enable O(m·log^(2/3) n) complexity for path-based cut queries versus O(n log n) for direct approaches, targeting 10-15x speedup over JavaScript fallbacks and 4-8x improvement in the full j-tree pipeline.Key Changes
BmsspJTreeLevelwrapper providing path-cut duality for minimum cut queries via WASM-accelerated shortest pathsBmsspNeuralSparsifierusingWasmNeuralBMSSPfor learned edge importance scoring and graph sparsificationoptimization_bench.rswith 7 benchmark suites (DSpar, PathCache, SIMD, Pool, Parallel, WASM_Batch, Complete_Suite) measuring before/after performance for each optimizationjtree_bench.rsfor hierarchical decomposition performance testingCargo.tomlwith new features:jtree,tiered,all-cut-queriesfor modular optimization selectionImplementation Details
Architecture
The integration follows a 3-layer design:
Performance Targets
Deployment Support
Dependency Updates
windowsfrom 0.57.0 to 0.58.0cognitum-gate-kernel 0.1.0dependencyruvector-*crates to 2.0.1 (from 2.0.0)ruvector-attention,ruvector-gnn,ruvector-graph,ruvector-sona,ruvllmTesting
Comprehensive benchmark suite validates:
All benchmarks use Criterion for statistical rigor with multiple iterations.