Stabilize Gaussian mixture backward passes#3452
Open
jburroni wants to merge 3 commits into
Open
Conversation
Collaborator
|
thanks @jburroni! your diff changed a bunch of other files so you'll need to fix that if you want this reviewed and merged |
Contributor
Author
|
Hi @martinjankowiak! The GH actions seem to be broken, and I don't know how to proceed. What do you suggest? |
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
This PR fixes numerical instabilities in the backward passes for Pyro's Gaussian mixture distributions:
MixtureOfDiagNormalsGaussianScaleMixtureMixtureOfDiagNormalsSharedCovarianceThe affected backward paths can materialize very small density/product terms in probability space. In float32, these terms can underflow to zero, which can then produce nonfinite gradients during backpropagation.
Changes
Adds regression tests that assert finite gradients in numerically sensitive high-dimensional / small-scale cases.
Updates the affected backward computations to avoid unstable probability-space divisions/products where possible.
Format code to pass lint.
Tests
Added regression coverage for:
small-scale
MixtureOfDiagNormalssmall-scale
GaussianScaleMixturehigh-dimensional
MixtureOfDiagNormalsSharedCovarianceEach test verifies that samples, losses, and parameter gradients remain finite.