You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug fix: DictStateful fails to load state_dict (#1028)
Summary:
Pull Request resolved: #1028
### Bug Fix: DictStateful Fails to Load State Dict
#### Overview
This diff addresses a bug in the `DictStateful` class where it fails to load the state dictionary. The fix involves modifying the `state_dict` method to return a copy of the dictionary instead of the original dictionary. Additionally, the `load_state_dict` method is updated to clear the dictionary before loading the new state.
#### Changes
* `fbcode/torchtnt/utils/stateful.py`:
* The `state_dict` method is updated to return a copy of the dictionary (`self.copy()`) instead of the original dictionary (`self`).
* `fbcode/torchtnt/tests/utils/meta/test_stateful.py`:
* Test cases are added to verify the correctness of the `DictStateful` class, including a test for checkpointing.
#### Impact
This bug fix ensures that the `DictStateful` class functions correctly when saving and loading its state dictionary. This is crucial for maintaining the accuracy and reliability of machine learning models that rely on this class.
Reviewed By: JKSenthil
Differential Revision: D81674115
fbshipit-source-id: 6ee8e8a5d91733dd46a59198316554cff68f8b7f
0 commit comments