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

Fix a bug with excess RAM usage during vector computes. #1195

Merged
merged 3 commits into from
Feb 29, 2024
Merged

Conversation

nsthorat
Copy link
Contributor

Vector stores now return Iterators of np.array vectors.

flat_vector_keys = [key for vector_keys in all_vector_keys for key in (vector_keys or [])]
all_vectors = self._vector_store.get(flat_vector_keys)
all_vectors = iter(self._vector_store.get(flat_vector_keys))
Copy link
Contributor

Choose a reason for hiding this comment

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

don't think you need the iter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, no longer needed. was using islice but simplified it.


for loc_chunk in chunks(locs, HNSW_RETRIEVAL_BATCH_SIZE):
chunk_items = np.array(self._index.get_items(loc_chunk), dtype=np.float32)
for vector in np.split(chunk_items, chunk_items.shape[0]):
Copy link
Contributor

Choose a reason for hiding this comment

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

probably simpler/shorter:

for i in range(chunk_items.shape[0]):
  yield chunk_items[i]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to use split here since it doesn't make a copy

@nsthorat nsthorat merged commit 5d84c76 into main Feb 29, 2024
4 checks passed
@nsthorat nsthorat deleted the nik-conc-iter branch February 29, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants