faiss-wheels icon indicating copy to clipboard operation
faiss-wheels copied to clipboard

Compatibility issue with faiss-cpu wheels on arm64 vs x86

Open NikhilSehgal123 opened this issue 1 year ago • 9 comments

Describe the bug FAISS has different wheels for arm64 chips & Intel/AMD chips. If you vectorise a document using arm64, you should use FAISS to interact with this document on a arm64 machine.

So right now, my mac is arm64 and I vectorised docs on my mac using the arm64 wheel. However in the Azure functions, it attempts to use the Intel wheel which is slightly different. Intel/AMD chips use something called AVX2 support in FAISS (no idea what it actually is but it's different to the way arm64 machines use FAISS).

How can this be solved? Normalise the wheels across all architectures to solve this compatibility issue problem - happy to help?

NikhilSehgal123 avatar Apr 27 '23 08:04 NikhilSehgal123

avx2 is a CPU instruction set. I have no idea what is the binary compatibility to the saved indices across different architectures. Ask the question in the official repository.

kyamagu avatar Apr 28 '23 00:04 kyamagu

Yep, I have this exact issue. I've deployed to AWS EKS but built the vectorstore on my mac locally and am getting errors. Would be great to get this fixed! @NikhilSehgal123 if you post this issue in the official repository, please post the link here, and i'll +1 and comment! 🙏

max-addison avatar Apr 28 '23 08:04 max-addison

Ya it would be great to fix this issue soon if possible!

jpzhangvincent avatar May 23 '23 08:05 jpzhangvincent

Hey guys @max-addison @jpzhangvincent, I know this issue is causing some pain for many people, so another simple workaround is to just upload your vectorstores to Pinecone or another cloud hosted vector DB to avoid this type of issue.

NikhilSehgal123 avatar May 23 '23 09:05 NikhilSehgal123

I experienced this same issue when using LangChain.

here there is the following code:

Import faiss if available, otherwise raise error.
    If FAISS_NO_AVX2 environment variable is set, it will be considered
    to load FAISS with no AVX2 optimization.

When I explicitly did not set FAISS_NO_AVX2 this error subsides. Previously I was experiencing the same thing mentioned in this thread. The faiss index that I am working with today, was created on a windows machine and running successfully on a linux machine. So it seems like loading FAISS with AVX2 optimization resolved the issue for me. Not sure this is helpful to everybody, but hopefully it will help somebody 😄

Alex-Wenner-FHR avatar Jul 12 '23 13:07 Alex-Wenner-FHR

@Alex-Wenner-FHR

I was trying FAISS_NO_AVX2 but it does not work inside of docker container for some reason (getting TypeError: IndexFlatCodes.add() missing 1 required positional argument: 'x' error). I opened issue: https://github.com/langchain-ai/langchain/issues/8857 . Please let me know if you know why I am getting that error.

aiakubovich avatar Aug 07 '23 09:08 aiakubovich

@aiakubovich I actually ran into this as well. I am trying to recall what I had done... I know I had troubles with pathing and being able to find the index.faiss in the faiss_index folder. I do believe I had to recreate the Faiss_Index on the same type of machine I was trying to inference... for example, originally it was on Windows and trying to be ran on a linux machine, I had to recreate it on a linux machine to run it on the linux machine.

Alex-Wenner-FHR avatar Aug 07 '23 12:08 Alex-Wenner-FHR

@Alex-Wenner-FHR Thanks for your response. I thought that FAISS_NO_AVX2 is option that allows to use same embeddings for both Windows and Linux machines. Without this option I indeed have to rerun embeddings on different machines. With this option I unable to run embeddings in Linux container at all. No idea why.

aiakubovich avatar Aug 07 '23 15:08 aiakubovich

Same problem to run on linux but not on m2/m1 mac

https://github.com/langchain-ai/chat-langchain/issues/61

aboutmydreams avatar Dec 12 '23 09:12 aboutmydreams