Skip to content

[BUG] load_state_dict fails if checkpoint lacks entries for TensorDictParams #1472

@egaznep

Description

@egaznep

The context is rather hard to explain, but I have already identified the problem.

Culprit:

prefix = tuple(key for key in prefix.split(".") if key)
if prefix:
data = data.get(prefix)
self.data.load_state_dict(data)

If prefix is not present in data, L1246 would set data = None and the subsequent line fails. I guess the following codeblock would solve it?

        if prefix:
            data = data.get(prefix)
        if data is not None:
            self.data.load_state_dict(data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions