Transport applications
Historical and modern applications of optimal transport — from Monge's earth-moving problem through Wasserstein GANs, single-cell genomics, domain adaptation, and geometric deep learning.
Optimal transport has one of the longest application histories in applied mathematics — 240 years from Monge's engineering problem to today's generative model training loops. This page traces where the problem arises, why OT is the right formulation, and how torchmatch's backends map onto each use case.
Supply chain and resource allocation
The first computational use of the transportation problem (the discrete precursor to general OT) was in centrally-planned resource allocation: given factories producing a good and warehouses needing it, at what shipping cost should supply be routed to minimise total freight? Kantorovich developed the LP formulation for exactly this purpose in wartime Soviet planning, and the 1975 Nobel Prize citation mentions "optimal allocation of resources" as the core contribution. Koopmans, sharing the prize, applied the same structure to shipping route optimisation.
The transportation LP — assign continuous mass from supply locations to demand locations at
minimum unit transport cost — is the special case where a and b are given histograms
and C encodes geographic distance. It remains a daily tool in logistics optimisation and
supply chain planning.
Image retrieval and perceptual similarity
The Earth Mover's Distance entered computer vision through image retrieval [Rubner2000]. When comparing two images by their colour histograms, Euclidean distance between bin counts is insensitive to perceptually small shifts: moving probability mass from the "red" bin to the "orange" bin registers as a large L2 distance but a small perceptual distance. OT charges the actual cost of moving mass between bins according to the colour-space ground metric (a distance function defined over the colour space, e.g. Euclidean distance in RGB or Lab), so nearby colours are treated as similar.
The same idea extends to texture descriptors, shape histograms, and any feature whose
natural distance is not Euclidean on the raw representation. The EXACT_EMD backend in
torchmatch computes the exact earth mover's distance for small histograms where no
regularisation is desired.
Colour transfer and style matching
Histogram matching via OT underlies a family of image stylisation techniques. Given a
source image and a target whose colour statistics you want to adopt, computing the 1D or 3D
OT map between their colour histograms and applying it as a pixel-wise transformation
transfers the palette of the target to the source with minimal perceptual distortion.
Pitié, Kokaram, and Dahyot [Pitie2007] formalised this as iterated 1D projections
(sliced Wasserstein transport — an approximation that computes 1D OT on random projections of the distribution, avoiding the full N-dimensional cost), an approximation that scales to full 3D colour histograms
without materialising an n³ cost.
Generative modelling
Wasserstein GAN [Arjovsky2017] reframed generative adversarial training in terms of the Wasserstein-1 distance between the real and generated distributions. The Wasserstein distance is meaningful even when the two distributions have disjoint support (which commonly occurs during early GAN training), whereas Jensen-Shannon divergence and KL divergence both saturate to a constant in this regime, providing no gradient signal. The practical implementation uses the Kantorovich-Rubinstein dual (the equivalent formulation of W1 as a supremum over 1-Lipschitz functions, used to train the discriminator) with gradient-penalised discriminators rather than directly computing the OT plan, but the connection motivates the loss design.
Wasserstein autoencoders (WAE) [Tolstikhin2018] replaced the evidence lower bound of the VAE with a Wasserstein distance between the aggregate posterior and the prior, producing sharper reconstructions on image benchmarks.
Flow matching [Lipman2022]; [Liu2022] frames diffusion-model training as learning a vector field that transports a source distribution (Gaussian noise) to a target distribution (data). The "OT-conditioned flow matching" variant conditions the flow on the OT displacement plan between individual noise samples and data samples, producing straighter trajectories and faster inference.
For all three model classes, transport.matrix.solve with SINKHORN_DIVERGENCE or
transport.samples.loss with debias=True provides a differentiable Wasserstein-like
training loss that can be substituted for or combined with the standard objectives.
Domain adaptation
A model trained on a labelled source domain often fails on an unlabelled target domain because the marginal feature distributions differ. OT provides a principled way to measure and correct this discrepancy: it computes a transport plan between source and target feature distributions, then uses that plan to move source features toward the target domain before training a classifier.
- OTDA [Courty2017] computes the regularised OT plan between labelled source samples and unlabelled target samples in the feature space of a pretrained network. The plan then transports source features toward the target, producing pseudo-labelled target samples that train a target-domain classifier.
- DeepJDOT [Damodaran2018] integrates OT alignment into an end-to-end deep network: the OT plan between source and target minibatches is recomputed each iteration and used as a re-weighting of the classification loss.
- Distribution matching for dataset distillation: the Sinkhorn divergence between feature distributions of real and distilled datasets serves as the distillation objective, requiring a geometry-aware distance that respects the ground metric of feature space.
The UNBALANCED_SINKHORN backend is particularly useful when source and target have
genuinely different class distributions: relaxing the marginal constraints prevents the
coupling from being dominated by classes that are abundant in one domain but rare in the
other.
Geometric deep learning and 3D vision
Point cloud registration and shape matching require finding correspondences between two
unordered point sets. OT provides the soft coupling that minimises transport cost, giving
a probabilistic correspondence matrix as the plan. This soft matching initialises or
replaces ICP (iterative closest point) in registration pipelines, is differentiable with
respect to the point positions, and scales to large point clouds via the samples.loss
streaming kernel.
Wasserstein barycenters [Agueh2011] — weighted averages of distributions in Wasserstein space — produce interpolations between shapes that respect the geometry of the ground metric. Interpolating between two 3D shapes in Wasserstein space moves each point smoothly toward its corresponding point in the target, unlike Euclidean averaging which collapses the shape when distributions are disjoint.
Shape completion and generation: point-cloud generative models (PointFlow,
ShapeGF, DPM-based point clouds) use Wasserstein or Sinkhorn losses to supervise the
generated shape. transport.samples.loss is directly applicable; the streaming Triton
kernel avoids the N × M allocation that would dominate memory at generation-scale cloud
sizes.
Natural language processing
Word Mover's Distance [Kusner2015] embeds documents as distributions over word embedding vectors (weighted by TF-IDF or uniform) and computes the OT cost between them using pretrained embeddings as the ground metric. The resulting distance is insensitive to synonyms and paraphrases — moving mass from "automobile" to "car" is cheap because the embeddings are nearby — and outperforms bag-of-words similarity on several retrieval benchmarks.
The same idea applies to sentence-level alignment for mining parallel corpora, where OT between sentence embedding distributions identifies likely translations without requiring exact string matches.
Computational biology
Waddington-OT [Schiebinger2019] modelled cellular differentiation as an OT problem: single-cell RNA-seq profiles from adjacent time points define the source and target distributions over gene-expression space, and the OT plan between them gives the most parsimonious account of which early cells give rise to which later cells. This transport interpretation respects the Waddington epigenetic landscape metaphor and produces biologically interpretable developmental trajectories without requiring paired data.
Moscot [Klein2023] scaled this framework to million-cell datasets and extended it to
spatial transcriptomics alignment, single-cell multi-omics integration (matching cells
across RNA and protein measurements), and lineage tracing. The computational backbone is
log-domain Sinkhorn with online batching — structurally identical to LOG_SINKHORN —
applied at dataset scales that require careful memory management.
Protein structure comparison: OT between residue-coordinate distributions provides a rotation-invariant distance between two protein chains that accounts for insertions, deletions, and loop flexibility without requiring global structural alignment.
References
- [Rubner2000]Rubner, Yossi and Tomasi, Carlo and Guibas, Leonidas J.. "The earth mover's distance as a metric for image retrieval." International Journal of Computer Vision, vol. 40(2), pp. 99–121. 2000. doi:10.1023/A:1026543900054.
- [Pitie2007]Pitié, François and Kokaram, Anil C. and Dahyot, Rozenn. "Automated colour grading using colour distribution transfer." Computer Vision and Image Understanding, vol. 107(1--2), pp. 123–137. 2007. doi:10.1016/j.cviu.2006.11.011.
- [Arjovsky2017]Arjovsky, Martin and Chintala, Soumith and Bottou, Léon. "Wasserstein generative adversarial networks." In International Conference on Machine Learning, pp. 214–223. 2017.
- [Tolstikhin2018]Tolstikhin, Ilya and Bousquet, Olivier and Gelly, Sylvain and Schölkopf, Bernhard. "Wasserstein auto-encoders." In International Conference on Learning Representations. 2018.
- [Lipman2022]Lipman, Yaron and Chen, Ricky T. Q. and Ben-Hamu, Heli and Nickel, Maximilian and Le, Matt. "Flow matching for generative modeling." In International Conference on Learning Representations. 2023.
- [Liu2022]Liu, Xingchao and Gong, Chengyue and Liu, Qiang. "Flow straight and fast: Learning to generate and transfer data with rectified flow." In International Conference on Learning Representations. 2023.
- [Courty2017]Courty, Nicolas and Flamary, Rémi and Tuia, Devis and Rakotomamonjy, Alain. "Optimal transport for domain adaptation." IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 39(9), pp. 1853–1865. 2017. doi:10.1109/TPAMI.2016.2615921.
- [Damodaran2018]Damodaran, Bharath Bhushan and Kellenberger, Benjamin and Flamary, Rémi and Tuia, Devis and Courty, Nicolas. "DeepJDOT: Deep joint distribution optimal transport for unsupervised domain adaptation." In European Conference on Computer Vision (ECCV), pp. 467–483. 2018. doi:10.1007/978-3-030-01225-0_28.
- [Agueh2011]Agueh, Martial and Carlier, Guillaume. "Barycenters in the Wasserstein space." SIAM Journal on Mathematical Analysis, vol. 43(2), pp. 904–924. 2011. doi:10.1137/100805741.
- [Kusner2015]Kusner, Matt J. and Sun, Yu and Kolkin, Nicholas I. and Weinberger, Kilian Q.. "From word embeddings to document distances." In International Conference on Machine Learning, pp. 957–966. 2015.
- [Schiebinger2019]Schiebinger, Geoffrey and Shu, Jian and Tabaka, Marcin and Cleary, Brian and Subramanian, Vidya and Solomon, Aryeh and Gould, Joshua and Liu, Siyan and Lin, Stacie and Berube, Peter and Lee, Lia and Chen, Jenny and Brumbaugh, Justin and Rigollet, Philippe and Hochedlinger, Konrad and Jaenisch, Rudolf and Regev, Aviv and Lander, Eric S.. "Optimal-transport analysis of single-cell gene expression identifies developmental trajectories in reprogramming." Cell, vol. 176(4), pp. 928–943. 2019. doi:10.1016/j.cell.2019.01.006.
- [Klein2023]Klein, Dominik and Palla, Giovanni and Lange, Marius and Klein, Michal and Piran, Zoe and Gander, Manuel and Meng-Papaxanthos, Laetitia and Sterr, Michael and Treutlein, Barbara and Lickert, Heiko and Theis, Fabian J.. "Mapping cells through time and space with moscot." bioRxiv. 2023. doi:10.1101/2023.05.11.540374.
Assignment applications
Historical and modern applications of the linear assignment problem — from 1950s operations research to DETR, multi-object tracking, and cluster evaluation in contemporary deep learning.
Benchmarks
Per-op benchmark sweep across problem sizes, dtypes, and devices — covering assignment (single-problem, batched) and transport (matrix-face Sinkhorn/EMD, samples-face Triton) ops.