diffusion model load failed because safetensor
Author: jiqing-feng
Pull request: no
Labels: name: bug

### System Info

latest main branch of transformers and diffusers

### Who can help?

@ArthurZucker 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```
import torch
from diffusers import StableDiffusionInpaintPipeline

pipe = StableDiffusionInpaintPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-inpainting", torch_dtype=torch.float16)
```

output:
```
2025-12-02 05:47:31.059894093 [W:onnxruntime:Default, device_discovery.cc:164 DiscoverDevicesForPlatform] GPU device discovery failed: d
evice_discovery.cc:89 ReadFileContents Failed to open file: "/sys/class/drm/card0/device/vendor"
An error occurred while trying to fetch /home/jiqing/.cache/huggingface/hub/models--stable-diffusion-v1-5--stable-diffusion-inpainting/s
napshots/8a4288a76071f7280aedbdb3253bdb9e9d5d84bb/unet: Error no file named diffusion_pytorch_model.safetensors found in directory /home
/jiqing/.cache/huggingface/hub/models--stable-diffusion-v1-5--stable-diffusion-inpainting/snapshots/8a4288a76071f7280aedbdb3253bdb9e9d5d
84bb/unet.
Defaulting to unsafe serialization. Pass `allow_pickle=False` to raise an error instead.
Loading pipeline components...:  14%|█████████▊                                                           | 1/7 [00:00<00:03,  1.60it/s]
An error occurred while trying to fetch /home/jiqing/.cache/huggingface/hub/models--stable-diffusion-v1-5--stable-diffusion-inpainting/s
napshots/8a4288a76071f7280aedbdb3253bdb9e9d5d84bb/vae: Error no file named diffusion_pytorch_model.safetensors found in directory /home/
jiqing/.cache/huggingface/hub/models--stable-diffusion-v1-5--stable-diffusion-inpainting/snapshots/8a4288a76071f7280aedbdb3253bdb9e9d5d8
4bb/vae.
Defaulting to unsafe serialization. Pass `allow_pickle=False` to raise an error instead.
Loading weights: 100%|█████████████████████████████████| 396/396 [00:00<00:00, 458.07it/s, Materializing param=visual_projection.weight]
> /home/jiqing/transformers/src/transformers/modeling_utils.py(4489)mark_tied_weights_as_initialized()ng param=visual_projection.weight]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/venv/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/jiqing/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1021, in from_pretrained
    loaded_sub_model = load_sub_model(
                       ^^^^^^^^^^^^^^^
  File "/home/jiqing/diffusers/src/diffusers/pipelines/pipeline_loading_utils.py", line 876, in load_sub_model
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jiqing/transformers/src/transformers/modeling_utils.py", line 250, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jiqing/transformers/src/transformers/modeling_utils.py", line 4001, in from_pretrained
    model, missing_keys, unexpected_keys, mismatched_keys, offload_index, error_msgs = cls._load_pretrained_model(
                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jiqing/transformers/src/transformers/modeling_utils.py", line 4161, in _load_pretrained_model
    model.mark_tied_weights_as_initialized()
  File "/home/jiqing/transformers/src/transformers/modeling_utils.py", line 4489, in mark_tied_weights_as_initialized
    for tied_param in self.all_tied_weights_keys.keys():
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1964, in __getattr__
    raise AttributeError(
AttributeError: 'StableDiffusionSafetyChecker' object has no attribute 'all_tied_weights_keys'. Did you mean: '_tied_weights_keys'?
```

### Expected behavior

I tried to convert `stable-diffusion-v1-5/stable-diffusion-inpainting` in https://safetensors-convert.hf.space/. But found this model is already converted, but the file name seems weird: [model.fp16.safetensors](https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-inpainting/tree/main/safety_checker)

Comments:
Better places in `diffusers` imo (cc @sayakpaul ). The `StableDiffusionSafetyChecker` class inherits from `PreTrainedModel` but does not call post init which initializes tied weights



Fixed in diffusers. Close this issue.