solves AttributeError: 'State' object has no attribute 'rng_states'#2412
Merged
vfdev-5 merged 9 commits intopytorch:masterfrom Jan 10, 2022
bibhabasumohapatra:solves-error-rng_states
Merged
solves AttributeError: 'State' object has no attribute 'rng_states'#2412vfdev-5 merged 9 commits intopytorch:masterfrom bibhabasumohapatra:solves-error-rng_states
vfdev-5 merged 9 commits intopytorch:masterfrom
bibhabasumohapatra:solves-error-rng_states
Conversation
Collaborator
|
@bibhabasumohapatra please add a test for state_dict method |
vfdev-5
reviewed
Jan 9, 2022
vfdev-5
reviewed
Jan 9, 2022
| def state_dict(self) -> OrderedDict: | ||
| setattr(self.state, "rng_states", _get_rng_states()) | ||
| state_dict = super(DeterministicEngine, self).state_dict() | ||
| state_dict["rng_states"] = _get_rng_states() |
Collaborator
There was a problem hiding this comment.
Let's keep this, instead of setattr(self.state, "rng_states", _get_rng_states())
EDIT:
Main point here is that engine.state.rng_states does not (and is not intended to) reflect rng states at each moment as rng states are dynamically changing. Thus we kept engine.state.rng_states is None once provided rng state was applied in _setup_engine method. If we leave engine.state.rng_states with a certain value then it wont reflect the latest state and thus provides some wrong info. => I propose to keep engine.state.rng_states as None and do not compare with sd["rng_states"].
vfdev-5
approved these changes
Jan 10, 2022
Collaborator
vfdev-5
left a comment
There was a problem hiding this comment.
Thank for the PR @bibhabasumohapatra !
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.
Fixes #2197
Description:
returns:
AttributeError: 'State' object has no attribute 'rng_states'
Check list: