Skip to content

Bug report: This line causes error when using MADGRAD optimizer & resume training #11741

@circlecrystal

Description

@circlecrystal

https://github.com/PyTorchLightning/pytorch-lightning/blob/8c07d8bf905e395bbd2142b5df7b185b8e936c41/pytorch_lightning/trainer/connectors/checkpoint_connector.py#L284

The reported error is:
File "/home/tiger/.local/lib/python3.7/site-packages/pytorch_lightning/trainer/connectors/checkpoint_connector.py", line 283, in restore_optimizers for k, v in state.items(): AttributeError: 'Tensor' object has no attribute 'items'

For MADGRAD, optimizer.state["k"] is tensor-type instead of mapping type. Therefore, we need to fix this problem for making Pytorch Lightning compatible with such kind of optimizers.

The correct way of fixing this issue is changing it to:
Screen Shot 2022-02-05 at 4 57 59 AM

cc @awaelchli @ananthsub @ninginthecloud @rohitgr7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcheckpointingRelated to checkpointingwon't fixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions