Skip to content

[WIP] BSP-OT: Sparse transport plans between discrete measures in loglinear time#768

Open
dcoeurjo wants to merge 70 commits into
PythonOT:masterfrom
dcoeurjo:master
Open

[WIP] BSP-OT: Sparse transport plans between discrete measures in loglinear time#768
dcoeurjo wants to merge 70 commits into
PythonOT:masterfrom
dcoeurjo:master

Conversation

@dcoeurjo
Copy link
Copy Markdown
Contributor

@dcoeurjo dcoeurjo commented Oct 15, 2025

Initial fork and PR. (wip)

Types of changes

Original paper

Motivation and context / Related issue

How has this been tested (if it applies)

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

Added 'TBA' section to the README.
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 75.63025% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.77%. Comparing base (41a4d57) to head (c39389a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #768      +/-   ##
==========================================
- Coverage   96.87%   96.77%   -0.11%     
==========================================
  Files         113      116       +3     
  Lines       23062    23180     +118     
==========================================
+ Hits        22342    22432      +90     
- Misses        720      748      +28     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the CI label Jan 29, 2026
Comment thread ot/bsp/BSP-OT_header_only.h Outdated
Comment thread test/test_bspot.py
)


def test_bsp_ot_torch_backend():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add pytest skipif if torch not installed

Comment thread test/test_ot_openmp.py Outdated
Comment thread test/test_bspot.py Outdated
Copy link
Copy Markdown
Collaborator

@rflamary rflamary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is looking good thanks so much @dcoeurjo and @baptiste-genest . below are some comments about API.

Comment thread docs/source/all.rst
unbalanced
utils
weak
bsp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this one up to stay alphabetical please

Comment thread examples/plot_bsp_ot.py
between two large point clouds: shape morphing (and animated morphing)
and full color transfer (pixel permutation).

[?] Genest, B., Bonneel, N., Nivoliers, V., Coeurjolly, D.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the number ? is the same as in the end of the README file where you should add the reference also ;)

You should also have the same reference in the functions docstring with same number (and reference the algorithm in the paper from teh doc)

Comment thread examples/plot_bsp_ot.py
# Load point clouds
# ----------------------------
N = 100000
A = sample_ball(N)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use X_s and X_t ? A and B are used for sample weights in other exmaples

Comment thread examples/plot_bsp_ot.py
# Bijection computation
# ----------------------------------

start = time.time()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start = time.time()
ot.tic()

Comment thread examples/plot_bsp_ot.py
cost, perm, _ = ot.bsp.compute_bspot_bijection(A, B, 64, 2)
print(
"Bijection computed between {} points, with cost {} in {}s".format(
N, cost, time.time() - start
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
N, cost, time.time() - start
N, ot.toq()

return teh tiem wit better precision

Comment thread ot/bsp/bsp_ot.py
The transport cost of the final bijection.
plan : array-like, shape (n_samples,)
The final bijection, stored as a permutation (e.g. a list of numbers) such that X[i] is assigned to Y[plan[i]].
plans : list of array
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be array_like and size should be given (n_samples,n_plans)

Comment thread ot/bsp/bsp_ot.py
-------
cost : float
The transport cost of the final bijection.
plan : array-like, shape (n_samples,)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it perm, or perm_plan so that it is clear that it is a permutation, plan in POT is a OT plan (that can be sparse)

Comment thread ot/bsp/bsp_ot.py
return cost, plan, plans


def merge_bijections(X, Y, plans, lp_power=2):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def merge_bijections(X, Y, plans, lp_power=2):
def merge_bijections(X, Y, perms, p=2):

Comment thread .gitmodules
@@ -0,0 +1,3 @@
[submodule "deps/eigen"]
path = deps/eigen
url = https://gitlab.com/libeigen/eigen.git
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the version/commit of eigen here. fdor instance with branch=5.0

Comment thread RELEASES.md
- Clean documentation (PR #787)
- Fix code coverage (PR #791)
- Fix test of the version of jax in `ot.backend` (PR #794)
- Reverting the openmp fix on macOS (PR #789) for macOS (PR #796)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Reverting the openmp fix on macOS (PR #789) for macOS (PR #796)

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.

4 participants