Fix PyroModule registration of frozen parameters - #3469
Open
tandede wants to merge 1 commit into
Open
Conversation
Author
|
Hi maintainers, I wanted to follow up on this PR in case it was overlooked. It fixes registration of frozen parameters in PyroModule and is ready for review. Please let me know if any changes or additional validation would be useful. Thank you! |
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.
Proposed changes
PyroModulecurrently emits apyro.paramstatement whenever a regulartorch.nn.Parameteris read during a module call.ParamStoreDictmakes registered tensors trainable, so this silently changes parameters created withrequires_grad=Falsetorequires_grad=Trueand adds them to the parameter store.This change:
pyro.module();PyroModulecontext;The regression test covers both parameter-store modes, parameters created during initialization, and parameters assigned dynamically during
forward().Fixes #3438.
Tests
pytest -q tests/nn/test_module.py(69 passed, 1 xfailed)pytest -q tests/params/test_module.py(7 passed)pytest -q tests/infer/test_autoguide.py -k 'test_exact and not AutoGaussianFunsor'(29 passed)pytest -q tests/distributions/test_spanning_tree.py(66 passed, 60 skipped, 6 xfailed)ruff check .black --check pyro/nn/module.py tests/nn/test_module.pypython scripts/update_headers.py --checkmypy --warn-unused-ignores pyro/nn/module.py tests/nn/test_module.py