Implement GPU IVF add_preassigned via add_core (implement #3908)#5372
Open
weiwch wants to merge 4 commits into
Open
Implement GPU IVF add_preassigned via add_core (implement #3908)#5372weiwch wants to merge 4 commits into
weiwch wants to merge 4 commits into
Conversation
Contributor
|
@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D111188416. |
Contributor
|
Thanks for this change! |
Contributor
Author
|
I hadn’t used preassigned GpuIndexIVFPQ in my own project before, so I hadn’t tested it or added a test covering that flow. I’ll add a small test soon. |
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.
Summary
This implements GPU IVF support for
ivf_tools.add_preassigned, addressing #3908.GPU IVF already supports
search_preassigned, butivf_tools.add_preassignedpreviously only worked for CPU IVF indexes because GPU IVF did not expose the correspondingadd_corepath. This implements the follow-up I mentioned in #3908 by refactoring my earlier faiss_preassigned work into the mainline-compatibleadd_corepath. This PR addsGpuIndexIVF::add_core(...), wires precomputed IVF list ids through the existing GPU add paging/copy path, and makes the existingivf_tools.add_preassignedhelper work for GPU IVF indexes without any change ofivf_tools.py.The implementation follows the CPU IVF design:
GpuIndexIVF::add_core(...)with the same naming and argument order asIndexIVF::add_core(...)precomputed_idxthrough the existing GPU add paging/copy pathIVFBase::addVectorsPreassigned(...)for appending vectors to precomputed IVF listscontrib.ivf_tools.add_preassignedcan now callindex_ivf.add_core(...)for both CPU and GPU IVF indexes. Compared with my earlier fork implementation, this does not introduce separate GPU-specificadd_preassigned*APIs; the naming and entry point are aligned with the existing CPU IVF API.Implementation note
GpuIndex::addPaged_andaddPaged_ex_were moved fromprivatetoprotectedsoGpuIndexIVF::add_core(...)can reuse the existing GPU add paging path.Tests
Added a GPU IVFFlat add-preassigned test that:
ivf_tools.add_preassignedsearch_preassigned