fix(distributions): initialize expanded Delta instance - #2768
Open
aswanth-07 wants to merge 1 commit into
Open
Conversation
aswanth-07
marked this pull request as ready for review
August 9, 2026 16:41
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
Deltainstance returned byexpand()when GPyTorch is using its Pyro-free fallbackRoot cause and impact
The fallback implementation called zero-argument
super().__init__, which initializesself, after creating and populatingnewwith_get_checked_instance. As a result, expanding aDeltaunexpectedly changed the original distribution'sbatch_shape, while the returned object lacked_batch_shapeand_event_shapeand failed on normal distribution operations.The fix follows Pyro's reference implementation and GPyTorch's existing
MultivariateNormal.expand()pattern by initializingnewexplicitly.Fixes #2767.
Validation
main: fails because the originalbatch_shapechanges from[2]to[3, 2](and the returned object'sbatch_shaperaisesAttributeError)python -m unittest test.distributions.test_delta— 5 passedpython -m unittest discover -s test/distributions -p "test_*.py"— 47 passedpython -m ufmt check gpytorch/distributions/delta.py test/distributions/test_delta.py— passedpy -3.13 -m flake8 gpytorch/distributions/delta.py test/distributions/test_delta.py— passedflake8was run separately;require-asciiwas skipped because its Windows command did not quote this workspace path containing spaces)All tests used CPU tensors with Pyro absent, exercising the affected fallback.
AI assistance
Codex assisted with repository inspection, reproduction, duplicate searching, implementation, tests, and drafting this pull request. I reviewed the diff and validation results.