Skip to content

[WIP] Add a stablized function entropic_partial_wasserstein_logscale#724

Open
wzm2256 wants to merge 5 commits into
PythonOT:masterfrom
wzm2256:my-feature
Open

[WIP] Add a stablized function entropic_partial_wasserstein_logscale#724
wzm2256 wants to merge 5 commits into
PythonOT:masterfrom
wzm2256:my-feature

Conversation

@wzm2256
Copy link
Copy Markdown

@wzm2256 wzm2256 commented Mar 13, 2025

  1. add a new function called entropic_partial_wasserstein_logscale to ot.partial. This function solves the same problem as entropic_partial_wasserstein but is computed in logscale, so it is more robust.

  2. Test exampless are provided in compare_logscale_POT.py. Test data is in data\entropic_partial_OT_cost.txt

Types of changes

I implement a new function entropic_partial_wasserstein_logscale that solves exactly the same problem as the one in entropic_partial_wasserstein in log scale. The new function is a line-to-line translation of the old one, and the input/output format is exactly the same.

I do not remove the old function because the new function can be slower due to the use of the logsumexp trick. So when there is no Nan error, the old function is favored.

Motivation and context / Related issue

#723

How has this been tested (if it applies)

I test the new function entropic_partial_wasserstein_logscale against the old one entropic_partial_wasserstein in the example file 'compare_logscale_POT.py` for both numpy and pytorch.

  1. When eps is large, the old and new function produces exactly the same result
  2. When eps is small, the old function produce an error, but the new function works well.

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.

I could not build the document in my laptop due to some errors:

Theme error:
no theme named 'sphinx_rtd_theme' found (missing theme.toml?)

so I am not completely sure whether the document is fine, although I only added a few sentences to the docs.

Also, I do not know how to use pytest to test my code. If this is necessary, I may need some help here.

wzm2256 added 2 commits March 13, 2025 11:43
ot.partial. This function solves the same problem as
entropic\_partial\_wasserstein but is computed in logscale, so it is
more robust.

2. Test exampless are provided in compare_logscale_POT.py. Test data is
   in data\entropic_partial_OT_cost.txt
@rflamary
Copy link
Copy Markdown
Collaborator

Hello @wzm2256 and thanks for the PR we are indeed missing a stabilized partial entropic ot solver.

When we add a stabilized solver, we usually add the function and make the original function as a wrapper when we add the log implementation (see how it is done for function ot.sinkhorn ) so that with an additional parameter method='sikhorn_log' one can select the stabilized solver. Could you please do that and add the tests ?

Finally your example is nice we usually try to add a visualization and we really try not to add raw data to the git. Could you design a simulated example instead of a new dataset?

Thanks again for your work, we will do a proper code review as soon as possible but wold prefer to do that after the comments above are taken into account.

@rflamary rflamary changed the title [MRG] Add a stablized function entropic_partial_wasserstein_logscale [WIP] Add a stablized function entropic_partial_wasserstein_logscale Mar 28, 2025
@wzm2256
Copy link
Copy Markdown
Author

wzm2256 commented Mar 28, 2025

Sure! I will work on that.

@rflamary
Copy link
Copy Markdown
Collaborator

Hello @wzm2256 , quick reminder that we are waiting for a few changes here.

@prateekiiest
Copy link
Copy Markdown

I tested the current implementation, for some reason its extremely slow at the first iteration itself.

hinanohart added a commit to hinanohart/mosaicraft-active-vision that referenced this pull request May 16, 2026
Two planning artefacts so the next session does not have to rebuild
this context cold:

paper/outline.md — 7 headline claims for an Insights from Negative
Results / OTML workshop preprint. Every claim links to its evidence
JSON or test. Two negative results (Sinkhorn loses to Hungarian
across all ε / framings; Oklch pool aug hurts Sinkhorn) and two
positive ones (log-domain numerical stability; Oklch pool aug
improves Hungarian) are framed honestly, not buried. Limitations,
discussion mechanism argument, and reproducibility checklist are
sketched.

notes/pot-pr-724-rescue.md — investigation of
PythonOT/POT#724 (entropic_partial_wasserstein_logscale, [WIP]
since 2025-03, mergeable=CONFLICTING since 2025-09). The author
self-flagged "I do not know how to use pytest" as the blocker;
this repo's test_matching.py §numerical-stability scaffolding maps
onto exactly that gap. The note records a 9-step rescue plan and
the co-authorship proposal text to send to @wzm2256 and @rflamary.
Execution is gated on R14 user sign-off (PROGRESS row 21).
hinanohart added a commit to hinanohart/mosaicraft-active-vision that referenced this pull request May 16, 2026
…escue patch

Phase 3 tightened to N=8 seeds × N=4 targets = 32 paired runs per
condition. Both Phase-3 signs hold and CIs narrow:

  hungarian_no_aug      0.4990 ± 0.031   baseline
  hungarian_oklch_aug   0.5255 ± 0.022   Δ +0.0264 [+0.018, +0.036] BEATS
  sinkhorn_no_aug       0.4717 ± 0.041   baseline
  sinkhorn_oklch_aug    0.4295 ± 0.042   Δ -0.0421 [-0.047, -0.037] WORSE

Snapshot: experiments/results/phase3_baseline_tight_2026-05-16.json.

Figures:

  paper/figures/fig_paired_ci.{pdf,png}     Phase-2 ε sweep CIs (left)
                                            + Phase-3 oklch-aug split CIs
                                            (right), side-by-side.
  paper/figures/fig_L_preservation.{pdf,png}  Per-pixel ΔL* histogram
                                                across the default Oklch
                                                rotation schedule on a
                                                real image. max|ΔL*| ≤ 0.01.

Both regenerable via the make_*.py scripts next to them.

paper/preprint.md — full draft of the Insights/OTML/arXiv preprint
from paper/outline.md (≤ 8-page workshop length, 9 sections + 2
appendices). Every numeric claim cites a JSON snapshot or test path.

paper/outline.md — venue deadline survey added (2026-05-16):

  - ICBINB 2026: deadline Jan 31 2026 — MISSED.
  - Insights from Negative Results in NLP @ EMNLP 2026: workshop
    Oct 22-29 Budapest; CFP TBA.
  - OTML @ NeurIPS 2026: not yet announced.
  - Plan-of-record: arXiv first, then Insights@EMNLP when CFP opens.

notes/pot-pr-724-rescue.patch — local rescue of PythonOT/POT#724
built on /tmp/POT (not pushed). Single commit, 5 files changed,
+371/−8 lines. 17/17 partial-OT tests pass on the rescue branch.
Fork + push + PR comment remain R14-gated.

PROGRESS.md — rows 20–27 brought up to date; 20 and 21 are now ◐
(local prep done, external push gated on user sign-off).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hinanohart
Copy link
Copy Markdown

@wzm2256 @rflamary @cedricvincentcuaz — hello! I'm a downstream user of entropic_partial_wasserstein and hit exactly the NaN regime described in #723. I've prepared the missing pieces (pytest cases, Sphinx-Gallery example, docs blurb, RELEASES.md) as a rescue follow-up at #811.

Why a separate PR instead of pushing here: ot/partial.py was split into the ot/partial/ package after this PR opened, so the diff against current master is now mostly unrelated movement. Re-applying just @wzm2256's function on the new layout is cleaner than rebasing through that split.

I'm happy to do whichever you prefer:

  1. Keep [WIP] entropic_partial_wasserstein_logscale: stable log-domain solver (rescue of #724) #811 as the canonical rescue PR (default) — wzm2256 retained as algorithm author in the description.
  2. Close [WIP] entropic_partial_wasserstein_logscale: stable log-domain solver (rescue of #724) #811 and push these commits to this branch — if @wzm2256 grants write access, or if @rflamary / @cedricvincentcuaz prefers to keep [WIP] Add a stablized function entropic_partial_wasserstein_logscale #724 as the canonical PR.

Either way, the goal is to get the function in so issue #723 closes. Let me know which path you want.

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.

5 participants