Repository navigation
[MRG] Restore dual feasibility at zero-mass bins in d-MMOT - #933
Open
xihaian251 wants to merge 1 commit into
Open
xihaian251 wants to merge 1 commit into
xihaian251 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #933 +/- ##
=======================================
Coverage 97.09% 97.09%
=======================================
Files 130 130
Lines 27229 27258 +29
=======================================
+ Hits 26437 26466 +29
Misses 792 792 🚀 New features to boost your workflow:
|
5 of 7 tasks
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.
Summary
ot.lp.dmmot_monge_1dgrid_losscan return dual potentials that are not feasible when an input histogram contains exact zero-mass bins. The dual objective still equals the primal value because the offending bins carry zero mass, but the returned array is not a dual certificate and therefore is not a valid subgradient for autograd.Minimal exact example (
d=2,n=2):The true primal and the reported dual objective are both 0, but the returned dual violates feasibility at
(1,1). The root cause is in the original greedy dual construction: the first main-loop update raises one marginal's potential when a bin is exhausted, while a zero-mass bin in the other marginal never receives the compensating potential. Terminal fill-in does not repair it. PR #923 does not create this defect; it faithfully exposes the invalid dual through Torch backward.Fix
After the greedy dual construction, exact zero-mass bins are lowered to
Greedy increments for the max-min Monge cost lie in
{−1,0,+1}, so original potentials are bounded in absolute value byn−1. Any tuple containing a zero bin therefore has dual sum at most−B+(d−1)(n−1)=0≤c. Tuples whose indices all have positive mass are feasible by an ε-perturbation argument: strictly positive marginals admit the original Monge greedy primal-dual theorem; positive-bin potentials converge as ε→0; feasibility inequalities are closed. Changing zero-mass potentials leaves the dual objective unchanged, so the repaired dual remains optimal.This returns a valid dual subgradient representative at zero-mass boundaries. It does not claim that the value is differentiable there, nor that the returned subgradient is unique.
Evidence, separated by method
linprogOracle was run on a 958-case subset of the above suite, with no objective or feasibility failures. The remaining cases were checked by direct constraint evaluation and primal/dual objective comparison, not bylinprog.Combined with PR #923, Torch shape, dtype and cotangent tests pass, and the zero-boundary one-sided subgradient inequality holds. Local real merges with #923 in both orders produce identical production code and pass 17/17 combined d-MMOT tests.
Compatibility and cost
Strictly positive and near-zero positive inputs are unchanged. The repair adds one
O(nd)zero scan and at mostO(nd)assignments. The full solver isO(nd²)time whendis variable because each greedy iteration recomputes max/min over thedcoordinates; withdfixed, it isO(n). Space isO(nd).Scope and limitations
This PR fixes the original dual construction. PR #923 fixes a separate Torch
set_gradientsregistration bug; the two patches are independent and complementary. CUDA and TensorFlow were not tested; JAXgradremains unsupported by the current NumPy-conversion path. No unique-gradient claim is made at nonsmooth zero-mass boundaries.