POT icon indicating copy to clipboard operation
POT copied to clipboard

Precise GPU solvers?

Open Yura52 opened this issue 5 years ago • 4 comments

Hi! I am looking for replacements for the OpenCV solver.

My requirements are: (1) precise solver (i.e. Sinkhorn-like solvers is not an option) (2) GPU-acceleration (3) it is possible to pass custom cost matrix (or EMD is hardcoded) (4) ideally, with batched calculation

As far as I can see, ot.gpu offers only approximate solvers, right? If so, are you aware of any other projects that are relevant to my query? I realize that this is not a "POT issue", sorry for that, just don't know where to ask (Google doesn't help).

Yura52 avatar Oct 07 '20 08:10 Yura52

Hello,

I have a start of implementation that uses the fast exact solver on cpu but with a seamless cpu/gpu wrapper for torch. The actual solving is not done on GPU but i have found that the overhead is quite small in practice.

https://github.com/PythonOT/POT/tree/torch

I am not a aware of a true GPU opens source exact OT solver for the general emd problem (general cost function). Please tell us if you find one.

rflamary avatar Oct 07 '20 11:10 rflamary

https://github.com/PythonOT/POT/tree/torch

Thank you, I'll take a look.

for the general emd problem (general cost function)

I'd like to clarify (sorry for ambiguity): by "EMD" I mean the general Optimal Transport problem with a specific cost matrix that is formed by euclidean (not squared) distances (I refer to the terminology suggested somewhere by the author of [geomloss](https://www.kernel-operations.io/geomloss/api/pytorch-api.html; in terms of their APIs, I am looking for solvers with p=1). This is why "EMD is hardcoded" will also work for me.

P.S. Probably worth mentioning that gradients is also not a requirement, I am just looking for fast ways of optimal plans calculation.

Yura52 avatar Oct 07 '20 11:10 Yura52

Hi @Yura52 , sorry for delay. EMD can be solved with any type of cost matrix. As for mini-batch, I do not think it is possible to solve the exact OT problem in a batch setting. You can do batch (with stochastic descent) if you add some regularizations to the problem (thus leading to 'smoother' solutions) or consider a mini-batch strategy such as in this paper https://arxiv.org/pdf/1910.04091.pdf, but again the result will not be the exact OT distance/coupling....

ncourty avatar Oct 12 '20 22:10 ncourty

I mean a batch of independent optimal transport problems with inputs of the same dimensions.

As for EMD terminology, I still encounter different definitions, but I got your point :)

Yura52 avatar Oct 13 '20 09:10 Yura52