Scalable Approximation Algorithms for $p$-Wasserstein Distance and Its Variants

Nathaniel Lahn, Sharath Raghvendra, Emma Saarinen, Pouyan ShirzadianICML 2025

Introduction

The $p$-Wasserstein distance—often conceptualized as Optimal Transport or the "Earth Mover's Distance"—is a powerful mathematical tool for comparing probability distributions. It measures the minimum cost to transform one distribution into another, where the cost of moving a unit of mass is defined as the ground distance raised to the power of $p$.

While the $1$-Wasserstein distance ($p=1$) benefits from fast, scalable approximation algorithms, the $p$-Wasserstein distance for $p \ge 2$ is widely preferred in machine learning and computer vision because it better captures geometric similarity. However, this paper addresses two massive hurdles that arise when $p \ge 2$:

  1. Lack of scalable algorithms: Fast algorithms for $p=1$ rely on the fact that the cost function is a metric (satisfying the triangle inequality). For $p \ge 2$, the cost $d(x,y)^p$ is no longer a metric, which breaks standard tree-embedding approximation techniques.
  2. Extreme noise sensitivity: The $p$-Wasserstein distance is highly sensitive to outliers. A tiny amount of noise (e.g., $\delta$ mass) can artificially inflate the distance by $\delta^{1/p}$.

This paper breaks through these barriers by introducing a near-quadratic time $O(\log n)$-approximation algorithm using multiple tree embeddings, alongside a highly scalable $O(n^2/\delta^3)$ algorithm for a noise-resistant variant of the metric.

Algorithmic Innovations

The authors tackle the open challenge of designing fast, near-quadratic time approximation algorithms for $p \ge 2$ that can handle arbitrary metric spaces. They propose two distinct algorithmic frameworks:

1. Relative Approximation via Multiple Tree Embeddings

To approximate the standard $p$-Wasserstein distance, the authors adapt Hierarchically Well-Separated Trees (HSTs). Embedding a metric into a single tree introduces distortion, which is disastrous for $p \ge 2$ due to its inherent noise sensitivity.

To solve this, the authors introduce the "Minimum of Trees" trick. They construct $p$ independent HSTs and define a new tree-based distance by taking the minimum edge cost across all $p$ trees for any pair of points. By always trusting the "tightest" distance estimate, the distortion is stabilized enough to achieve a bounded $O(\log n)$ approximation. To compute the optimal transport plan over this new distance, they design a primal-dual (Hungarian) algorithm supercharged by a custom dynamic weighted Bichromatic Closest Pair (BCP) data structure.

2. Additive Approximation via Robust Partial Wasserstein (RPW)

The authors first prove a negative result: computing a standard additive approximation for $p$-Wasserstein is computationally bottlenecked at $\Omega(n^2/\delta^p)$ due to its sensitivity to noise.

To bypass this hard computational barrier, they target a recently introduced noise-resistant variant called the $(p, k)$-Robust Partial Wasserstein (RPW) distance. The RPW distance allows a small fraction of mass to be ignored to account for outliers. The authors adapt the LMR (Gabow-Tarjan) algorithm by scaling the problem space to integers and stopping the algorithm early. This exploits the fact that optimal transport algorithms route the vast majority of mass very quickly, spending most of their runtime on a tiny residual fraction.

Empirical Performance and Results

The authors evaluated their algorithms empirically using synthetic stochastic datasets (samples drawn from uniform and truncated normal distributions inside a 10-dimensional unit hypercube).

Key Theoretical and Empirical Results: * Theoretical Speedups: The relative approximation algorithm computes an $O(\log n)$-approximation of the $p$-Wasserstein distance in $\tilde{O}(n^2)$ time—specifically $O(n^2 \log U \log \Delta \log n)$. Meanwhile, the additive approximation algorithm for the RPW distance runs in $O(n^2/\delta^3)$ time. Crucially, this RPW runtime is completely independent of $p$. * Empirical Efficiency: In practice, the BCP data structure operations in the relative algorithm scale at roughly $O(n^{1.5})$, significantly outperforming the theoretical worst-case bound of $O(n^2)$. * RPW Superiority: The proposed RPW algorithm drastically outperforms the existing state-of-the-art (LMR-RPW), especially as $p$ increases (e.g., $p=4$) or as the error tolerance $\delta$ becomes smaller.

Limitations and Future Directions

While the paper presents major steps forward for optimal transport scalability, the authors note a few limitations:

  • Exponential dependence on $p$: Although the relative approximation algorithm bounds the expected distortion to $O(\log n)$, the hidden constant scales exponentially with $p$ (specifically $O((4 \log n)^p)$). This makes the tree-embedding approach less practical for very large values of $p$.
  • Memory Overhead: The space complexity of the dynamic BCP data structure is $O(pn \log \Delta)$. While this can theoretically be optimized to $O(pn)$, it still requires non-trivial memory overhead for large datasets.
  • Lack of Real-World Benchmarks: The empirical evaluations are currently limited to synthetic 10-dimensional data. Testing these algorithms on real-world, high-dimensional datasets—such as image embeddings or NLP word vectors—remains an important area for future work.

Summary updated

BibTeX
@inproceedings{lahn2025scalable,
  author = {Nathaniel Lahn and Sharath Raghvendra and Emma Saarinen and Pouyan Shirzadian},
  title = {{Scalable Approximation Algorithms for $p$-Wasserstein Distance and Its Variants}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=5YXzrcchMu},
}
Figure