Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MVN.expand() to support non-lazy MVN & reuse scale_tril where possible #2623

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

saitcakmak
Copy link
Collaborator

The previous implementation of MVN.expand() would error out when MVN was not lazy (since self._covar is not defined) and would discard the scale_tril, requiring its re-computation down the line. This PR updates MVN.expand() to support both lazy and non-lazy MVN and to re-use scale_tril whenever possible.

Test Plan:
Added unittests for MVN.expand().

else:
# Non-lazy MVN is represented using scale_tril in PyTorch.
# Constructing it from scale_tril will avoid unnecessary computation.
# Initialize using __new__, so that we can skip __init__ and use scale_tril.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems slightly hairy - would an alternative here be to just add support for MultivariateNormal to be initialized directly from the scale_tril?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'd be an option. I didn't want to touch it since it can potentially affect correctness of MVN. But it doesn't seem like _covar is directly used anywhere, so it may be safer than I initially though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what would we do if both covar and scale_tril are provided? Do we validate that they are compatible? This would require re-computing one or the other, not the cheapest operation. Seems to conflict with the goal of re-using whenever these are available.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we could also just make it such that we error out if both of them are provided.

@saitcakmak saitcakmak requested a review from Balandat January 21, 2025 18:39
@saitcakmak saitcakmak merged commit b37a85b into cornellius-gp:main Jan 22, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants