perf: reduce peak memory during cosine IVF-PQ index training#6016
Merged
wkalt merged 2 commits intolance-format:mainfrom Feb 26, 2026
Merged
perf: reduce peak memory during cosine IVF-PQ index training#6016wkalt merged 2 commits intolance-format:mainfrom
wkalt merged 2 commits intolance-format:mainfrom
Conversation
Two optimizations that together eliminate the transient 2x memory peak on the training sample during cosine-distance index builds: 1. Add `normalize_fsl_owned` that L2-normalizes a FixedSizeListArray in-place via `Buffer::into_mutable()` when the buffer is uniquely owned, avoiding a full copy. Falls back to the existing copy path when the buffer is shared. 2. Skip `arrow::compute::filter` when all vectors are already finite, avoiding another full copy of the training data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bc57006 to
2a505cd
Compare
Contributor
Author
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
wjones127
pushed a commit
to wjones127/lance
that referenced
this pull request
Mar 4, 2026
…ormat#6016) Two optimizations that together eliminate the transient 2x memory peak on the training sample during cosine-distance index builds: 1. Add `normalize_fsl_owned` that L2-normalizes a FixedSizeListArray in-place via `Buffer::into_mutable()` when the buffer is uniquely owned, avoiding a full copy. Falls back to the existing copy path when the buffer is shared. 2. Skip `arrow::compute::filter` when all vectors are already finite, avoiding another full copy of the training data. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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
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.

Two optimizations that together eliminate the transient 2x memory peak on the training sample during cosine-distance index builds:
Add
normalize_fsl_ownedthat L2-normalizes a FixedSizeListArray in-place viaBuffer::into_mutable()when the buffer is uniquely owned, avoiding a full copy. Falls back to the existing copy path when the buffer is shared.Skip
arrow::compute::filterwhen all vectors are already finite, avoiding another full copy of the training data.