Skip to content

[MRG] Fix entropic regularization in gcg#817

Open
MatDag wants to merge 10 commits into
PythonOT:masterfrom
MatDag:fix_gcg
Open

[MRG] Fix entropic regularization in gcg#817
MatDag wants to merge 10 commits into
PythonOT:masterfrom
MatDag:fix_gcg

Conversation

@MatDag
Copy link
Copy Markdown

@MatDag MatDag commented May 29, 2026

Types of changes

When gcgcalls generic_conditional_gradient, it must be with reg2 = None since the entropic regularization is already taken into account in the inner sinkhorn solver.

Motivation and context / Related issue

This PR solves #758

How has this been tested (if it applies)

n = 100
X = ot.datasets.make_2D_samples_gauss(n, m=[0, 0], sigma=np.eye(2))
Y = ot.datasets.make_2D_samples_gauss(n, m=[1, 1], sigma=np.eye(2))

M = ot.dist(X, Y)
M /= M.max()

a = ot.unif(n)
b = ot.unif(n)

reg = 1e-2

pi1 = ot.optim.gcg(a, b, M, reg, 0., lambda x: 0., lambda x: np.zeros(x.shape), numInnerItermax=1000)
pi2 = ot.sinkhorn(a, b, M, reg, numItermax=1000)

assert np.allclose(pi1, pi2, atol=1e-5)  # now works

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.

MatDag and others added 8 commits September 13, 2025 18:47
* linear ot implemented

* improve stopping criterion and assymetric case

* Add recompute_const and simplify the pipeline for the symmetric = False

* add tests

* update the examples and rename to follow the "ot.solve" naming conventions

* update realeases.md

* idem

* move set_grad_enabled to backend

* set_grad_enabled for quadratric solver

* update doc

* remove useless importation in doc

* Update references

* update example

* Remove classes in quadratic, move examples to backend, add potentials, remove context managers for grads. To do: improve doc and tests

* updat tests

* Massive improvement of the documentation for ot.batch

* cover (almost) all ot.batch with tests

* bug in the tests

* update docstring

* highlight that ot.batch is solving the entropic version

* removing yet another error in the docstring

* Add missing parameter recompute_const

* Remove png, add all backends and gradient mode to tests

* add the missing pytest

* change .sum() into nx.sum

* add missing backend

* yet another missing nx

* remove useless squeeze and add test for non-log bregman

* remove last_step from quadratic tests

* add missing tests and improve documentation

* proper unsqueeze test

* add unsqueeze to tensorflow

* solve double backprop issue in test_gradients_torch

---------

Co-authored-by: PaulKrzakala <paul.krzakala@gmail.com>
Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
Co-authored-by: Cédric Vincent-Cuaz <cedvincentcuaz@gmail.com>
* Fix deprecation warning of .T for 1-d inputs

* Update RELEASES.md
….6 (PythonOT#759)

* fatser tests

* add tests

* add new build wheels

* add python 3.13

* keep version macos

* python 3.12 on macosx

* release

* ste release version number

* remove macos-13

* move solve_batch and solve_gromov_btac and dist in main ot
* Release 0.9.6

* Update RELEASES.md

* Update RELEASES.md

---------

Co-authored-by: Cédric Vincent-Cuaz <cedvincentcuaz@gmail.com>
* change version number and update manifest

* use proper numbering

* use proper numbering

* pr number

* last one?
@MatDag MatDag changed the title Fix entropic regularization in gcg [MRG] Fix entropic regularization in gcg May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.79%. Comparing base (fab3507) to head (f84e1f8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #817      +/-   ##
==========================================
- Coverage   96.80%   96.79%   -0.02%     
==========================================
  Files         118      118              
  Lines       23721    23721              
==========================================
- Hits        22963    22960       -3     
- Misses        758      761       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Thanks @MatDag for this PR and catching the problem.

cold you had a very quick test that checks for equality small p small number of iters) so that we will avoid regressions in the future?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants