Skip to content

load_from_checkpoint returns None #20607

@shmuelyo

Description

@shmuelyo

Bug description

On calling load_from_checkpoint i get 'None'.
I tried debugging the issue and saw that the lightning module class is initialized successfully in _load_from_checkpoint (line 91 in saving.py), but at the end return model.to(device) returns None (line 99 in saving.py).
AFAIK this is the expected behavior of pytorch's to, which is why i believe this is a bug.
And just FYI, loading the model works fine when i initialize the lightning module class and call pytorch's load_state_dict.
I'm using pytorch-lightning 2.5.0.post0 with python 3.12 and pytorch 2.5.1.
Image

What version are you seeing the problem on?

master

How to reproduce the bug

Error messages and logs

None

Environment

Current environment
* CUDA:
        - GPU:
                - Tesla T4
        - available:         True
        - version:           12.4
* Lightning:
        - lightning-utilities: 0.11.9
        - pytorch-lightning: 2.5.0.post0
        - torch:             2.5.1
        - torchmetrics:      1.6.1
        - torchvision:       0.20.1
* System:
        - OS:                Linux
        - architecture:
                - 64bit
                - ELF
        - processor:         x86_64
        - python:            3.12.3

More info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageWaiting to be triaged by maintainersver: 2.5.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions