Skip to content

Bug: torch.load with weights_only=True (PyTorch 2.6 default) fails on checkpoints containing easydict.EasyDict — SETITEMS error #9

@AhmedTrb

Description

@AhmedTrb

Subject: Bug: torch.load with weights_only=True (PyTorch 2.6 default) fails on checkpoints containing easydict.EasyDict — SETITEMS error

Bug Report

Environment

  • PyTorch version: 2.6+
  • Platform: Google Colab (CUDA)
  • Model: DiffFuSR (SR + Fusion network)

Description

Since PyTorch 2.6 changed the default of weights_only from False to True in torch.load, loading checkpoints that contain easydict.EasyDict objects now raises an UnpicklingError. This affects any model checkpoint saved with EasyDict in its state dict or config.

Steps to Reproduce

import torch
from pathlib import Path

# Any checkpoint that was saved with easydict.EasyDict in its state
checkpoint = torch.load('model.ckpt', map_location='cpu')  # weights_only=True by default in 2.6

Error Message

torch.serialization.UnpicklingError: Weights only load failed.
WeightsUnpickler error: Can only SETITEMS for dict, collections.OrderedDict,
collections.Counter, but got <class 'easydict.EasyDict'>

Adding easydict.EasyDict via torch.serialization.add_safe_globals([easydict.EasyDict]) does not resolve the issue — the SETITEMS restriction is a separate, deeper limitation in the weights-only unpickler.

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