Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Numerical stability fixes for l2 pairwise distance (rapidsai#1319)
When computing L2 distance, we could sometimes see the distances go slightly negative. This is because of numerical instability, especially when computing self distance. For L2SqrtExpanded, this would end up taking the sqrt of this negative value - which introduced NaN values. Fix by clamping distances to 0. This matches the behaviour found in the fused_l2 distance calculation: https://github.com/rapidsai/raft/blob/3ca7eacc5cb411facdfb08ff27663a3402486bc4/cpp/include/raft/distance/detail/fused_l2_nn.cuh#L179 And is similar to that found in the sparse l2 distance calculation: https://github.com/rapidsai/raft/blob/3ca7eacc5cb411facdfb08ff27663a3402486bc4/cpp/include/raft/sparse/distance/detail/l2_distance.cuh#L84-L85 Authors: - Ben Frederickson (https://github.com/benfred) - Corey J. Nolet (https://github.com/cjnolet) Approvers: - Corey J. Nolet (https://github.com/cjnolet) URL: rapidsai#1319
- Loading branch information