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

Only include arg_constraints in pytree_data_fields if they are not lazy_propertys. #1929

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

tillahoffmann
Copy link
Contributor

This PR tries to address #1928 to obtain consistent pytree structures.

On a related note, similar behavior is observed with the get_args method. I'm not sure what the "correct" behavior should be in this case.

>>> import jax
>>> from jax import numpy as jnp
>>> from numpyro import distributions as dists
>>> 
>>> 
>>> def make_dist():
>>>     return dists.MultivariateNormal(precision_matrix=jnp.eye(2))
>>> 
>>> 
>>> init = make_dist()
>>> init.get_args()
{'loc': array([0.]),
 'precision_matrix': Array([[1., 0.],
        [0., 1.]], dtype=float32),
 'scale_tril': Array([[1., 0.],
        [0., 1.]], dtype=float32)}
>>> init.covariance_matrix
>>> init.get_args()
{'loc': array([0.]),
 'covariance_matrix': Array([[1., 0.],
        [0., 1.]], dtype=float32),
 'precision_matrix': Array([[1., 0.],
        [0., 1.]], dtype=float32),
 'scale_tril': Array([[1., 0.],
        [0., 1.]], dtype=float32)}

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

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

LGTM! Re get_args: it depends on the definition of the method. It might be worth to add a clear description there. Any method with lazy properties might give inconsistent behaviors, not just with get_args.

@fehiepsi fehiepsi merged commit b74c0e9 into pyro-ppl:master Dec 5, 2024
9 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