Skip to content

Investigate getting all globals that need to be added to torch.serialization.add_safe_globals in one call rather than iteratively #129698

@mikaylagawarecki

Description

@mikaylagawarecki

as title

Right now the process is to keep doing this until the torch.load eventually succeeds

torch.load(f, weights_only=True)
# Fails with Unsupported GLOBAL: {bla} ... and says to use `add_safe_globals` if it is safe
torch.add_safe_globals([bla])

We should see whether we can get all the GLOBALs in the checkpoint in one go in an efficient manner to make the process more low friction. Not sure whether this is possible without code execution though.

A possibility is that we could parse the pickletools.dis("data.pkl") for GLOBAL

Thanks @vmoens for suggesting this :)

Versions

main

cc @mruberry

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: serializationIssues related to serialization (e.g., via pickle, or otherwise) of PyTorch objectstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions