Repository navigation
[MRG] Keep lazy Euclidean Sinkhorn cost blocks on the input backend - #925
Open
bingdongni wants to merge 3 commits into
Open
bingdongni wants to merge 3 commits into
bingdongni wants to merge 3 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_samplefor 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