Skip to content

update load_state_dict() signature to align with torchsnapshot#887

Closed
xunnanxu wants to merge 1 commit intometa-pytorch:mainfrom
xunnanxu:export-D41094635
Closed

update load_state_dict() signature to align with torchsnapshot#887
xunnanxu wants to merge 1 commit intometa-pytorch:mainfrom
xunnanxu:export-D41094635

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