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

Updating to latest faiss?

Open jondot opened this issue 1 year ago • 9 comments

I've forked @SkyFan2002 's static build, and in the effort to simplify, I've also updated to latest Faiss: https://github.com/jondot/faiss-rs Compiling on Mac M1 and running vector search and indexing works well.

As now we have static build in this repo, I'm wondering if its possible to point to a recent Faiss version (and not a specific C_api flavor), or there's something hidden from my knowledge that forbids that?

jondot avatar Aug 28 '23 08:08 jondot

Updating the inner Faiss to v1.7.4 seems like a good plan for v0.13.0. If you would like to send in a PR, the steps would be:

  1. Update the scripts in faiss-sys to point to v1.7.4
  2. Run gen_bindings.sh (may need tweaking depending on the version of bindgen used)
  3. Include changes to bindings.rs and bindings_gpu.rs
  4. Adjust code at faiss if necessary

Enet4 avatar Aug 28 '23 08:08 Enet4

on the fork up top i just updated the git submodule without running gen_bindings or any source updates. having said that, I selfishly built for my Mac M1 only, you're saying that if I attempt building for other platforms I might need these kind of tweaks?

jondot avatar Aug 28 '23 10:08 jondot

I'm not sure if I understood you correctly. Do you want to use a custom version of the Faiss library? That makes things a bit trickier. You will either need to depend on dynamic linking (assuming the C API is left working and compatible), or bring those changes upstream to Faiss so that they are released officially in a future version.

The changes I mentioned above are necessary to target a new version of Faiss, regardless of platform. Since Faiss does not follow semver, the crate is intended to always target a specific version of the library, or a version with a compatible C API.

Enet4 avatar Aug 28 '23 11:08 Enet4

What I'm saying is that I went ahead and updated my personal fork to this https://github.com/facebookresearch/faiss/commits/v1.7.4

And without running any binding gen steps, building statically, everything worked.

So i'm wondering -- did everything work only because I built for Mac? or if I tried building for other platforms, then I would need to do gen_bindings etc.

Hope that's clearer?

jondot avatar Aug 28 '23 11:08 jondot

I mean, it might have worked because of the range of API compatibility between those versions, but that may have been purely coincidental. In addition, new parts of the API are not exposed by faiss-sys unless the bindings are regenerated. So a complete Faiss upgrade should still go through the full process.

Enet4 avatar Aug 28 '23 12:08 Enet4

Got it, thanks!

jondot avatar Aug 28 '23 14:08 jondot

I've forked @SkyFan2002 's static build, and in the effort to simplify, I've also updated to latest Faiss: https://github.com/jondot/faiss-rs Compiling on Mac M1 and running vector search and indexing works well.

As now we have static build in this repo, I'm wondering if its possible to point to a recent Faiss version (and not a specific C_api flavor), or there's something hidden from my knowledge that forbids that?

@jondot hello,I hava a bug on mac m1

  = note: ld: library not found for -lgomp

do you know what's going on?


I hava installed libopm
(base) simonyi@simondeMacBook-Pro-2 faiss-rs %  brew info libomp
==> libomp: stable 16.0.6 (bottled) [keg-only]
LLVM's OpenMP runtime library
https://openmp.llvm.org/
/opt/homebrew/Cellar/libomp/16.0.6 (7 files, 1.7MB)
  Poured from bottle using the formulae.brew.sh API on 2023-09-05 at 13:57:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libomp.rb
License: MIT
==> Dependencies
Build: cmake ✔, lit ✔
==> Caveats
libomp is keg-only, which means it was not symlinked into /opt/homebrew,
because it can override GCC headers and result in broken builds.

For compilers to find libomp you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
==> Analytics
install: 19,756 (30 days), 80,619 (90 days), 231,651 (365 days)
install-on-request: 3,859 (30 days), 16,318 (90 days), 46,744 (365 days)
build-error: 2 (30 days)

web3creator avatar Sep 05 '23 07:09 web3creator

yes, on mac, we need omp and not gomp, and after omp is specified in build.rs, then you need to have libomp on your computer.

jondot avatar Sep 05 '23 07:09 jondot

@Enet4 I haven't yet moved back to your repo, so these are the relevant lines: https://github.com/jondot/faiss-rs/blob/master/faiss-sys/build.rs#L39-L43

jondot avatar Sep 05 '23 08:09 jondot