Conversation
…onOT#264) The semi-dual gradient computed exp(-(M[i] - beta) / reg) directly. Once beta grows, that overflows, the normalisation divides inf by inf, and khi comes back all-NaN, which is what makes the stochastic solvers unusable at the sizes reported in the issue. c_transform_entropic in the same module already guards against this by subtracting min(r) before exponentiating. This applies the same shift to coordinate_grad_semi_dual. It cancels in the ratio, so the returned gradient is unchanged wherever the old code did not overflow; verified to 1.7e-16 across a range of beta. Adds a test that the gradient is finite at large beta without even warning, and a test pinning the values against the unshifted formula in the regime where that formula is valid.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #866 +/- ##
=======================================
Coverage 96.86% 96.87%
=======================================
Files 128 128
Lines 26304 26326 +22
=======================================
+ Hits 25480 25502 +22
Misses 824 824 🚀 New features to boost your workflow:
|
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
Bug fix (non-breaking change which fixes an issue).
Motivation and context / Related issue
Closes #264.
coordinate_grad_semi_dualcomputesexp(-(M[i] - beta) / reg)directly. Oncebetagrows that overflows, the normalisation dividesinfbyinf, andkhicomes back all-NaN — the behaviour reported in the issue.c_transform_entropicin the same module already guards this by subtractingmin(r)before exponentiating. This applies the same shift. It cancels in the ratio, so the gradient is unchanged wherever the old code did not overflow; verified to 1.7e-16 across a range ofbeta.How has this been tested (if it applies)
Two tests: the gradient is finite at large
betawithout warning (verified to fail on master), and its values are pinned against the unshifted formula in the regime where that formula is valid. Full suite green, pre-commit clean.PR checklist