Skip to content

Implement Log Matmul #54064

@t-vi

Description

@t-vi

Edit: As discussed below, log matmul seems more acceptable

🚀 Feature

Implement GPU/CPU kernels for efficient regularized Wasserstein distance computation (Sinkhorn).

Motivation

The regularized Wasserstein distance between samples is a frequent metric used in various deep learning models.

One intuitive way to think about it is that it is a distance (in the underlying space)-aware alternative to KL divergence for measuring distances between probability measures.

In the time since Cuturi from 2013 and Frogner et al. from 2015, this has developed into a very useful general purpose tool. Recent notable applications using the Wasserstein distance include SwAV, but it is also of interest more generally to compare probability distributions or interpolate between them.

One key computational challenge is that stable implementation requires (more or less) a matrix multiplication using logsumexp instead of regular dot products, this is much easier to get with a custom kernel. (And logsumexp is much more stable than factoring out large scalars which has been proposed as a make-do stabilization.)

Pitch

I propose to implement a sinkhorn kernel.

Alternatives

Implement it a specialized library, but I think the applications are numerous and general enough to warrant inclusion into PyTorch proper.

Additional context

Related: #51777

Metadata

Metadata

Assignees

No one assigned

    Labels

    function requestA request for a new function or the addition of new arguments/modes to an existing function.module: distance functionstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy