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

[BUG] Cagra index search segfaults for vectors with 1024+ dimensions #1948

Closed
Ngalstyan4 opened this issue Nov 1, 2023 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Ngalstyan4
Copy link

Ngalstyan4 commented Nov 1, 2023

Describe the bug
Cagra index creation via the CPP api (cagra::build) seems to succeed for vectors of dimension 1025 but search (cagra::search) results in a Segmentation Fault.

The issues exists both in the cuda API and in the runtime API of cagra.

Steps/Code to reproduce bug

Change this line in cagra example to int64_t n_dim = 1025;, compile and run. This should cause a segmentation fault.

To test on the runtime API, use raft::runtime::neighbors::cagra::{build, search} in place of raft::neighbors::cagra::{build, search}.

Expected behavior
Expected the index creation and search to succeed without any issues, as it does for smaller dimensional vectors.

Environment details (please complete the following information):

  • Environment location: GCP, Debian 11, Cuda compilation tools, release 12.2, V12.2.140, Tesla V100-SXM2-16GB
  • Method of RAFT install: install from source

Additional context
This is important because OpenAI embeddings are 1536 dimensional. There are many other models that produce 1024+ dimensional embeddings.

The fix might be as simple as adding an element to this array but I have not tried it.

@cjnolet
Copy link
Member

cjnolet commented Nov 8, 2023

@Ngalstyan4 CAGRA CUDA kernels are templated on the dataset dimension and we need to define a new template argument for larger dimensions.

Some of these RAG embeddings go up to extremely large numbers of dimensions. Any specific range you'd are targeting or just as high as we can go?

@Ngalstyan4
Copy link
Author

1536 dimensional openai embeddings are probably most widely used these days, so having support for that out of the box would be the primary ask.

It would also be great to throw an informative error when the templates are used with unsupported vector sizes instead of segfaulting, as it happens now.

@cjnolet
Copy link
Member

cjnolet commented Nov 8, 2023

It would also be great to throw an informative error when the templates are used with unsupported vector sizes instead of segfaulting, as it happens now.

Totally agree witht his. We're going to prioritize this, and do a PoC to at least enable 1536 in the meantime. We can work our way up to even higher dimensions depending on the perf of enabling 1536. For example, it might take some significant improvements to the CUDA kernels to support 4096 dims, but we'll know once we dive in.

@narangvivek10
Copy link
Contributor

While integrating CAGRA into Lucene, I ran into this issue as well. It seems that dimensions of more than 1024 segfaults while running search. Here is how we encountered this issue.

rapids-bot bot pushed a commit that referenced this issue Dec 8, 2023
This PR updates the CAGRA search implementation to support 1024+ dim vectors.
For 1024+ dim vectors, the distance between a vector and the query vector is calculated by splitting the vector into multiple 1024 dim vectors and accumulating the distances of each sub-vector.

Rel: #1948

Authors:
  - tsuki (https://github.com/enp1s0)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1994
@cjnolet cjnolet moved this from Todo to Done in VS/ML/DM Primitives Release Board Jan 12, 2024
@cjnolet cjnolet closed this as completed Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

4 participants