facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
31.72k stars 3.66k forks source link

How to dynamicly choose simd level at runtime? #2959

Open chasingegg opened 1 year ago

chasingegg commented 1 year ago

In faiss some features like IVFPQFastScan rely on at least AVX2 level simd, and we could turn on the flag at the compilation, but we can not decide it dynamicly, that is if we turn on the opt flag on a very old machine, it could not run. Another question is that when we conda install faiss, it seems it could detect the simd level and choose the AVX2 or just no simd, how does it happen?

mdouze commented 1 year ago

The packaged faiss comes with two compiled versions of the .so library (_swigfaiss.so and _swigfaiss_avx2.so) that are selected at the python layer. It is a current discussion on how we can switch platforms with a finer granulairty.

chasingegg commented 1 year ago

I see, when we install python package, it is on our 'run machines' where we could detect the simd level. Otherwise, there is possibly the problem between 'compile machines' and 'run machines'. So you mean you guys are discussing the proper solution recently? Curious about the result.