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

update load_state_dict() signature to align with torchsnapshot #887

Closed
wants to merge 1 commit into from

Conversation

xunnanxu
Copy link
Contributor

@xunnanxu xunnanxu commented Nov 7, 2022

Summary:
Checkpointing relies on some protocol checking to make sure it takes Checkpointable modules.

The canonical protocol currently requires def load_state_dict(self, state_dict: Dict[str, Any]) -> None: but DLv2's positional argument is state instead.

So even though logically everything works this breaks static type checking, creating confusion to users.

See signature
https://github.com/pytorch/torchsnapshot/blob/28ce508ceb1db0a4f16c269b776fe88216e340f5/torchsnapshot/stateful.py#L14

Reviewed By: Miiira

Differential Revision: D41094635

Summary:
Checkpointing relies on some protocol checking to make sure it takes `Checkpointable` modules.

The canonical protocol currently requires `def load_state_dict(self, state_dict: Dict[str, Any]) -> None:` but DLv2's positional argument is `state` instead.

So even though logically everything works this breaks static type checking, creating confusion to users.

See signature
https://github.com/pytorch/torchsnapshot/blob/28ce508ceb1db0a4f16c269b776fe88216e340f5/torchsnapshot/stateful.py#L14

Reviewed By: Miiira

Differential Revision: D41094635

fbshipit-source-id: 4215bb653b22728a36a066b534939d563f622bfb
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Nov 7, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D41094635

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants