Skip to content

Cuvs-Lucene-139: Fix GPU OOMs && Java Heap OOMs#141

Closed
nvzm123 wants to merge 2 commits into
NVIDIA:mainfrom
nvzm123:cuvslucene-139__zackm
Closed

Cuvs-Lucene-139: Fix GPU OOMs && Java Heap OOMs#141
nvzm123 wants to merge 2 commits into
NVIDIA:mainfrom
nvzm123:cuvslucene-139__zackm

Conversation

@nvzm123

@nvzm123 nvzm123 commented Apr 29, 2026

Copy link
Copy Markdown

GPU OOM fix:
Replaced usage of CuVSMatrix.deviceBuilder with usage of CuVSMatrix.hostBuilder instead. deviceBuilder was eagerly loading the full dataset to GPU. using hostBuilder gives responsibility to CAGRA as to how to optimally stream data from host memory to GPU.

Java Heap OOM fix:
Stream subsets of data during HNSW graph construction instead of trying to load the full dataset onto the Java Heap.

Note: this PR also includes the commit from cuvs-lucene-137 (#137)

EC2 Default User added 2 commits April 28, 2026 21:13
without loading the full set of data on the Java Heap, but instead allows us
to stream the set of data to the Java Heap.
@nvzm123 nvzm123 requested a review from a team as a code owner April 29, 2026 04:26
@copy-pr-bot

copy-pr-bot Bot commented Apr 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nvzm123

nvzm123 commented Apr 29, 2026

Copy link
Copy Markdown
Author

@narangvivek10 narangvivek10 added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Apr 30, 2026
int size,
int dimensions,
CuVSMatrix adjacencyListMatrix,
CuVSMatrix vectorDataset,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have createMultiLayerHnswGraph method just above this one, mainly differing in this parameter. Is there any strong reasoning behind having a copy of the method almost the same code? Can we not just modify the above to mainly change vectors param to vectorDataset?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

addressed in #173

builder.addVector(mergedVectors.vectorValue(it.index()));
}
CuVSHostMatrix dataset = builder.build();
writeFieldInternal(fieldInfo, dataset, size);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can derive size from dataset so is there a strong reasoning behind passing size as a separate primitive int parameter? Will there a situation where the size parameter's value will be different from dataset.size()?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

addressed in #173

* @param size number of vectors in the dataset
* @throws IOException
*/
private void writeFieldInternal(FieldInfo fieldInfo, CuVSHostMatrix dataset, int size)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar observation with the duplicated writeFieldInternal method and almost the same code as above, with mainly one parameter change from vectors to dataset.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

addressed in #173

CuVSMatrix.DataType.FLOAT);

// Add vectors one by one - builder copies directly to device memory
CuVSMatrix.hostBuilder( // was: CuVSMatrix.deviceBuilder(resources, ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This being part of Utils, maybe we can think of allowing the caller of this method to choose between host or device in case it is needed anywhere in the future?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

addressed in #173

repeating a comment on that PR here:
Utils host/device flexibility — the CuVSResources parameter on the
matrix builders was unused after the switch to hostBuilder, so it's
removed, and the docs that still referred to "device memory" are corrected.
Removing it updated call sites in CuVS2510GPUVectorsWriter and the
binary/scalar quantized writers. Making the builders fully
host/device-selectable seems broader than this PR — device construction
still exists directly in CuVS2510GPUVectorsReader, so a proper
host/device-aware API would want to account for that. Would you prefer I
file a separate issue to track it, or leave it until something actually
needs device-side construction through these helpers? Happy either way.

@nvzm123

nvzm123 commented Jul 2, 2026

Copy link
Copy Markdown
Author

closing because superseded by #173

@nvzm123 nvzm123 closed this Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants