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

[WIP] Faster backend compatible ot.dist #701

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

rflamary
Copy link
Collaborator

@rflamary rflamary commented Nov 27, 2024

Types of changes

The current implementation of ot.dist uses the cdist foncton form sipy on non euclidean costs which makes it very slow. This PR is an attempt at making it faster by implementing the most common distances using the backend.

For the moeme,t backend computation are ot always faster

for instanec on a 1024x200 matrix X we have
n= 1024 , d= 200

cdist (scipy) dist 0.9.5 ot.dist (numpy) dist (torch) dist (torch, ten) dist (torch,GPU)
euclidean 0.942832 0.0836014 0.0897373 0.0932314 0.00872684 0.429742
sqeuclidean 0.798189 0.0778745 0.0659651 0.00911853 0.0744656 0.00241347
cityblock 1.2758 1.26534 6.4717 0.42605 2.14289 0.0770559
cosine 0.971009 0.970279 0.473443 0.0740105 0.00881105 0.00222607
minkowski 0.847159 0.843644 6.97861 0.614996 3.37625 0.0993479
correlation 1.01531 1.01237 0.0785626 0.0948708 0.012194 0.00431579

Motivation and context / Related issue

How has this been tested (if it applies)

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 10 lines in your changes missing coverage. Please review.

Project coverage is 97.02%. Comparing base (1761d0b) to head (3be92a4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #701      +/-   ##
==========================================
- Coverage   97.05%   97.02%   -0.03%     
==========================================
  Files          98       98              
  Lines       19955    20008      +53     
==========================================
+ Hits        19367    19413      +46     
- Misses        588      595       +7     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant