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

Support pickling MCMC objects with enumeration #1577

Merged
merged 4 commits into from
Apr 19, 2023

Conversation

tare
Copy link
Contributor

@tare tare commented Apr 14, 2023

This PR aims to solve the issue reported in #1576.

Moved the inner functions

def config_fn(site):
if (
site["type"] == "sample"
and (not site["is_observed"])
and site["fn"].has_enumerate_support
):
return {"enumerate": site["infer"].get("enumerate", default)}
return {}
and
def config_fn(site):
if (
site["type"] == "sample"
and (not site["is_observed"])
and (sites is None or site["name"] in sites)
):
return {"kl": site["infer"].get("kl", "analytic")}
return {}
return infer_config(fn, config_fn)
outside of the functions config_enumerate and config_kl, respectively. I'm not sure in which use cases the current version of config_kl would produce issues but since it was using the same nested function pattern I updated it as well.

Implemented a couple of tests based on some existing tests to verify the appropriateness of the changes.

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.

Nice solution! Thanks for supporting this feature, @tare!

@fehiepsi fehiepsi merged commit ffca0b8 into pyro-ppl:master Apr 19, 2023
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