Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from RAFT to CUVS #3549

Open
wants to merge 121 commits into
base: main
Choose a base branch
from

Conversation

tarang-jain
Copy link
Contributor

@tarang-jain tarang-jain commented Jun 25, 2024

Remove the dependency on raft::compiled and modify GPU implementations to use cuVS backend in place of RAFT.

A deeper insight into the dependency:
FAISS gets the ANN algorithm implementations such as IVF-Flat and IVF-PQ from cuVS. RAFT is meant to be a lightweight C++ header-only template library that cuVS relies on for the more fundamental / low-level utilities. Some examples of these are RAFT's device mdarray and mdspan objects; the RAFT resource object (raft::resource) that takes care of the stream ordering of device functions; linear algebra functions such as mapping, reduction, BLAS routines etc. A lot of the cuVS functions take the RAFT mdspan objects as arguments (for example raft::device_matrix_view). Therefore FAISS relies on both cuVS and RAFT. FAISS gets RAFT headers through cuVS and uses them to create the function arguments that can be consumed by cuVS. Note that we are not explicitly linking FAISS against raft::raft or raft::compiled. Only the required headers are included and compiled rather than compiling the whole RAFT shared library. This is the reason we still see mentions of raft in FAISS.

@tarang-jain tarang-jain marked this pull request as ready for review July 31, 2024 16:34
@asadoughi asadoughi self-assigned this Aug 6, 2024
@asadoughi
Copy link
Contributor

Hi @tarang-jain! Thanks for the PR. I quickly skimmed through the PR and noticed there are still a lot of references to RAFT. Is the plan to completely remove all references to RAFT and replace with cuVS? For example, try grep -r -nH -i raft . in your local checkout.

@tarang-jain
Copy link
Contributor Author

@asadoughi thanks for your comment. I have updated the PR description!

Copy link
Contributor

@asadoughi asadoughi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tarang-jain - thanks for the changes. I provided some comments inline.

.circleci/config.yml Outdated Show resolved Hide resolved
@@ -110,7 +110,7 @@ Several options can be passed to CMake, among which:
values are `ON` and `OFF`),
- `-DFAISS_ENABLE_PYTHON=OFF` in order to disable building python bindings
(possible values are `ON` and `OFF`),
- `-DFAISS_ENABLE_RAFT=ON` in order to enable building the RAFT implementations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about lines 9, 20-21, 27, 38-39? Will we have a faiss-gpu-cuvs package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally did not make changes to the docs (readme and install) because I thought that is something entirely under FAISS' governance. Don't want to modify that without approval from you guys. But to answer your question: yes it will be called faiss-gpu-cuvs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those lines reference packages distributed by the nvidia channel so if you have faiss-gpu-cuvs prepared we can coordinate the release.

@@ -41,13 +41,13 @@ def aa(*args, **kwargs):


group = parser.add_argument_group('benchmarking options')
aa('--raft_only', default=False, action='store_true',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run this before and after the change to determine the change (if any) in performance?

@@ -43,8 +43,8 @@ def aa(*args, **kwargs):
help='whether to benchmark add operation on GPU index')
aa('--bm_search', default=True,
help='whether to benchmark search operation on GPU index')
aa('--raft_only', default=False, action='store_true',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run this before and after the change to determine the change (if any) in performance?

faiss/gpu/CMakeLists.txt Show resolved Hide resolved
faiss/gpu/utils/CuvsUtils.h Show resolved Hide resolved
faiss/gpu/test/TestGpuDistance.cu Show resolved Hide resolved
faiss/gpu/test/TestGpuIndexIVFFlat.cpp Show resolved Hide resolved
faiss/gpu/impl/CuvsCagra.cu Outdated Show resolved Hide resolved
@asadoughi
Copy link
Contributor

Hi @tarang-jain - it looks like the test fails on https://github.com/facebookresearch/faiss/actions/runs/10587022390/job/29337315242#step:3:2446 related to a core dump. Are you able to debug the issue?

@facebook-github-bot
Copy link
Contributor

@asadoughi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@asadoughi
Copy link
Contributor

Regarding the segfault, consider rebasing off of the latest main to see if #3806 has an effect.

@tarang-jain
Copy link
Contributor Author

@asadoughi I was able to resolve the seg fault. It was related to some bugs in the cuvs parts of bfKnn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants