Skip to content

[MRG] Keep lazy Euclidean Sinkhorn cost blocks on the input backend - #925

Open
bingdongni wants to merge 3 commits into
PythonOT:masterfrom
bingdongni:perf/lazy-euclidean-costs
Open

bingdongni wants to merge 3 commits into
PythonOT:masterfrom
bingdongni:perf/lazy-euclidean-costs

Conversation

@bingdongni

@bingdongni bingdongni commented Nov 16, 2026 •

Copy link
Copy Markdown

Motivation

ot.solve_sample(xs, xt, reg=..., lazy=True) copies both point clouds to NumPy and uploads newly computed cost blocks for every dual update, marginal check and final linear cost. Euclidean distances already have a backend implementation. Use it when both clouds and the source weights share a dtype and device. Keep the existing detached cost semantics and the NumPy conversion for other metrics or mixed types.

Tests

The regression goes through solve_sample for both Euclidean metrics and compares the linear cost with a dense reference. A separate test covers the SciPy-only Chebyshev metric. In the RTX 4060 comparison (257 × 129 points, 16 dimensions), the original solve copied four coordinate arrays to the host and uploaded 158 cost blocks (5,834,928 bytes). The patched solve made zero such transfers and returned the same linear cost, 25.535818478019777.

The FP32 cost calculation also runs at its input precision inside PyTorch autocast. The jobs exercise CPU bfloat16 and CUDA float16 autocast with nearby coordinates around 200, where casting the dot product loses precision or overflows.

The Linux job builds POT from source. The Windows GPU job uses the checkout's Python solver and the wheel's three unrelated compiled extensions. The release note and API docstring are included.

Linux CPU tests · RTX 4060 tests

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant