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 scan for Trace_ELBO #1693

Merged
merged 10 commits into from
Dec 18, 2023
Merged

Support scan for Trace_ELBO #1693

merged 10 commits into from
Dec 18, 2023

Conversation

deoxyribose
Copy link
Contributor

Issue #1685

Reuse the substitute_stack to store the replay trace, and replay the sites in the scan'ed function one iteration at a time.

@fehiepsi
Copy link
Member

fehiepsi commented Dec 4, 2023

Nice support, @deoxyribose! Could you add tests for this change?

frans added 2 commits December 6, 2023 13:12
@deoxyribose
Copy link
Contributor Author

deoxyribose commented Dec 6, 2023

I've added a test that does SVI with an AutoNormal guide, and checks that results are relatively accurate. I've kept model and data size to a minimum, the test takes around 3-4 seconds on my machine. There already was a test combining scan, SVI and AutoNormal (test_subsample_guide in test/infer/test_autoguide.py), but it doesn't run inference and checks results, so the current version of scan passes it.

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.

Looks great! Thanks, @deoxyribose !

site["value"] = site["value"][i]
return site

return {k: get_ith_value(v.copy()) for k, v in replay_trace.items()}
Copy link
Member

Choose a reason for hiding this comment

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

nit: it is better to do the copy inside git_ith_value

@fehiepsi fehiepsi merged commit fb7a029 into pyro-ppl:master Dec 18, 2023
4 checks passed
@OlaRonning OlaRonning deleted the master branch February 28, 2024 10:31
OlaRonning added a commit to aleatory-science/numpyro that referenced this pull request May 6, 2024
* scan replay handling

* fix off by one error

* cleaned a bit

* lint

* use substack

* handle custom guides

* handle empty value shape

* a

* test

* move copy inside get_ith_value

---------

Co-authored-by: frans <[email protected]>
Co-authored-by: OlaRonning <[email protected]>
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.

3 participants