Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems

Bernhard Schmitzer

Introduction

Optimal transport (OT) is a classical optimization problem dating back to the seminal work of Monge and Kantorovich (see monographs for introduction and historical context). The induced Wasserstein distances lift a metric from a ‘base’ space (X,d)(X,d) to probability measures over XX. This is a powerful analytical tool, for example to study PDEs as gradient flows in Wasserstein space . With the increase of computational resources, OT has also become a popular numerical tool in image processing, computer vision and machine learning (e.g. ).

Many ideas have been presented to extend Wasserstein distances to general non-negative measures. We refer to and references therein for some context. A transport-type distance for general multi-channel signals is proposed in .

Computational Optimal Transport

To this day, the computational effort to solve OT problems remains the principal bottleneck in many applications. In particular large problems, or even multi-marginal problems, remain challenging both in terms of runtime and memory demand.

For the linear assignment problem and discrete transport problems there are (combinatorial) algorithms based on the finite dimensional linear programming formulation by Kantorovich, such as the Hungarian method , the auction algorithm , the network simplex and more . Typically, they work for (almost) arbitrary cost functions, but do not scale well for large, dense problems. On the other hand, there are more geometric solvers, relying on the polar decomposition , that tend to be more efficient. There is the famous fluid dynamic formulation by Benamou and Brenier , explicit computation of the polar decomposition , semi-discrete solvers , and solvers of the Monge-Ampère equation among many others. However, these only work on very specific cost functions, most notably the squared Euclidean distance. In a compromise between efficiency and flexibility, several discrete coarse-to-fine solvers have been proposed that adaptively select sparse sub-problems .

Entropy Regularization for Optimal Transport

In entropy regularization of the linear assignment problem is considered to allow application of smooth optimization techniques or the Sinkhorn matrix scaling algorithm . For sufficiently small regularization the true optimal assignment can be extracted from the approximate solution. For increased numerical stability, the Sinkhorn algorithm is also reformulated in the log-domain. Similarly, in the Sinkhorn algorithm is applied to solve an entropy regularized approximation of the discrete optimal transport problem. It is demonstrated that for moderate regularization strengths the algorithm is trivial to parallelize, easy to implement on GPUs and fast. Besides, it is shown that moderate regularization can actually be beneficial for classification applications. Regularization also makes the optimization problem more well-behaved (e.g. uniqueness of optimal coupling, optimal objective differentiable as function of marginal distributions), which led to the first practical numerical method for approximate computation of Wasserstein barycenters . Today, this approach is widely used, for instance .

More recently, the Sinkhorn algorithm has been extended to more general transport-type problems, such as multi-marginal problems and direct computation of Wasserstein barycenters , gradient flows and unbalanced transport problems , resulting in a family of Sinkhorn-like diagonal scaling algorithms.

Convergence Speed of Sinkhorn Algorithm

In the convergence rate of the Sinkhorn algorithm is studied for positive kernel matrices, yielding a global linear convergence rate of the marginals in terms of Hilbert’s projective metric. However, applied to entropy regularized optimal transport, the contraction factor tends to one exponentially, as the regularization approaches zero. Thus, running the algorithm with this particular measure of convergence is often not practically feasible. In the local convergence rate of the Sinkhorn algorithm near the solution is examined, based on a linearization of the iterations. This bound is tighter and more accurately describes the behaviour of the algorithm close to convergence. But these estimates do not apply when one starts far from the optimal solution, which is the usual case for small regularization parameters. In a comparison is made between the Sinkhorn algorithm and the auction algorithm. In particular the role of the entropy regularization parameter is related to the slack parameter ε\varepsilon of the auction algorithm and it is pointed out that convergence of both algorithms becomes slower, as these parameters approach zero (but small parameters are required for good approximate solutions). For the auction algorithm this can provably be remedied by ε\varepsilon-scaling, where the ε\varepsilon parameter is gradually decreased during optimization. Analogously, it is suggested to gradually decrease entropy regularization during the Sinkhorn algorithm to accelerate optimization. Consequently, in the following we will also refer to the entropy regularization parameter as ε\varepsilon and to the gradual reduction scheme as ε\varepsilon-scaling. The ideas of are refined in . In particular, the latter proves convergence of a modified algorithm with ‘deformed iterations’ where ε\varepsilon is gradually decreased during the iterations, similar to ε\varepsilon-scaling. They show that the primal iterate converges to the unregularized solution if the decrease is sufficiently slow. Unfortunately, the number of iterations to reach a given value of ε\varepsilon increases exponentially, as ε\varepsilon decreases. Thus it is “mostly interesting from the theoretical point of view” [43, p. 8].

Limitations of Entropic Transport

Despite its considerable merits, there are some fundamental constraints to the naive entropy regularization approach. Entropy introduces some blur in the optimal assignment. While this may sometimes be beneficial (see above), in many applications it is considered a nuisance (e.g. it quickly smears distinct features in gradient flows), and one would like to run the scaling algorithm with as little regularization as possible. However, a standard implementation has some major numerical limitations, becoming increasingly severe as the regularization approaches zero. The diagonal scaling factors diverge in the limit of vanishing regularization, leading to numerical overflow and instabilities. Moreover, the algorithm requires an increasing number of iterations to converge. In practice this can often be remedied by ε\varepsilon-scaling, but its efficiency is not yet well understood theoretically. Therefore, numerically this limit is difficult to reach. In addition, naively storing the dense kernel matrix requires just as much memory as storing the full cost matrix in standard linear programming solvers and multiplications with the kernel matrix become increasingly slow. Thus, effective heuristics to avoid storing of, and multiplication by, the dense kernel matrix have been conceived, such as efficient Gaussian convolutions or approximation by a pre-factored heat kernel . However, these remedies only work for particular (although relevant) problems, and do not solve the issues of blur and diverging scaling factors.

2 Contribution and Outline

In Section 2 we recall the framework for transport-type problems and corresponding scaling algorithms for their entropy regularized counterparts, as put forward in . The main contributions of this article are twofold: In Section 3 we propose to combine four modifications of the Sinkhorn algorithm to address issues with numerical instability, slow convergence and large kernel matrices. In Section 4 a new convergence analysis for the Sinkhorn algorithm is derived, based on an analogy to the auction algorithm. The two sections can be read independently from each other. The modifications used in Section 3 are:

Section 3.1: A log-domain stabilization of the Sinkhorn algorithm, as described in . It allows to numerically run the algorithm at small regularizations while largely retaining the simple matrix scaling structure.

Section 3.2: The well-known ε\varepsilon-scaling heuristic, to reduce the number of required iterations.

Section 3.3: Sparsification of the kernel matrix by adaptive truncation, to reduce memory demand and accelerate iterations. We quantify the error induced by truncation and propose a truncation scheme which reliably yields small error bounds that are easy to evaluate. While truncation has been proposed elsewhere (e.g. ), to the best of our knowledge the present article gives the first concrete bounds for the inflicted error.

Section 3.4: A multi-scale scheme, inspired, for instance, by . This serves two purposes: First, it allows for a more efficient computation of the truncated kernel. Second, we propose to combine the coarse-to-fine approach with simultaneous ε\varepsilon-scaling, which drastically reduces the number of variables during early stages of ε\varepsilon-scaling, without losing significant precision.

We emphasize that each modification builds on the previous ones (see Remark 5.1) and only combining all four leads to an algorithm that can solve large problems with significantly less runtime, memory and regularization, as compared to the naive algorithm. The adaptations extend to the more general scaling algorithms for transport-type problems presented in .

In Section 4 we develop a new convergence analysis of the Sinkhorn algorithm, based on analogy to the auction algorithm, different from the Hilbert metric approach of . The structure of Section 4 is:

Section 4.1: The classical auction algorithm for the linear assignment problem is recalled.

Section 4.2: A slightly modified asymmetric variant of the Sinkhorn algorithm is given and a bound is derived for the number of iterations until a prescribed accuracy is reached. As for the auction algorithm, for fixed ε\varepsilon the maximal number of iterations scales as O(1/ε)\mathcal{O}(1/\varepsilon). This is in good agreement with numerical experiments (cf. Section 5.2). To avoid the difficulties with slow convergence in Hilbert’s projective metric (cf. Section 1.1) we choose a weaker, but reasonable, measure of convergence (cf. Remark 4.13).

Section 4.3: We prove stability of optimal dual solutions of entropy regularized OT under changes of the regularization parameter. This also implies stability of dual solutions in the limit of vanishing regularization and therefore complements results of (see also Remark 4.17).

Section 4.4: Our eventual goal is a better theoretical understanding of the ε\varepsilon-scaling heuristic and its efficiency. We show that the above stability result is an important step and discuss missing steps for a full proof. To our knowledge (with the exception of , see above), these are the first theoretical results towards ε\varepsilon-scaling for the Sinkhorn algorithm.

Numerical experiments confirm the efficiency of the modified algorithm (Section 5.2). Examples for unbalanced optimal transport, barycenters, and Wasserstein gradient flows illustrate that the modified algorithms retain the versatility of the diagonal scaling algorithms presented in (Section 5.3).

3 Notation and Preliminaries

We assume that the reader has a basic knowledge of convex optimization, such as convex conjugation, Fenchel–Rockafellar duality and primal-dual gaps (cf. ).

For Sect. 4 we require the following Lemma.

The first line follows immediately from 0≤exp⁡(a(z)/ε)≤exp⁡(max⁡a/ε)0\leq\exp(a(z)/\varepsilon)\leq\exp(\max a/\varepsilon). Line three then follows from min⁡(a−b)≤max⁡(a)−max⁡(b)≤max⁡(a−b)\min(a-b)\leq\max(a)-\max(b)\leq\max(a-b). The second and fourth line are implied by softmin⁡(a,ε)=−softmax⁡(−a,ε)\operatorname*{softmin}(a,\varepsilon)=-\operatorname*{softmax}(-a,\varepsilon).

Entropy Regularized Transport-Type Problems and Diagonal Scaling Algorithms

Recently it has been proposed to replace the constraints PXπ=μ\textnormal{P}_{X}\pi=\mu and PYπ=ν\textnormal{P}_{Y}\pi=\nu by soft constraints. This allows meaningful comparison between measures of different total mass. Such formulations were studied e.g. in (see also for more context). A particularly relevant choice for the soft constraints is the Kullback–Leibler divergence. A corresponding ‘unbalanced’ transport problem is given by

where λ>0\lambda>0 is a weighting parameter. Note that neither μ\mu, ν\nu nor π\pi need to be probability measures in this case and each may have different total mass.

one obtains the Wasserstein–Fisher–Rao (WFR) distance (or Hellinger–Kantorovich distance), introduced independently and simultaneously in . WFR is the length distance induced by GHK .

Problems (2.1) and (2.2) share a common structure: in both we optimize over non-negative measures π\pi on the product space X×YX\times Y, there is a linear cost term ⟨c,π⟩\left\langle c,\pi\right\rangle and two functions act on the marginals of π\pi. They are prototypical examples of a family of transport-type optimization problems with a common functional structure that was introduced in . The general structure is given in the following definition.

The indicator function ι≤c(PX⊤ α+PY⊤ β)\iota_{\leq c}(\textnormal{P}_{X}^{\top}\,\alpha+\textnormal{P}_{Y}^{\top}\,\beta) denotes the classical optimal transport dual constraint α(x)+β(y)≤c(x,y)\alpha(x)+\beta(y)\leq c(x,y) for all (x,y)∈X×Y(x,y)\in X\times Y (see Section 1.3).

This family also covers Wasserstein gradient flows and the structure can be extended to multiple couplings to describe barycenter and multi-marginal problems (see for details). As indicated, the standard optimal transport problem (2.1) is obtained as a special case.

Problem (2.1) is a special case of Def. 2.1 with FX:=ι{μ}F_{X}:=\iota_{\{\mu\}} and FY:=ι{ν}F_{Y}:=\iota_{\{\nu\}}. The primal and dual functional are given by:

Likewise, we can proceed for the unbalanced transport problem (2.2).

Problem (2.2) is a special case of Def. 2.1 with FX:=λ⋅KL⁡(⋅∣μ)F_{X}:=\lambda\cdot\operatorname{KL}(\cdot|\mu) and FY:=λ⋅KL⁡(⋅∣ν)F_{Y}:=\lambda\cdot\operatorname{KL}(\cdot|\nu). The primal and dual functional are given by:

2 Entropy Regularization and Diagonal Scaling Algorithms

with the convention exp⁡(−∞)=0\exp(-\infty)=0. KK is called the kernel associated with cc and the regularization parameter ε\varepsilon. For convenience we formally introduce the function

We obtain the regularized equivalent to Def. 2.1.

Primal optimizers π†\pi^{\dagger} have the form

where (α†,β†)(\alpha^{\dagger},\beta^{\dagger}) are dual optimizers. Conversely, for dual optimizers (α†,β†)(\alpha^{\dagger},\beta^{\dagger}), π†\pi^{\dagger} constructed as above is primal optimal .

Intuitively we see the relation between (2.4) and (2.10) as ε→0\varepsilon\to 0. For example, the term \varepsilon\,\operatorname{KL}^{\ast}\big{(}[\textnormal{P}_{X}^{\top}\alpha+\textnormal{P}_{Y}^{\top}\beta]/\varepsilon\big{|}K\big{)} in (2.10b) can be interpreted as a smooth barrier function for the dual constraint PX⊤α+PY⊤β≤c\textnormal{P}_{X}^{\top}\alpha+\textnormal{P}_{Y}^{\top}\beta\leq c in (2.4b). We refer to Sect. 1.1 for references to rigorous convergence results.

Under suitable assumptions problem (2.10b) can be solved by alternating optimization in α\alpha and β\beta (see for details). For fixed β\beta, consider the KL⁡∗\operatorname{KL}^{\ast}-term:

Note that the last term is constant w.r.t. α\alpha. Therefore, optimizing (2.10b) over α\alpha, for fixed β\beta corresponds to maximizing

This is a proximal step of FXF_{X} for the KL⁡\operatorname{KL} divergence with step size 1/ε1/\varepsilon (see Def. 1.2). So, by using the PD-optimality conditions between (2.12) and (2.13) (see e.g. [4, Thm. 19.1]), for a given β\beta the primal optimizer σ†\sigma^{\dagger} of (2.13) and the dual optimizer α†\alpha^{\dagger} of (2.12) are given by

Analogously, optimization w.r.t. β\beta for fixed α\alpha is related to KL⁡\operatorname{KL} proximal steps of FYF_{Y}. Starting from some initial β(0)\beta^{(0)}, we can iterate alternating optimization to obtain a sequence β(0),α(1),β(1),α(2),…\beta^{(0)},\alpha^{(1)},\beta^{(1)},\alpha^{(2)},\ldots as follows:

The algorithm becomes somewhat simpler when it is formulated in terms of the effective variables

For more convenient notation we introduce the proxdiv operator of a function FF and step size 1/ε1/\varepsilon:

The primal-dual relation (2.11) then becomes π†=diag⁡(u†) K diag⁡(v†)\pi^{\dagger}=\operatorname{diag}(u^{\dagger})\,K\,\operatorname{diag}(v^{\dagger}), which is why uu and vv are often referred to as diagonal scaling factors.

Throughout this article, we will refer to the arguments of the dual functionals (2.4b) and (2.10b) as dual variables and denote them with (α,β)(\alpha,\beta). The effective, exponentiated variables, introduced in (2.16), will be denoted by (u,v)(u,v) and referred to as scaling factors.

For future reference let us state the full scaling algorithm.

The stopping criterion is typically a bound on the primal-dual gap between dual iterates (α,β)=ε log⁡(u,v)(\alpha,\beta)=\varepsilon\,\log(u,v) and primal iterate π=diag⁡(u) K diag⁡(v)\pi=\operatorname{diag}(u)\,K\,\operatorname{diag}(v), an error bound on the marginals of π\pi (for standard optimal transport) or a pre-determined number of iterations.

With alternating iterations (2.15) or (2.18) a large family of functionals of form (2.10a) can be optimized, as long as the KL⁡\operatorname{KL} proximal steps of FXF_{X} and FYF_{Y} can be computed efficiently. A particularly relevant sub-family is, where FXF_{X} and FYF_{Y} are separable and are a sum of pointwise functions. Then the KL⁡\operatorname{KL} steps decompose into pointwise one-dimensional KL⁡\operatorname{KL} steps, see [14, Section 3.4] for details.

Since Section 4 focusses on the special case of entropy regularized optimal transport, let us explicitly state the corresponding functional and iterations.

The proximal steps of FXF_{X} and FYF_{Y} are trivial (if KK has non-empty columns and rows) and we recover the famous Sinkhorn iterations:

Stabilized Sparse Multi-Scale Algorithm

Throughout this section we combine four adaptions to the Algorithm 1 to overcome the limitations of a naive implementation outlined in Section 1.1.

When running Algorithm 1 with small regularization parameter ε\varepsilon, entries in the kernel KK, and the scaling factors uu and vv may become both very small and very large, leading to numerical difficulties. However, under suitable conditions (e.g. standard optimal transport, finite cost function) it can be shown that the optimal dual variables (α,β)(\alpha,\beta) remain finite and have a stable limit as ε→0\varepsilon\to 0 (, see also Remark 4.17). In and others it was proposed to formulate the Sinkhorn iterations directly in terms of the dual variables, instead of the scaling factors. For example, an update of α\alpha would be performed as follows:

As an alternative, we employ the redundant parametrization of the iterations as proposed in. The scaling factors (u,v)(u,v), (2.16), are written as

Analogous to the function getK\textnormal{get}K, (2.9), we define the stabilized kernel as

The second line, (3.3b), should be used for numerical evaluation such that extreme values in (α,β)(\alpha,\beta) and cc can cancel before exponentiation. Moreover, we introduce a stabilized version of the proxdiv operator:

Note that the regular version of the proxdiv operator, (2.17), is a special case of the stabilized variant with γ=0\gamma=0. With K=getK(ε)K=\textnormal{get}K(\varepsilon) and K=getK(α^,β^,ε)\mathcal{K}=\textnormal{get}\mathcal{K}(\hat{\alpha},\hat{\beta},\varepsilon) we observe that

For a threshold parameter τ>0\tau>0 we formally state the stabilized variant of Algorithm 1.

In the definitions for the stabilized kernel, (3.3b), and proxdiv-operator, (3.4), there still appear exponentials of the form exp⁡(⋅/ε)\exp(\cdot/\varepsilon), which may explode as ε→0\varepsilon\to 0. Extending the max⁡\max-argument trick in (3.1) to more general scaling algorithms entails similar questions. In the examples studied in Section 5 and those given in we find however, that evaluation of the exponential exp⁡(−γ/ε)\exp(-\gamma/\varepsilon) can be avoided. For the special case of standard optimal transport ε\varepsilon no longer appears in the stabilized step.

2 ε𝜀\varepsilon-Scaling

It is empirically and theoretically well-known (cf. Section 1.1) that convergence of Algorithm 1 becomes slow as ε→0\varepsilon\to 0. A popular heuristic remedy is the so-called ε\varepsilon-scaling, where one subsequently solves the regularized problem with gradually decreasing values for ε\varepsilon. Let E=(ε1,ε2,…,εn)\mathcal{E}=(\varepsilon_{1},\varepsilon_{2},\ldots,\varepsilon_{n}) be a list of decreasing positive parameters. We extend Algorithm 2 as follows:

The dual variable β\beta is kept constant while changing ε\varepsilon, not the scaling factor vv, because the optimal dual variables (α,β)(\alpha,\beta) usually have a stable limit as ε→0\varepsilon\to 0, while the scaling factors (u,v)(u,v) diverge (see Sect. 1.1 and also Theorem 4.16).

So far, very little is known theoretically about the behaviour of ε\varepsilon-scaling for the Sinkhorn algorithm (cf. Section 1.1). Empirically, it is shown in Sect. 5.2 that ε\varepsilon-scaling is highly efficient and the number of required iterations does not increase exponentially. We observe that indeed it behaves similar as in the auction algorithm, as discussed in . We work towards a theoretical quantification of this in Sect. 4.

Motivated by this, in practice we recommend a geometric decrease of ε\varepsilon and choose εk=ε0⋅λk\varepsilon_{k}=\varepsilon_{0}\cdot\lambda^{k} such that εn\varepsilon_{n} is the desired final value, ε0\varepsilon_{0} is on the order of the maximal values in the cost function cc and λ∈(0,1)\lambda\in(0,1) is a geometric scaling factor, typically in [0.5,0.75][0.5,0.75]. If λ\lambda is too small, iterations will start far from convergence after each change of ε\varepsilon, increasing the risk of numerical instabilities and requiring more iterations. On the other hand, if λ\lambda is too large, many stages of ε\varepsilon-scaling have to be performed, increasing numerical overhead.

3 Kernel Truncation

Storing the dense kernel KK and computing dense matrix multiplications during the scaling iterations (2.18) requires a lot of memory and time on large problems. For several problems with particular structure, remedies have been proposed (Sect. 1.1). But these do not comprise non-standard cost functions, as the one used for the Wasserstein-Fisher-Rao distance, (2.3). Moreover they are not compatible with the log-stabilization (Section 3.1), thus a certain level of blur cannot be avoided. We are looking for a more flexible method to accelerate solving.

For many unregularized transport problems the optimal coupling π†\pi^{\dagger} is concentrated on a sparse subset of X×YX\times Y. In fact, this is the underlying mechanism for the efficiency of most solvers discussed in Section 1.1. For the regularized problems the optimal coupling will usually be dense. This is due to the diverging derivative of the KL⁡\operatorname{KL} divergence at zero. However, as ε→0\varepsilon\to 0, the optimal coupling quickly converges to an unregularized solution (see Sect. 1.1, in particular [16, Thm. 5.8]). As ε→0\varepsilon\to 0, large parts of the coupling will approach zero exponentially fast.

So while we will not be able to exactly solve the full problem, by solving suitable sparse sub-problems, we may still expect a reasonable approximation. We formalize the concept of a sparse sub-problem.

Let FXF_{X} and FYF_{Y} be marginal functions and cc be a cost function as in Definition 2.1 and let N⊂X×Y\mathcal{N}\subset X\times Y. We introduce:

We call problems (2.4a) and (2.4b) with cc replaced by c^\hat{c} the problems restricted to N\mathcal{N}. This corresponds to adding the constraint spt⁡π⊂N\operatorname{spt}\pi\subset\mathcal{N} to the primal problem, and only enforcing the constraint α(x)+β(y)≤c(x,y)\alpha(x)+\beta(y)\leq c(x,y) on (x,y)∈N(x,y)\in\mathcal{N} in the dual problem. The entropy regularized variants of the restricted problems are obtained through replacing KK by K^\hat{K} in (2.10a) and (2.10b).

Clearly, when N\mathcal{N} is sparse, then so is K^\hat{K} and the restricted regularized problem can be solved faster and with less memory. We now quantify the error inflicted by restriction.

Let ε>0\varepsilon>0 and N⊂X×Y\mathcal{N}\subset X\times Y. Let EE and JJ be unrestricted regularized primal and dual functionals with kernel KK, as given in Definition 2.4, and let E^\hat{E} and J^\hat{J} be the functionals of the problems restricted to N\mathcal{N}, with sparse kernel K^\hat{K} (see Def. 3.1).

Further, let (α,β)(\alpha,\beta) be a pair of dual variables, let u=exp⁡(α/ε)u=\exp(\alpha/\varepsilon), v=exp⁡(β/ε)v=\exp(\beta/\varepsilon) be the corresponding scaling factors and let π=diag⁡(u) K^ diag⁡(v)\pi=\operatorname{diag}(u)\,\hat{K}\,\operatorname{diag}(v) be the corresponding (restricted) primal coupling.

Then we find for the primal-dual gap between π\pi and (α,β)(\alpha,\beta):

Together we obtain E(π)−J(α,β)=E^(π)−J^(α,β)+ε∑(x,y)∈(X×Y)∖Nu(x) K(x,y) v(y)E(\pi)-J(\alpha,\beta)=\hat{E}(\pi)-\hat{J}(\alpha,\beta)+\varepsilon\sum_{(x,y)\in(X\times Y)\setminus\mathcal{N}}u(x)\,K(x,y)\,v(y).

That is, the primal-dual gap for the original full functionals is equal to the gap for the truncated functionals plus the ‘mass’ that we have chopped off by truncating KK to K^\hat{K}, when using the scaling factors uu and vv. If some N\mathcal{N} were known, on which most mass of the optimal π†\pi^{\dagger} is concentrated, it would be sufficient to solve the problem restricted to N\mathcal{N}, to get a good approximate solution. The remaining challenge is, how to identify N\mathcal{N} without knowing π†\pi^{\dagger} before.

We propose an iterative re-estimation of N\mathcal{N}, based on current dual iterates and to combine this with the log-stabilized iteration scheme (Section 3.1) and the computation of the stabilized kernel, (3.3b). For a threshold parameter θ>0\theta>0 we define the following functions:

getK^\textnormal{get}\hat{K} can be used instead of getK\textnormal{get}\mathcal{K} in Algorithm 2. We refer to this as absorption iteration with truncation. For this combination one finds a simple bound for the primal-dual gap comparison of Proposition 3.2.

For (x,y)∈(X×Y)∖N(x,y)\in(X\times Y)\setminus\mathcal{N} one has exp⁡(−1ε[c(x,y)−α^(x)−β^(y)])<θ\exp(-\tfrac{1}{\varepsilon}[c(x,y)-\hat{\alpha}(x)-\hat{\beta}(y)])<\theta and therefore

4 Multi-Scale Scheme

Finally, we propose to combine the stabilized sparse iterations with a hierarchical multi-scale scheme, analogous to the ideas in .

This serves two purposes: First, a hierarchical representation of the problem allows to determine the truncated sparse stabilized kernel getK^\textnormal{get}\hat{K}, (3.9), with a coarse-to-fine tree search, without explicitly testing all pairs (x,y)∈X×Y(x,y)\in X\times Y. The second reason is to make the combination of ε\varepsilon-scaling (Algorithm 3) with the truncated stabilized scheme more efficient. For a fixed threshold θ\theta, while ε\varepsilon is large, the support of the truncated kernel getK^\textnormal{get}\hat{K} will contain many variables. At the same time, due to the blur induced by the regularization, the primal iterates will not provide a sharply resolved assignment. Solving the problems with large ε\varepsilon-value on a coarser grid reduces the number of required variables, without losing much spatial accuracy. As ε\varepsilon decreases, so does the number of variables in getK^\textnormal{get}\hat{K} (since the exponential function decreases faster), and the resolution of XX and YY can be increased. Therefore, it is reasonable to coordinate the reduction of ε\varepsilon with increasing the spatial resolution of the transport problem, until the desired regularization and resolution are attained.

We will now briefly recall the hierarchical representation of a transport problem from .

For a discrete set XX a hierarchical partition is an ordered tuple (X0,…,XI)(\mathcal{X}_{0},\ldots,\mathcal{X}_{I}) of partitions of XX where X0={{x} ⁣:x∈X}\mathcal{X}_{0}=\{\{x\}\colon x\in X\} is the trivial partition of XX into singletons and each subsequent level is generated by merging cells from the previous level, i.e. for i∈{1,…,I}i\in\{1,\ldots,I\} and any x∈Xi\mathbf{x}\in\mathcal{X}_{i} there exists some X^⊂Xi−1\hat{\mathcal{X}}\subset\mathcal{X}_{i-1} such that x=⋃x^∈X^x^\mathbf{x}=\bigcup_{\hat{\mathbf{x}}\in\hat{\mathcal{X}}}\hat{\mathbf{x}}. For simplicity we assume that the coarsest level is the trivial partition into one set: XI={X}\mathcal{X}_{I}=\{X\}. We call I>0I>0 the depth of X\mathcal{X}.

Then we define the extension α^=(α^0,…,α^I)\hat{\alpha}=(\hat{\alpha}_{0},\ldots,\hat{\alpha}_{I}) of α\alpha onto the full partition X\mathcal{X} by

for i∈{0,…,I}i\in\{0,\ldots,I\} and x∈Xi\mathbf{x}\in\mathcal{X}_{i} and analogous for β^\hat{\beta} and β\beta. Similarly, define an extension c^\hat{c} of cc by

for i∈{0,…,I}i\in\{0,\ldots,I\}, x∈Xi\mathbf{x}\in\mathcal{X}_{i} and y∈Yi\mathbf{y}\in\mathcal{Y}_{i}.

For i∈{0,…,I}i\in\{0,\ldots,I\}, x∈x∈Xix\in\mathbf{x}\in\mathcal{X}_{i}, y∈y∈Yiy\in\mathbf{y}\in\mathcal{Y}_{i} we find

Now we can implement a hierarchical tree-search for getN\textnormal{get}\mathcal{N} (and analogously getK^\textnormal{get}\hat{K}).

From (3.12) follows directly that Algorithm 4 implements (3.8).

The second purpose of the multi-scale scheme is the combination with ε\varepsilon-scaling. As explained above, the purpose is to reduce the number of variables while ε\varepsilon is large. For an illustration see Fig. 1. For this, we divide the list E\mathcal{E} of regularization parameters ε\varepsilon into multiple lists (E0,…,EI)(\mathcal{E}_{0},\ldots,\mathcal{E}_{I}), with the largest values in EI\mathcal{E}_{I} and the smallest (and final) values in E0\mathcal{E}_{0}, and sorted from largest to smallest within each Ei\mathcal{E}_{i}. Then, for every ii from II down to we perform ε\varepsilon-scaling with list Ei\mathcal{E}_{i} at hierarchical level ii, using the dual solution at each level as initialization at the next stage. The full algorithm, combining log⁡\log-stabilization, ε\varepsilon-scaling, kernel truncation and the multi-scale scheme, is sketched next.

Note: ScalingAlgorithmStabilized refers to calling Algorithm 2 for solving the problem at scale ii, with getK\textnormal{get}\mathcal{K} replaced by getK^\textnormal{get}\hat{K}, (3.9), with threshold θ\theta, implemented according to Algorithm 4. Accordingly, two arguments ii and θ\theta were added. RefineDuals initializes the dual variables (α,β)(\alpha,\beta) at level ii by setting the values at x\mathbf{x} to the previous values at parent(x)\textnormal{parent}(\mathbf{x}) for all cells x\mathbf{x} in Xi\mathcal{X}_{i}.

To solve the problem at hierarchical scale ii, not only do we need a coarse version of cc, as given in (3.11). In addition we need hierarchical versions of the marginal functions FXF_{X}, FYF_{Y}, see (2.10). An appropriate choice is often clear from the context of the problem. For example, for an optimal transport problem between μ\mu and ν\nu, see Def. 2.6, we set FXi=ι{μi}F_{{\mathcal{X}}_{i}}=\iota_{\{\mu_{i}\}}, where μi\mu_{i} is taken from the multi-scale measure approximation of μ\mu (see Def. 3.6). For the unbalanced transport problem with KL⁡\operatorname{KL} fidelity, Def. 2.3, we use FXi=λ⋅KL⁡Xi(⋅∣μi)F_{\mathcal{X}_{i}}=\lambda\cdot\operatorname{KL}_{\mathcal{X}_{i}}(\cdot|\mu_{i}).

This completes the modifications of the diagonal scaling algorithm. Their usefulness will be demonstrated numerically in Sect. 5.

Analogy between Sinkhorn and Auction Algorithm

In this section we develop a new complexity analysis of the Sinkhorn algorithm and examine the efficiency of ε\varepsilon-scaling. In an intuitive similarity between the Sinkhorn algorithm for the entropy regularized linear assignment problem and the auction algorithm was pointed out. This similarity motivates our approach.

In this section we only consider the standard Sinkhorn algorithm (as opposed to general scaling algorithms), since the auction algorithm solves the linear assignment problem and assumptions on fixed marginals μ\mu, ν\nu are required for our analysis.

The auction algorithm is briefly recalled in Section 4.1. In Section 4.2 we introduce an asymmetric variant of the Sinkhorn algorithm, that is more similar to the original auction algorithm and provide an analogous worst-case estimate for the number of iterations until a given precision is achieved. A stability result for the dual optimal solutions under change of the regularization parameter ε\varepsilon is given in Section 4.3 and we discuss how it relates to ε\varepsilon-scaling in Sect. 4.4.

For the sake of self-containedness, in this section we briefly recall the auction algorithm and its basic properties. Note that compared to the original presentation (e.g. ) we flipped the overall sign for compatibility with the notion of optimal transport.

The main loop of the auction algorithm is divided into two parts: During the bidding phase, elements of XX that are unassigned determine their locally most attractive counterpart in YY (taking into account the current dual variables) and submit a bid for them. During the assignment phase, all elements of YY that received at least one bid, pick the most attractive one and change the current assignment accordingly. A formal description is given in the following.

In the above algorithm, line 7 is usually replaced by α(x)←min⁡y′∈Y∖{y}[c(x,y′)−β(y′)]\alpha(x)\leftarrow\min_{y^{\prime}\in Y\setminus\{y\}}[c(x,y^{\prime})-\beta(y^{\prime})], which in practice may reduce the number of iterations. It does not affect the following worst-case analysis however, therefore we keep the simpler version.

We briefly summarize the main properties of the algorithm.

With ε>0\varepsilon>0 and β(0)=0Y\beta^{(0)}=0_{Y}, Algorithm 6 has the following properties:

α\alpha is increasing, β\beta is decreasing.

After each assignment phase one finds α(x)+β(y)≤c(x,y)\alpha(x)+\beta(y)\leq c(x,y) and [π(x,y)>0][\pi(x,y)>0] ⇒\Rightarrow [α(x)+β(y)≥c(x,y)−ε][\alpha(x)+\beta(y)\geq c(x,y)-\varepsilon]. The latter property is called ε\varepsilon-complementary slackness.

The primal iterate satisfies PXπ≤μ\textnormal{P}_{X}\pi\leq\mu and PYπ≤ν\textnormal{P}_{Y}\pi\leq\nu.

The algorithm terminates after at most N⋅(C/ε+1)N\cdot(C/\varepsilon+1) iterations, where C=max⁡cC=\max c.

For a proof see for example . From ε\varepsilon-complementary slackness we deduce the following result.

Upon convergence, the primal-dual gap of π\pi and (α,β)(\alpha,\beta), cf. Def. 2.2, is bounded by ⟨c,π⟩−(⟨μ,α⟩+⟨ν,β⟩)≤N⋅ε\left\langle c,\pi\right\rangle-(\left\langle\mu,\alpha\right\rangle+\left\langle\nu,\beta\right\rangle)\leq N\cdot\varepsilon. If cc is integer and ε<1/N\varepsilon<1/N, then the final primal coupling is optimal.

During the auction algorithm it may happen that several elements in XX compete for the same target y∈Yy\in Y, leading to the minimal decrease of β(y)\beta(y) by ε\varepsilon in each iteration. This phenomenon has been dubbed ‘price haggling’ and can cause poor practical performance of the algorithm, close to the worst-case iteration bound. The impact of price haggling can be reduced by the ε\varepsilon-scaling technique, where the algorithm is successively run with a sequence of decreasing values for ε\varepsilon, each time using the final value of β\beta as initialization of the next run (see also Algorithm 3). With this technique the factor C/εC/\varepsilon in the iteration bound can essentially be reduced to a factor log⁡(C/ε)\log(C/\varepsilon). An analysis of the ε\varepsilon-scaling technique for more general min-cost-flow problems can be found in .

2 Asymmetric Sinkhorn Algorithm and Iteration Bound

We now introduce a slightly modified variant of the standard Sinkhorn algorithm, derive an iteration bound and make a comparison with the auction algorithm. We emphasize that this modification is primarily made to facilitate theoretical study of the algorithm and to understand why convergence becomes slow as ε→0\varepsilon\to 0. We do not advocate its merits in an actual implementation.

The only differences to the standard Sinkhorn algorithm (given by Algorithm 1 with proxdiv-operators (2.20)) lie in line 5 and in the choice of the specific stopping criterion (see Remark 4.13 for a discussion). In the standard algorithm one would set v←v^v\leftarrow\hat{v}. The modification implies that vv is monotonously decreasing, which implies the following result for Algorithm 7 in the spirit of Proposition 4.2. This monotonicity is crucial for bounding the number of iterations (see also Remark 4.15).

uu and α=ε log⁡u\alpha=\varepsilon\,\log u are increasing, vv and β=ε log⁡v\beta=\varepsilon\,\log v are decreasing, qq is increasing.

PX π≤μ\textnormal{P}_{X}\,\pi\leq\mu and PY π≤ν\textnormal{P}_{Y}\,\pi\leq\nu. We say π\pi is sub-feasible.

There exists some y∗∈Yy^{\ast}\in Y such that v(y∗)=v(0)(y∗)v(y^{\ast})=v^{(0)}(y^{\ast}) for all iterations.

With these tools we can bound the total number of iterations to reach a given precision.

Let us look at the first ‘bid’ α(1)\alpha^{(1)}. With c≥0c\geq 0 we have

Combining this with (4.2) we obtain n≤1+Cε (1−q(n))n\leq 1+\tfrac{C}{\varepsilon\,(1-q^{(n)})}. So, as long as q(n)<qtargetq^{(n)}<q_{\textnormal{target}} we have n<1+Cε (1−qtarget)n<1+\tfrac{C}{\varepsilon\,(1-q_{\textnormal{target}})}. By contraposition we know that there is some n≤2+Cε (1−qtarget)n\leq 2+\tfrac{C}{\varepsilon\,(1-q_{\textnormal{target}})} such that q(n)≥qtargetq^{(n)}\geq q_{\textnormal{target}}.

And finally, we formally establish convergence of the iterates.

The criterion q≥qtargetq\geq q_{\textnormal{target}} is motivated by Lemma 4.7, to provide a minimal increment of α\alpha during iterations. 1−q1-q measures the mass that is still missing and is equal to the L1L^{1} error between the marginals of π\pi and the desired marginals μ\mu and ν\nu. In pathological cases the dual variables (α,β)(\alpha,\beta) may still be far from optimizers, even though q≥qtargetq\geq q_{\textnormal{target}} (see Example 4.14). In [21, Lemma 2] linear convergence of the marginals in the Hilbert projective metric is proven. This is a stricter measure of convergence, less prone to ‘premature’ termination. However, for small ε\varepsilon the contraction factor is roughly 1−4 exp⁡(−C/ε)1-4\,\exp(-C/\varepsilon), which is impractical. The scaling O(1/ε)\mathcal{O}(1/\varepsilon) predicted by Proposition 4.9 is consistent with numerical observations when one uses the L1L^{1} or L∞L^{\infty} marginal error as stopping criterion (Sect. 5.2). Therefore we consider the qq-criterion to be a reasonable measure for convergence, as long as one keeps 1−qtarget≪δ1-q_{\textnormal{target}}\ll\delta (Example 4.14).

We consider the 1×21\times 2 toy problem with the following parameters:

for some C>0C>0, δ∈(0,1)\delta\in(0,1) and some regularization strength ε>0\varepsilon>0. And we consider the scaling factors (one for XX, two choices for YY): u=(1)⊤u=\begin{pmatrix}1\end{pmatrix}^{\top}, v1=(11)⊤v_{1}=\begin{pmatrix}1&1\end{pmatrix}^{\top}, v2=(1eC/ε)⊤v_{2}=\begin{pmatrix}1&e^{C/\varepsilon}\end{pmatrix}^{\top}. Let πi=diag⁡(u) K diag⁡(vi)\pi_{i}=\operatorname{diag}(u)\,K\,\operatorname{diag}(v_{i}) and corresponding total masses qiq_{i}, i=1,2i=1,2. We find:

π2\pi_{2} and (α,β2)=ε log⁡(u,v2)(\alpha,\beta_{2})=\varepsilon\,\log(u,v_{2}) are primal and dual solutions. π1\pi_{1} is sub-feasible (see Proposition 4.5). For fixed ε>0\varepsilon>0, as δ→0\delta\to 0, q1q_{1} tends to 1 (but is strictly smaller), i.e. the pair (u,v1)(u,v_{1}) has almost converged in the qq-measure sense, but the distance between β1=ε log⁡v1\beta_{1}=\varepsilon\,\log v_{1} and the actual solution β2\beta_{2} is CC.

For now assume ∣X∣=∣Y∣=N|X|=|Y|=N and μ\mu, ν\nu are normalized counting measures. Then line 4 in Algorithm 7, expressed in dual variables, becomes

These are formally similar to the corresponding lines 7 and 13 in Algorithm 6. We can interpret the uu-update in Algorithm 7 as xx not just submitting a bid to the best candidate yy, but to all candidates, weighted by the attractiveness (recall that in the Sinkhorn algorithm, a change in the dual variable directly implies a change in the primal iterate via (2.11)). Conversely, in line 5, yy does not only accept the best bid, but bids from all candidates, again weighted by price. If there are too many bids (i.e. if v^(y)<v(y)\hat{v}(y)<v(y)), β(y)\beta(y) decreases and thereby rejects superfluous offers.

Consequently, in Algorithm 7 one can observe that points in XX compete for the mass in YY in a way similar to the auction algorithm by repeatedly increasing their prices until a different target seems more attractive or other competitors lose interest. In both algorithms the minimal increment is related to the parameter ε\varepsilon which leads to iteration bounds that are proportional to 1/ε1/\varepsilon (Props. 4.2 and 4.9). An attempt to mimic the analysis of ε\varepsilon-scaling is made in Section 4.4 (cf. Remark 4.26).

One can interpret the standard Sinkhorn algorithm with v←v^v\leftarrow\hat{v} as yy submitting a ‘counter-bid’ if it has not received enough bids. Such a symmetrization has also been discussed for the auction algorithm. But then the complexity analysis based on monotonous dual variables breaks down, and the algorithm may even run indefinitely (see ‘down iterations’ in ).

3 Stability of Dual Solutions

The main result of this section is Theorem 4.16, which provides stability of dual solutions to entropy regularized optimal transport (Def. 2.6) under changes of the regularization parameter ε\varepsilon. Its implications for ε\varepsilon-scaling are discussed in Sect. 4.4.

studies the convergence of entropy regularized linear programs to the unregularized variant and can be used to understand the limit of entropy regularized optimal transport (Def. 2.6). To apply , the constraint matrix must have full rank and the set of optimal solutions to (2.5b) must be bounded. When the cost cc is finite this is achieved by arbitrarily fixing one dual variable, e.g. α(x0)=0\alpha(x_{0})=0, and removing the corresponding column from the dual constraint matrix. The slight difference in the definition of the entropy (or the dual exponential barrier) can be absorbed into a change of variables which converges to the identity in the limit ε→0\varepsilon\to 0.

Then [16, Props. 3.1 and 3.2] imply that the optimal solutions of (2.19b) remain bounded and converge to a particular solution of (2.5b) as ε→0\varepsilon\to 0. Furthermore, provides statements about the convergence of the optimal couplings (Prop. 4.1) and the asymptotic behaviour (Thm. 5.8).

The bounds derived in depend on the geometry of the primal and dual feasible polytopes of (2.5), i.e. on the transport cost function cc. In contrast, the bound of Thm. 4.16 does not depend on cc. The motivation for deriving such a bound is the implication for ε\varepsilon-scaling, see Section 4.4. Note that Thm. 4.16 also implies that the optimal dual variables remain bounded as ε→0\varepsilon\to 0.

The proof requires several auxiliary definitions and lemmas. The estimate consists of two contributions: One stems from following paths within connected components of what we call assignment graph (defined in the following lemma), using the primal-dual relation (2.11). This reasoning is analogous to the proof strategy for ε\varepsilon-scaling in the auction algorithm (see ). However, between different connected components (2.11) is too weak to yield useful estimates. So a second contribution arises from a stability analysis of effective diagonal problems (in Lemmas 4.21 and 4.23).

For two feasible couplings π1\pi_{1}, π2∈Π(μ,ν)\pi_{2}\in\Pi(\mu,\nu) and a threshold M−1≥1M^{-1}\geq 1 the corresponding assignment graph is a bipartite directed graph with vertex sets (X,Y)(X,Y) and the set of directed edges

where (a,b)∈E(a,b)\in\mathcal{E} indicates a directed edge from a→ba\to b.

The assignment graph has the following properties:

Every node has at least one incoming and one outgoing edge.

Let X0⊂XX_{0}\subset X, Y0⊂YY_{0}\subset Y such that there are no outgoing edges from (X0,Y0)(X_{0},Y_{0}) to the rest of the vertices, then ∣μ(X0)−ν(Y0)∣<1/M|\mu(X_{0})-\nu(Y_{0})|<1/M. This is also true when there are no incoming edges from the rest of the vertices. If μ\mu and ν\nu are atomic, with atom size 1/M1/M (see Assumption 1), then μ(X0)=ν(Y0)\mu(X_{0})=\nu(Y_{0}).

Assume, a node x∈Xx\in X had no outgoing edge. Then ∑y∈Yπ2(x,y)<μ(x)/M≤μ(x)\sum_{y\in Y}\pi_{2}(x,y)<\mu(x)/M\leq\mu(x). This contradicts π2∈Π(μ,ν)\pi_{2}\in\Pi(\mu,\nu). Existence of incoming edges follows analogously.

Let X^0=X∖X0\hat{X}_{0}=X\setminus X_{0}, Y^0=Y∖Y0\hat{Y}_{0}=Y\setminus Y_{0}. If (X0,Y0)(X_{0},Y_{0}) has no outgoing edges, then

Since π1\pi_{1}, π2∈Π(μ,ν)\pi_{2}\in\Pi(\mu,\nu), the first inequality implies μ(X0)=π2(X0×Y)=π2(X0×Y0)+π2(X0×Y^0)<ν(Y0)+1/M\mu(X_{0})=\pi_{2}(X_{0}\times Y)=\pi_{2}(X_{0}\times Y_{0})+\pi_{2}(X_{0}\times\hat{Y}_{0})<\nu(Y_{0})+1/M and the second inequality implies ν(Y0)<μ(X0)+1/M\nu(Y_{0})<\mu(X_{0})+1/M, i.e. ∣μ(X0)−ν(Y0)∣<1/M|\mu(X_{0})-\nu(Y_{0})|<1/M. With Assumption 1 for atom size 1/M1/M, this implies μ(X0)=ν(Y0)\mu(X_{0})=\nu(Y_{0}). The statement about incoming edges follows from μ(X^0)=1−μ(X0)\mu(\hat{X}_{0})=1-\mu(X_{0}) and ν(Y^0)=1−ν(Y0)\nu(\hat{Y}_{0})=1-\nu(Y_{0}).

Every node in (X,Y)(X,Y) is part of at least one strongly connected component (containing at least the node itself). If two strongly connected components have a common element, they are identical. Hence, the strongly connected components form partitions of XX and YY. For some x∈Xx\in X (or y∈Yy\in Y), let Xout⊂XX_{\textnormal{out}}\subset X and Yout⊂YY_{\textnormal{out}}\subset Y be the set of nodes that can be reached from xx, let Xin⊂XX_{\textnormal{in}}\subset X and Yin⊂YY_{\textnormal{in}}\subset Y be the set of nodes from which one can reach xx and let (Xcon=Xout∩Xin,Ycon=Yout∩Yin)(X_{\textnormal{con}}=X_{\textnormal{out}}\cap X_{\textnormal{in}},Y_{\textnormal{con}}=Y_{\textnormal{out}}\cap Y_{\textnormal{in}}) be the strongly connected component of xx. Clearly (Xout,Yout)(X_{\textnormal{out}},Y_{\textnormal{out}}) has no outgoing edges. Hence, by (ii) one has μ(Xout)=ν(Yout)\mu(X_{\textnormal{out}})=\nu(Y_{\textnormal{out}}). Moreover, (Xout∖Xin,Yout∖Yin)(X_{\textnormal{out}}\setminus X_{\textnormal{in}},Y_{\textnormal{out}}\setminus Y_{\textnormal{in}}) has no outgoing edges, hence μ(Xout∖Xin)=ν(Yout∖Yin)\mu(X_{\textnormal{out}}\setminus X_{\textnormal{in}})=\nu(Y_{\textnormal{out}}\setminus Y_{\textnormal{in}}), from which follows that μ(Xcon)=ν(Ycon)\mu(X_{\textnormal{con}})=\nu(Y_{\textnormal{con}}).

where JJ denotes the dual functional of entropy regularized optimal transport (2.19b), and

Since maximizing J^\hat{J} corresponds to maximizing JJ over an affine subspace, clearly β^†\hat{\beta}^{\dagger} is a maximizer of J^\hat{J}. Since J^\hat{J} inherits the invariance of JJ under constant shifts, any β^††\hat{\beta}^{\dagger\dagger} of the form given above, is also a maximizer. Consequently, we may add the constraint β^(1)=0\hat{\beta}(1)=0, which does not change the optimal value. With this added constraint the functional becomes strictly convex, which implies a unique optimizer. Hence, any optimizer of the unconstrained functional can be written in the form of β^††\hat{\beta}^{\dagger\dagger}.

Let us now give a more explicit expression of J^(β^)\hat{J}(\hat{\beta}). We find

Minimizers of J^ε,d\hat{J}_{\varepsilon,d} exist.

That is, maxdiam⁡(w)\operatorname{maxdiam}(w) is the length of the longest cycle-less path in {1,…,R}\{1,\ldots,R\} with edge lengths ww.

The proofs of Theorem 4.16 and Lemma 4.23 can be found in Appendix A.

4 Application To ε𝜀\varepsilon-Scaling

Assuming that we know the dual solution for some ε1>0\varepsilon_{1}>0, then Theorem 4.16 allows to bound the number of iterations of Algorithm 7 for some smaller ε2∈(0,ε1)\varepsilon_{2}\in(0,\varepsilon_{1}), independently of bounds on the cost function cc. This may have implications for the efficiency of ε\varepsilon-scaling (see Remark 4.26).

Consider the set-up of Theorem 4.16. In particular, let ε1>ε2>0\varepsilon_{1}>\varepsilon_{2}>0 be two regularization parameters, let (α1,β1)(\alpha_{1},\beta_{1}), (α2,β2)(\alpha_{2},\beta_{2}) be corresponding optimizers of (2.19b). If Algorithm 7 is initialized with v(0)=exp⁡(β1/ε2)v^{(0)}=\exp(\beta_{1}/\varepsilon_{2}), with regularization ε2\varepsilon_{2}, and for a given qtarget∈(0,1)q_{\textnormal{target}}\in(0,1), the number of iterations nn necessary to achieve q(n)≥qtargetq^{(n)}\geq q_{\textnormal{target}} is bounded by

For the optimal scaling factor u1u_{1} of the ε1\varepsilon_{1}-problem we find:

This implies u1(x)−1 ν(y)−1≥exp⁡(−1ε1[c(x,y)−β1(y)])u_{1}(x)^{-1}\,\nu(y)^{-1}\geq\exp\left(-\tfrac{1}{\varepsilon_{1}}[c(x,y)-\beta_{1}(y)]\right) for all (x,y)∈X×Y(x,y)\in X\times Y. With this we can bound the first iterate of the ε2\varepsilon_{2}-run of the algorithm by:

where we have used ν(y)≥1/M\nu(y)\geq 1/M, Assumption 1. Eventually we find α(1)(x)≥α1(x)−ε1 log⁡M\alpha^{(1)}(x)\geq\alpha_{1}(x)-\varepsilon_{1}\,\log M.

Now we combine Algorithm 7 with ε\varepsilon-scaling, (cf. Algorithm 3). For ε=ε^⋅λ−k≥C\varepsilon=\hat{\varepsilon}\cdot\lambda^{-k}\geq C, according to Proposition 4.9 it will take at most 2+11−qtarget2+\frac{1}{1-q_{\textnormal{target}}} iterations. It is tempting to deduce from Proposition 4.24 that for each subsequent value of ε\varepsilon at most 2+Aλ (1−qtarget)2+\frac{A}{\lambda\,(1-q_{\textnormal{target}})} iterations are required, with A=N⋅(4log⁡N+24log⁡M)+log⁡MA=N\cdot(4\log N+24\log M)+\log M. For N>1N>1 the total number of iterations would then be bounded by (2+Aλ (1−qtarget))⋅(k+1)(2+\frac{A}{\lambda\,(1-q_{\textnormal{target}})})\cdot(k+1). For fixed λ\lambda the step parameter kk scales like log⁡(C/ε^)\log(C/\hat{\varepsilon}). Consequently, the total number of iterations would be bounded by O(log⁡(C/ε^))\mathcal{O}(\log(C/\hat{\varepsilon})) w.r.t. the cost function and regularization, which would be analogous to ε\varepsilon-scaling for the auction algorithm (Remark 4.4).

There is an obvious gap in this reasoning: Theorem 4.16 assumes that β1\beta_{1} is known exactly, while Algorithm 7 only provides an approximate result. From Example 4.14 we learn that in extreme cases this difference can be substantial and disrupt the efficiency of ε\varepsilon-scaling. Thus, additional assumptions on the problem are required to make the above argument rigorous.

However, as discussed in Remark 4.13, in practice we usually observe that approximate iterates are sufficient and we can therefore hope that ε\varepsilon-scaling does indeed serve its purpose.

Numerical Examples

Now we present a series of numerical experiments to confirm the usefulness of the modifications proposed in Sect. 3. We show that runtime and memory usage are reduced substantially. At the same time the adapted algorithm is still as versatile as the basic version of , Algorithm 1. But Algorithm 5 can solve larger problems at lower regularization, yielding very sharp results. We give examples for unbalanced transport, barycenters and Wasserstein gradient flows. The code used for the numerical experiments is available from the author’s website.https://github.com/bernhard-schmitzer

2 Efficiency of Enhanced Algorithm

The numerical efficiency of the subsequent modifications presented in Sect. 3, applied to the standard Sinkhorn algorithm, is illustrated in Fig. 2. While the stabilized algorithm (i) is not yet faster than the naive implementation, it can robustly solve the problem for all given values of ε\varepsilon. The required number of iterations scales like O(1/ε)\mathcal{O}(1/\varepsilon), in good agreement with the complexity analysis of Sect. 4.2. With ε\varepsilon-scaling (ii) the number of iterations is decreased substantially. Replacing the dense kernel with the adaptive truncated sparse kernel (iii) does not change the number of required iterations, but saves time and memory. With the multi-scale scheme the required number of iterations is slightly increased, since the initial dual variables obtained at a coarser level are only approximate solutions. But by reducing the number of variables during the early ε\varepsilon-scaling stages, the runtime is further decreased (cf. Fig. 1). The combination of all modifications leads to an average total speed-up of more than two orders of magnitude on this problem type.

A runtime benchmark and study of the sparsity of the truncated kernel are given in Fig. 3. The runtime scales approximately linear with ∣X∣|X| and for large problems the algorithm becomes faster than the adaptive sparse linear programming solver . The final number of variables in the sparse kernel is comparable with the number of variables in , for higher values of ε\varepsilon, during scaling, more memory is required (cf. Fig. 4). This underlines again the importance of the coarse-to-fine scheme (Sect. 3.4). It should be noted, that Fig. 2 shows results for 64×6464\times 64 images, the smallest image size in Fig. 3. For larger images the runtime difference between (i-iv) would be even larger, but due to time and memory constraints, only (iv) can be run practically.

The impact of different final values for ε\varepsilon is outlined in Fig. 4. As expected, the number of variables in the truncated kernel increases with ε\varepsilon. This leads to two competing trends in the overall runtime: For large ε\varepsilon, the kernel truncation is less efficient, leading to an increase with ε\varepsilon. For small ε\varepsilon, the number of variables is very small, but more and more stages of ε\varepsilon-scaling are necessary, increasing the runtime as ε\varepsilon decreases further. Convergence of the regularized optimal dual variables to the unregularized optimal duals is exemplified in the right panel, justifying the use of the approximate entropy regularization technique for transport-type problems. While one may consider the dual sub-optimality at ε≈30 h2\varepsilon\approx 30\,h^{2} sufficiently accurate, we point out that the corresponding primal coupling still contains considerable blur (cf. Fig. 1) and that due to less sparsity the runtime is actually higher than for ε≈h2\varepsilon\approx h^{2}.

As illustrated by Figs. 3 and 4, by choosing the threshold for the stopping criterion and the desired final ε\varepsilon, one can tune between required precision and available runtime.

The numerical findings presented in Figs. 2-4 underline how each of the modifications discussed in Sect. 3 builds on the previous ones and that all four of them are required for an efficient algorithm. The log-domain stabilization is an indispensable prerequisite for running the scaling algorithms with small regularization. However, for small ε\varepsilon, convergence tends to become extremely slow (cf. Fig. 2), therefore ε\varepsilon-scaling is needed to reduce the number of iterations. For small ε\varepsilon, kernel truncation significantly reduces the number of variables and accelerates the algorithm (cf. Figs. 2 and 4). However, for large ε\varepsilon (which must be passed during ε\varepsilon-scaling), far fewer variables are truncated and the algorithm cannot be run on large problems. This can be avoided by using the coarse-to-fine scheme, completing the algorithm. In principle it is possible, only to combine log-domain stabilization with kernel truncation, and to skip ε\varepsilon-scaling and the coarse-to-fine scheme. While this tends to solve the stability and memory issues, convergence is still impractically slow.

3 Versatility

The framework of scaling algorithms developed in , see Sect. 2, allows to solve more general transport-type problems for which the enhancements of Sect. 3 still apply. We now give some examples to demonstrate this flexibility. The scope of the following examples is similar to , but with Algorithm 5 one can solve larger problems with smaller regularization.

A proof is given in . Compared to the standard Sinkhorn algorithm, the only modification is the pointwise power of the iterates. As λ→∞\lambda\to\infty the Sinkhorn iterations are recovered. In the stabilized operator only the exponential \exp\big{(}\tfrac{-\alpha}{\lambda+\varepsilon}\big{)} needs to be evaluated, which remains bounded as ε→0\varepsilon\to 0. Algorithm 5 performs similarly with KL⁡\operatorname{KL}-fidelity as with fixed marginal constraints, allowing to efficiently solve large unbalanced transport problems. Since the truncation scheme can also be used with non-standard cost functions such as (2.3), this includes in particular the Wasserstein-Fisher-Rao (WFR) distance. Fig. 5 shows a geodesic for the WFR distance, to intuitively illustrate its properties. The geodesic has been computed as weighted barycenters between its endpoints (see below). For a direct dynamic formulation we refer to . For the relation to the KL⁡\operatorname{KL} soft-marginal formulation, Def. 2.3, see .

Wasserstein barycenters

Wasserstein barycenters as a natural generalization of the Riemannian center of mass have been studied in . The computation of entropy regularized Wasserstein barycenters with a Sinkhorn-type scaling algorithm has been presented in , an alternative numerical approach can be found in . The iterations can be considered as a special case of the framework in . Here, we very briefly recall the iterations. Derivations and proofs can be found in .

and KK is the kernel (2.8) over X×XX\times X for the cost c=d2c=d^{2}. When an optimizer (πi†)i(\pi^{\dagger}_{i})_{i} is found, the common second marginal of all πi†\pi^{\dagger}_{i} is the sought-after barycenter. To solve (5.2) one considers again a suitable dual problem and uses alternating optimization. Updates corresponding to F1F_{1} decompose into independent standard Sinkhorn iterations for each marginal, the update for F2F_{2} couples all marginals, see . The adaptations from Sect. 3 remain applicable. A barycentric triangle computed with Algorithm 5 is shown in Fig. 6. The log-domain stabilization allows to reach a lower final regularization ε\varepsilon as for example in . Regularization can be made so small that discretization artifacts become visible. While this may not look entirely pleasing, it clearly gives a better approximation to the unregularized problem and illustrates that with log-domain stabilization entropy regularized numerical methods can produce sharp results.

Wasserstein-Fisher-Rao barycenters

Similarly one can define barycenters for transport distances with KL⁡\operatorname{KL} marginal fidelity, which includes the Gaussian Hellinger-Kantorovich (GHK) distance and the Wasserstein-Fisher-Rao (WFR) distance (Def. 2.3). The primal functional is given by (5.2) with

where Λ>0\Lambda>0 is a global weight of the KL⁡\operatorname{KL}-fidelity. When a primal optimizer is found, the minimizing σ\sigma in F2F_{2} yields the sought-after barycenter. We refer to for details. Partial optimization corresponding to F1F_{1} can again be done separately for each marginal, leading to KL⁡\operatorname{KL} fidelity updates as given by (5.1). The update corresponding to F2F_{2} is again coupled , adaptations from Sect. 3 remain applicable.

Wasserstein Gradient Flows

In diagonal scaling algorithms were extended to compute proximal steps for entropy regularized optimal transport to approximate gradient flows in Wasserstein space (cf. Sect. 1.1). This was then subsumed into the general framework of . Here we given an example for the porous medium equation, for more details we refer to . Let

Conclusion

Scaling algorithms for entropy regularized transport-type problems have become a wide-spread numerical tool. Naive implementations have some severe numerical limitations, in particular for small regularization and on large problems. In this article, we proposed an enhanced variant of the standard scaling algorithm to address these issues: Diverging scaling factors and slow convergence are remedied by log-domain stabilization and ε\varepsilon-scaling. Required runtime and memory are significantly reduced by adaptive kernel truncation and a coarse-to-fine scheme. A new convergence analysis for the Sinkhorn algorithm was developed. Numerical examples showed the efficiency of the enhanced algorithm, confirmed the scaling predicted by the convergence analysis and demonstrated that the algorithm can produce sharp results on a wide range of transport-type problems. Potential directions for future research are the more detailed study of ε\varepsilon-scaling, a more systematic understanding of the stability of the log-domain stabilization and application to multi-marginal problems.

Lénaïc Chizat, Luca Nenna and Gabriel Peyré are thanked for stimulating discussions. Bernhard Schmitzer was supported by the European Research Council (project SIGMA-Vision).

Appendix A Additional Proofs

The first order optimality condition for the functional yields for the ii-th component of β\beta:

From the optimality conditions for βa(i1)\beta_{a}(i_{1}), a=1,2a=1,2, and (1.3) we obtain:

where w(i,j)=max⁡{−Δd(i,j),Δd(j,i)}w(i,j)=\max\{-\Delta d(i,j),\Delta d(j,i)\}. This implies there is some i2∈{1,…,R}∖{i1}i_{2}\in\{1,\ldots,R\}\setminus\{i_{1}\} with

where W(i1,k)=max⁡{−ΔD(i1,k),ΔD(k,i1)}W(i_{1},k)=\max\{-\Delta D(i_{1},k),\Delta D(k,i_{1})\} for k∈I2k\in I_{2} and ΔD=D2−D1\Delta D=D_{2}-D_{1}. With (1.3) we find

and eventually W(i1,k)≤max⁡j∈I1(w(j,k)−Δβ(j))+Δβ(i1)+max⁡{ε1,ε2}⋅log⁡RW(i_{1},k)\leq\max_{j\in I_{1}}(w(j,k)-\Delta\beta(j))+\Delta\beta(i_{1})+\max\{\varepsilon_{1},\varepsilon_{2}\}\cdot\log R. So there is some index i3∈I2i_{3}\in I_{2} such that

The index i3i_{3} will be called a child of the minimizing index j∈I1j\in I_{1} on the r.h.s. (or one of the minimizing indices). Then we add i3i_{3} to the set I1I_{1} and repeat the argument with the reduced functional, to obtain an index i4i_{4} and repeat this until I1I_{1} contains all indices.

Since we assign every new index iki_{k} that is added to I1I_{1} as a child to one parent node in I1I_{1}, this also constructs a tree graph with root node i1i_{1} (finiteness of dd and consequently DD implies that this graph is connected). For an index iki_{k} let (i1,i2,…,ik)(i_{1},i_{2},\ldots,i_{k}) be the unique path from the root to iki_{k}. Then

Since Δβ(i1)=max⁡Δβ\Delta\beta(i_{1})=\max\Delta\beta the result follows.

A.2 Proof of Theorem 4.16

Let π1\pi_{1}, π2\pi_{2} be the primal optimizers associated with (α1,β1)(\alpha_{1},\beta_{1}) and (α2,β2)(\alpha_{2},\beta_{2}) and consider the assignment graph for π1\pi_{1} and π2\pi_{2} and threshold 1/M1/M (see Lemma 4.19). Let {(Xi,Yi)}i=1R\{(X_{i},Y_{i})\}_{i=1}^{R} be the strongly connected components of the assignment graph. By virtue of Lemma 4.19(iii), μ(Xi)=ν(Yi)\mu(X_{i})=\nu(Y_{i}) for i=1,…,Ri=1,\ldots,R. Pick some representatives {yi}i=1R⊂Y\{y_{i}\}_{i=1}^{R}\subset Y such that yi∈Yiy_{i}\in Y_{i} for i=1,…,Ri=1,\ldots,R.

Now we derive some estimates on Δd\Delta d. Consider once more the assignment graph for π1\pi_{1}, π2\pi_{2} and threshold 1/M1/M. For every edge y→xy\to x we have (using (2.11))

Moreover, from the marginal conditions we find π2(x,y)≤ν(y)\pi_{2}(x,y)\leq\nu(y), which implies

Combining the two estimates, we obtain Δα(x)+Δβ(y)≤(ε1+ε2) log⁡M≤2ε1 log⁡M:=L\Delta\alpha(x)+\Delta\beta(y)\leq(\varepsilon_{1}+\varepsilon_{2})\,\log M\leq 2\varepsilon_{1}\,\log M:=L. Similarly, for edges x→yx\to y we obtain Δα(x)+Δβ(y)≥−(ε1+ε2) log⁡M≥−L\Delta\alpha(x)+\Delta\beta(y)\geq-(\varepsilon_{1}+\varepsilon_{2})\,\log M\geq-L. Let now (y1,x1,…,yk)(y_{1},x_{1},\ldots,y_{k}) be an alternating path in (X,Y)(X,Y), then, by combining the above inequalities we find Δβ(yj+1)≥Δβ(yj)−2⋅L\Delta\beta(y_{j+1})\geq\Delta\beta(y_{j})-2\cdot L for j=1,…,k−1j=1,\ldots,k-1 and eventually

Similarly, for a path (x1,y2,x2,…,yk)(x_{1},y_{2},x_{2},\ldots,y_{k}) get Δα(x1)+Δβ(yk)≥−(2 k−1)⋅L\Delta\alpha(x_{1})+\Delta\beta(y_{k})\geq-(2\,k-1)\cdot L, and for a path (y1,x1,…,yk,xk)(y_{1},x_{1},\ldots,y_{k},\allowbreak x_{k}) get Δα(xk)+Δβ(y1)≤(2 k−1)⋅L\Delta\alpha(x_{k})+\Delta\beta(y_{1})\leq(2\,k-1)\cdot L.

where we used ∣Δεlog⁡(μ(x) ν(y))∣≤2ε1 log⁡M=L|\Delta\varepsilon\log(\mu(x)\,\nu(y))|\leq 2\varepsilon_{1}\,\log M=L. From this follows that w(i,j)≤8 max⁡{∣Yi∣,∣Yj∣}⋅ε1 log⁡M+2 ε1 log⁡Nw(i,j)\leq 8\,\max\{|Y_{i}|,|Y_{j}|\}\cdot\varepsilon_{1}\,\log M+2\,\varepsilon_{1}\,\log N, which in turn implies that maxdiam⁡(w)≤16 ε1 N log⁡M+2 ε1 R log⁡N\operatorname{maxdiam}(w)\leq 16\,\varepsilon_{1}\,N\,\log M+2\,\varepsilon_{1}\,R\,\log N.

Recall that Δβ^=β^2†−β^1†\Delta\hat{\beta}=\hat{\beta}_{2}^{\dagger}-\hat{\beta}_{1}^{\dagger}, where β^a†\hat{\beta}_{a}^{\dagger}, a=1,2a=1,2, are the optimizers of the effective diagonal problems. Then from Lemma 4.23, and by bounding R≤NR\leq N we obtain that

and analogously we get the equivalent bound for Δα\Delta\alpha.

References