feat(ruvector-cnn): CNN contrastive learning + SIMD optimization fixes#252
Merged
feat(ruvector-cnn): CNN contrastive learning + SIMD optimization fixes#252
Conversation
- Add ruvector-cnn crate with SIMD-optimized convolutions and contrastive losses - Implement InfoNCE (SimCLR) and TripletLoss for contrastive learning - Add MobileNet-V3 inspired backbone architecture - Include AVX2, NEON, WASM SIMD support with scalar fallback - Add WASM bindings (ruvector-cnn-wasm) for browser/Node.js - Add npm package with TypeScript definitions - Include comprehensive research docs and ADR-088 - 36 tests passing Co-Authored-By: claude-flow <ruv@ruv.net>
Co-Authored-By: claude-flow <ruv@ruv.net>
## SIMD Implementations (was using scalar fallbacks) - AVX2: conv_3x3_avx2, conv_3x3_avx2_fma, depthwise_conv_3x3_avx2 - AVX2: global_avg_pool_avx2, max_pool_2x2_avx2 - WASM: conv_3x3_wasm, depthwise_conv_3x3_wasm All now use real SIMD intrinsics processing 8 (AVX2) or 4 (WASM) channels simultaneously with scalar fallback for remainders. ## Backbone Fixes - Deprecated MobileNetV3Small/Large (use unified MobileNetV3 instead) - Implemented actual block processing in forward() methods - Fixed hardcoded channel counts in global_avg_pool calls ## Dead Code Fixes - Added #[allow(dead_code)] for momentum field (used in training) - Added #[allow(dead_code)] for rng field (feature-gated) - Added #[cfg(feature = "augmentation")] for rand::Rng import - Commented out undefined "parallel" feature reference Co-Authored-By: claude-flow <ruv@ruv.net>
…ation - Add Winograd F(2,3) transforms for 2.25x faster 3x3 convolutions - Implement π-calibrated INT8 quantization with anti-resonance offsets - Apply 4x loop unrolling with 4 accumulators to AVX2 convolutions - Update README with practical intro, capabilities table, benchmarks - Update npm README with simpler language and examples - Add CNN image embeddings to root README capabilities Co-Authored-By: claude-flow <ruv@ruv.net>
Owner
Author
Additional Changes (Latest Commit)Added more optimizations and documentation improvements: New Features
Documentation Updates
New Files
All 36 unit tests + 4 doc tests pass. |
- Add unsafe blocks for WASM SIMD intrinsics (v128_load/v128_store) - Disable wasm-opt to avoid SIMD validation issues - Build and include WASM bindings in npm package - Update npm package.json with all WASM files - Published to npm as @ruvector/cnn@0.1.0 Co-Authored-By: claude-flow <ruv@ruv.net>
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 adds CNN contrastive learning capabilities to ruvector and fixes critical SIMD/backbone issues discovered during code review.
New Features
CNN Contrastive Learning Crate
augmentationfeature): random crop, flip, color jitter, grayscale, blurruvector-cnn-wasm)ruvector-cnn) with TypeScript definitionsBug Fixes (Closes #251)
SIMD Functions Were Stubs
Implemented real SIMD for:
conv_3x3_avx2,conv_3x3_avx2_fma- now processes 8 output channels simultaneouslydepthwise_conv_3x3_avx2- now processes 8 channels at onceglobal_avg_pool_avx2- vectorized accumulationmax_pool_2x2_avx2- uses_mm256_max_psconv_3x3_wasm,depthwise_conv_3x3_wasm- 4 channels with SIMD128MobileNetV3 Forward Pass
MobileNetV3Small/MobileNetV3Largein favor of unifiedMobileNetV3Dead Code
Test Plan
Files Changed
🤖 Generated with claude-flow