-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Avoid multiple in-memory copies of Vector Data #134048
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/ESGpuHnswVectorsWriter.java
# Conflicts: # x-pack/plugin/gpu/src/main/java/org/elasticsearch/xpack/gpu/codec/ESGpuHnswVectorsWriter.java
… vector count/mmap availability conditions
…rch into optimize-write-field
… vector count/mmap availability conditions
| } | ||
| } | ||
|
|
||
| public static IndexOutput getVectorDataIndexOutput(FlatVectorsWriter flatVectorWriter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be called getQuantizedVectorDataIndexOutput and below method getVectorDataIndexOutput?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we build the Cagra index using a GPU, we need to copy vector data to GPU memory.
We want to optimize this scenario, or better, we want to avoid wasteful use of memory.
Currently, vector data is held
Some host-memory copies are probably necessary: when data is transferred from host to GPU memory it needs to be as a
MemorySegmentholding the 2D data as contiguous rows.To improve on the current situation we can:
a. get rid of the on-heap copy; instead of using a
FlatFieldVectorsWriter<float[]>, we used something that stores data to a MemorySegment directly (instead of a List of float[])b. get rid of the native memory copy: we use the on-disk data and memory-map that file, so that a copy happens between the mmap file and GPU memory. Since we have just flushed the vector data, it is likely the mmapped data is still in the process memory
c. get rid of the native memory copy: we copy data directly from on-heap memory to GPU memory; this is technically possible but currently it is a non-optimized scenario and unsupported scenario in cuvs-java (even if we have plan to cover it), so it will be work for a follow-up PR.
This PR implements (b)