You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AutoencoderRAE loading error with older transformers #13279
I am trying to use AutoencoderRAE, unfortunately I cannot load it and it seems to break by giving the following error:
File ".venv/lib/python3.13/site-packages/transformers/models/dinov2_with_registers/modeling_dinov2_with_registers.py", line 529, in _init_weights
).to(module.weight.dtype)
^^
AttributeError: 'NoneType' object has no attribute 'to'
I think its because of older tokenizers, transformers and huggingface-hub versions.
from diffusers import AutoencoderRAE
model = AutoencoderRAE.from_pretrained(
"nyu-visionx/RAE-dinov2-wReg-base-ViTXL-n08"
).to("cuda").eval()
Logs
File ".venv/lib/python3.13/site-packages/transformers/models/dinov2_with_registers/modeling_dinov2_with_registers.py", line 529, in _init_weights
).to(module.weight.dtype)
^^
AttributeError: 'NoneType' object has no attribute 'to'
small patch to src/diffusers/models/modeling_utils.py
@contextmanagerdefno_init_weights():
""" Context manager to globally disable weight initialization to speed up loading large models. To do that, all the torch.nn.init function are all replaced with skip. """def_skip_init(*args, **kwargs):
passhf_modeling_utils=Nonehf_init_weights=Noneifis_transformers_available():
fromtransformersimportmodeling_utilsashf_modeling_utilshf_init_weights=hf_modeling_utils._init_weightshf_modeling_utils._init_weights=Falseforname, init_funcinTORCH_INIT_FUNCTIONS.items():
setattr(torch.nn.init, name, _skip_init)
try:
yieldfinally:
# Restore the original initialization functionsforname, init_funcinTORCH_INIT_FUNCTIONS.items():
setattr(torch.nn.init, name, init_func)
ifhf_modeling_utilsisnotNone:
hf_modeling_utils._init_weights=hf_init_weights
Activity
kashif commentedon Mar 17, 2026
thanks @arijit-hub checking
kashif commentedon Mar 18, 2026
I have fixed ImageReward to work with transformers v5, can you try with:
arijit-hub commentedon Mar 18, 2026
Hye,
Thanks for looking into it so quickly. Really appreciate it.
Unfortunately, this leads to import error in ImageReward due to transformers :(
Maybe doing something in
diffusersmakes more sense than changingImageReward?Again, thanks a lot for looking into it!
lavinal712 commentedon Oct 4, 2026
small patch to
src/diffusers/models/modeling_utils.py