Utilities for optimal transport algorithms and benchmarking
Project description
uot-bench
uot-bench is a Python toolkit for optimal transport solvers and benchmarking. It provides JAX-first implementations of common OT methods, utilities for generating problems and measures, and a configurable pipeline for running experiments at scale.
Package name vs import name:
pip install uot-bench, thenimport uot.
Full documentation: docs/
Install
pip install uot-bench
Optional extras:
pip install "uot-bench[viz,color-transfer,gurobi]"
pip install "uot-bench[storage]" # HDF5 problem store
pip install "uot-bench[profiling]" # GPU resource tracking
pip install "uot-bench[mnist]" # MNIST classification experiment
pip install "uot-bench[cuda12]" # JAX with CUDA 12
pip install "uot-bench[all]" # All optional extras
60-second example
import numpy as np
from uot import TwoMarginalProblem
from uot.data import PointCloudMeasure
from uot.solvers import SinkhornTwoMarginalSolver
from uot.utils.costs import cost_euclid_squared
x = np.linspace(0.0, 1.0, 64).reshape(-1, 1)
y = np.linspace(0.0, 1.0, 64).reshape(-1, 1)
a = np.exp(-((x - 0.3) ** 2) / 0.01).reshape(-1); a /= a.sum()
b = np.exp(-((y - 0.7) ** 2) / 0.02).reshape(-1); b /= b.sum()
mu = PointCloudMeasure(x, a, name="mu")
nu = PointCloudMeasure(y, b, name="nu")
problem = TwoMarginalProblem("toy", mu, nu, cost_euclid_squared)
inputs = problem.solver_inputs()
result = SinkhornTwoMarginalSolver().solve(
marginals=inputs.marginals,
costs=inputs.costs,
reg=1e-2,
)
print("cost:", float(result["cost"]))
See docs/quickstart.md for more examples, and docs/guide/custom-solver.md to write your own solver.
CLI cheatsheet
After pip install uot-bench the following console scripts are available.
Each is equivalent to the python -m <module> form shown alongside it.
| Console script | python -m equivalent |
What it does | Schema |
|---|---|---|---|
uot-serialize --config X --export-dir Y |
python -m uot.problems.problem_serializer |
Generate + persist problems to disk | cli/serialize |
uot-benchmark --config X --export results.csv |
python -m uot.experiments.synthetic.benchmark |
Run experiment over problems × solvers, write CSV | cli/benchmark |
uot-color-transfer --config X |
python -m uot.experiments.real_data.color_transfer.color_transfer |
Color transfer experiment | cli/color-transfer |
uot-color-transfer-viz --origin_folder X --results_folder Y |
python -m uot.experiments.real_data.color_transfer.visualization |
Launch visualization dashboard | |
uot-mnist-distances --config X |
python -m uot.experiments.real_data.mnist_classification.count_pairwise_distances |
Step 1 of MNIST: pairwise OT distances | cli/mnist |
uot-mnist-classification --config X |
python -m uot.experiments.real_data.mnist_classification.mnist_classification |
Step 2 of MNIST: KNN classification | cli/mnist |
uot-inspect-store --dataset X --outdir Y |
python -m uot.problems.inspect_store |
Visualize a serialized problem dataset |
Writing your own Problem / Generator / Solver
Subclass uot.Problem, uot.Generator, or uot.BaseSolver and plug them
directly into Experiment and run_pipeline.
- Writing a custom Problem
- Writing a custom Generator
- Writing a custom Solver
- Running experiments in Python
Linting
ruff check .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uot_bench-0.1.9.tar.gz.
File metadata
- Download URL: uot_bench-0.1.9.tar.gz
- Upload date:
- Size: 326.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e7b2ebc615abd100565fb455667e6993a1cef2beb6876212a90c6df96b61567
|
|
| MD5 |
7ac08b3cda662888d3a33825ccbf9b71
|
|
| BLAKE2b-256 |
0f30922226f5c33deb2a117b0321852c05b9f0432d877e60b65c8915b1e6c648
|
File details
Details for the file uot_bench-0.1.9-py3-none-any.whl.
File metadata
- Download URL: uot_bench-0.1.9-py3-none-any.whl
- Upload date:
- Size: 371.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b81cc1990c685e0dc052b987314cdb4852bdba19b1f570c4b022450d4481b79
|
|
| MD5 |
1fe1a3bdd9a0a117d70a8a61bc2aacde
|
|
| BLAKE2b-256 |
043433b2e8cfb38462ff28ac4962b75e6185b00189bf7f32b6d9b8c8521e4ba9
|