fix knn_merge_parts for inner product - #2426
Conversation
divyegala
left a comment
There was a problem hiding this comment.
Hi @qwertyforce, thank you for the PR! I think this change will severely affect the binary size of cuVS, can you please provide a before-after measurement? Alternatively, we could run an element-wise operation to negate the inner product distances before running the merge kernel.
|
Hi! i ran ./build.sh libcuvs --allgpuarch --no-nvtx -n (GCC 13, CUDA 12.8) |
|
Thanks @qwertyforce , in that case can we please pursue the alternative of running a negation for inner product? |
|
Yes, will try to implement and benchmark it |
|
made a negation version, doesnt affect ivf search performance in multigpu index cuvs/cpp/src/neighbors/detail/tiered_index.cuh Lines 244 to 269 in 3937a7c also, as i understand, it is possible that other instances where knn_merge_parts is used could also be affected, for example (should probably be resolved in another pr) cuvs/cpp/src/neighbors/detail/sparse_knn.cuh Lines 317 to 375 in cd4bbab |
|
@viclafargue could you please take a look at whether this PR needs follow-on work, and if yes, capture it an issue? |
divyegala
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
|
/ok to test bb6d2df |
There was a problem hiding this comment.
Great catch! Thank you for identifying the issue and following through with a PR to fix it.
@divyegala There indeed is an other independently existing issue in the direct merge path that would deserve some work. I will directly open up a PR to fix this.
EDIT: Here is the PR : #2441.
|
/merge |
By default, when merging the results of sharded multigpu index, knn_merge_parts keeps K smallest values. But inner product is not a distance, it is a measure of similarity. Therefore results are wrong for IP.
In this PR we are adding an additional overload, that receives an argument select_min, we keep backward compatibility and add a new test