fix(priors): avoid RecursionError when moving MultivariateNormalPrior to device - #2
Draft
castor639 wants to merge 1 commit into
Draft
fix(priors): avoid RecursionError when moving MultivariateNormalPrior to device#2castor639 wants to merge 1 commit into
castor639 wants to merge 1 commit into
Conversation
cursor
Bot
force-pushed
the
mvn-prior-cuda-recursion
branch
from
August 29, 2026 17:16
9012e44 to
9cf32ae
Compare
…evice Check BUFFERED_PREFIX before hasattr in Prior.__setattr__ so torch lazy_property caching (e.g. covariance_matrix) does not re-enter. Also clear MVN lazy properties in to(), matching cuda()/cpu().
cursor
Bot
force-pushed
the
mvn-prior-cuda-recursion
branch
from
August 29, 2026 17:16
9cf32ae to
5e6fa38
Compare
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
Addresses the
MultivariateNormalPriorRecursionErrorreported in cornellius-gp#2679 (device /.cuda()path).Prior.__setattr__evaluatedhasattr(self, name)before checking for the buffered-attribute prefix. Fortorch.distributionslazy properties such ascovariance_matrix, thathasattrre-enters the lazy property getter, which caches viasetattr, causing infinite recursion after.cuda()/.to()/.cpu()clears and recomputes those properties.This PR:
BUFFERED_PREFIXbeforehasattrinPrior.__setattr__to(), consistent with existingcuda()/cpu()Out of scope:
LKJPrior/HalfCauchyPriorGPU failures from cornellius-gp#2679 are left for cornellius-gp#2581, as noted by the reporter.Upstream: Opening against
cornellius-gp/gpytorchreturned 403. Prefer:cornellius-gp/gpytorch@main...castor639:gpytorch:mvn-prior-cuda-recursion
Test plan
python -m unittest test.priors.test_multivariate_normal_priorpython -m unittest discover -s test/priors/test_multivariate_normal_prior_to_gpuwhen CUDA is available