ashvardanian / SimSIMD

Up to 200x Faster Dot Products & Similarity Metrics — for Python, Rust, C, JS, and Swift, supporting f64, f32, f16 real & complex, i8, and bit vectors using SIMD for both AVX2, AVX-512, NEON, SVE, & SVE2 📐
https://ashvardanian.com/posts/simsimd-faster-scipy/
Apache License 2.0
988 stars 59 forks source link

Feature: How is WASM Compiled? Are you using wasm_simd128 and msimd128 ? #189

Open vtempest opened 2 months ago

vtempest commented 2 months ago

Describe what you are looking for

WASM support for SIMD discussion: https://github.com/emscripten-core/emscripten/issues/12714 emscripten SIMD Docs https://emscripten.org/docs/porting/simd.html wasm vs wam with msimd benchmark https://jeromewu.github.io/improving-performance-using-webassembly-simd-intrinsics/ demo code with wasm_simd https://github.com/jeromewu/wasm-perf/blob/main/mul_mats_intrin.c

Here's where the NGT algorithm, which is faster than HNSW, uses SIMD to optimize internally: https://github.com/yahoojapan/NGT/blob/1e44fffc2b95b211ff29ee693abb4a25057042d4/lib/NGT/Clustering.h#L224

Can you contribute to the implementation?

Is your feature request specific to a certain interface?

It applies to everything

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 2 months ago

Hi @vtempest! We don't currently compile to WASM, but it should be compatible with SimSIMD NEON kernels, I believe. What exactly are you looking for?

vtempest commented 2 months ago

I would like to help build the fastest Simd accelerated vector search. If usearch uses simsimd and compiles to wasm, I'd love to improve upon it and build my vsearch fork with ram limited clusters.

ashvardanian commented 2 months ago

Yes, USearch compiles to WASM, but the whole ecosystem is currently fragmented, and it's not clear how to ship library dependencies for WASM. Still, it shouldn't be hard to integrate USearch directly into an arbitrary project that uses WASM, and then compile together as a monorepo. Have you tried that?

vtempest commented 2 months ago

Yes I was working on top of the original hnswlib ported to wasm here: https://github.com/kaiobarb/hnswlib-wasm?tab=readme-ov-file I am wondering how to integrate usearch instead as the base lib and then add to it the cluster splitting for RAM limits.

https://github.com/yahoojapan/NGT/issues/168#issuecomment-2363499081 NGT inventor says my ram-limited clusters approach looks very promising. I'd like to integrate it into hnsw and usearch v3

ashvardanian commented 2 weeks ago

@vtempest, have you tried compiling SimSIMD into WASM already? I think the NEON backend should be compatible and can provide a huge boost for i8/u8/f16/bf16 vectors in any search engine, be it USearch or HNSW lib 🤗