Repository navigation
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.
Types of changes
Performance improvement to classical dense NumPy Sinkhorn, an optional accuracy parameter, documentation, and regression tests.
Motivation and context / Related issue
This PR brings Residual Sinkhorn to supported dense NumPy calls in
ot.sinkhornandot.bregman.sinkhorn_knopp. It reduces work at the same requested marginal tolerance, without requiring users to change their calls.The approach grew out of our work on Brenier maps: a residual-based check lets supported solves stop earlier at the same marginal tolerance. The implementation also avoids a second kernel allocation and reuses matrix products and fixed-cost kernels. See the Residual Sinkhorn project page for the mathematical derivation and how the idea transfers from Brenier maps to Sinkhorn.
This PR also extends the earlier adapter to a case where it did not help. In repeated solves such as point-cloud registration, the previous plan’s scalings can be a good warm start, but the next marginal check after the first update may not occur until update 11. Supported warm calls check the same marginal target after updates 2–4 as well. Before an early return, both marginals are checked on the actual returned array; calls requesting a scaling log retain the scalings for the next solve. Shared input and residual checks reuse work without changing the schedule. Unsupported ordinary requests use POT's existing path. Other backends and
sinkhorn2are outside this change.The optional
plan_tolargument is for callers who explicitly need a whole-plan error target. It is unset in all default-call benchmarks below.Related: #934. Thanks to @xihaian251 for independently checking the mathematical argument and for an independent port and timing study of two earlier implementation changes. Reproduction archive.
How has this been tested?
Same marginal tolerance, no additional accuracy request
These are direct reruns of stock POT, the original standalone adapter, and the final candidate (source tree from
66ce7cc). All used the same marginal tolerance and iteration budget within a workload, withplan_tolunset. Twelve order-balanced single-core, single-BLAS-thread trials were used; grouped figures sum per-setting medians. For the 56-frame jobs, each solver evolves its own poses from identical starting inputs.Most gains in the first four rows were already present in the adapter. In the 192-point warm-start example, total updates dropped from 58 to 13. In a prior controlled comparison, changing only the check schedule in the same implementation took 2.33 to 1.88 ms. In the final direct rerun, all eight targeted registration settings had shorter medians than stock, and the five complete 56-frame runs took 16–38% less time. All 304 registration plans met
stopThr=1e-7on both marginals. Across the additional 160 settings the final candidate returned another 5,417 plans meeting their requested marginal tolerances. Earlier exits can change the plan and its error against a tighter numerical reference even when marginal tolerances match.Final integrated candidate
Separately, we measured the effect of removing shared validation work in the final candidate. A separate matched replay against
0460680reduced time across the 168 archived application settings by 2.21% in aggregate. The two dense MNIST batches took 2.75% and 3.03% less time; the four terminal registration settings took 3.86% less. These percentages are from the direct final-versus-previous comparison; they are not inferred from or added to the direct three-way timings above.Two of 186 settings were initially more than 3% slower than the preceding candidate; neither reproduced that slowdown in 36 paired reruns. Very small problems that already converge on update one can still favor stock. In this follow-up, the cold-cache identical-seed 8×8 case took 29.8 µs in stock and 38.4 µs in the final candidate; the 32×128 case took 47.2 and 53.6 µs. These are controlled stress tests. A separate repeated-call stream retained roughly 1 µs of overhead per 8×8 call after the check cleanup. None of these measurements implies a universal speedup.
The final public entry point matched
0460680on returned plan contents, marginal residuals and warning messages over 5,739 calls across 186 settings. The earlier native Linux suite of this exact source tree with GCC completed with 1,585 passed, 170 skipped, and 4 expected failures. The focused coverage includes warm starts that exit on updates 2–4, logged scalings, unsupported inputs and numerical rollback. Separate explicit-TV regressions test supported requests and failure to meet the requested bound. A fresh checkout of the final Python code also passed 126 focused tests (10 skipped) using the released binaries for unchanged extensions. The local HTML build completed with gallery execution disabled, and the new full-plan example ran separately.Full benchmark tables and case studies. The reusable RGB summary and the MNIST grid experiment on the project page are separate research implementations, not included in this patch.
PR checklist
RELEASES.md.