model from_pretrained bug in 4.50.dev0 in these days
Author: M3Dade
Pull request: no
Labels: name: bug

### System Info


- `transformers` version: 4.50.dev0
- Platform: Linux-5.10.101-1.el8.ssai.x86_64-x86_64-with-glibc2.31
- Python version: 3.10.16
- Huggingface_hub version: 0.29.1
- Safetensors version: 0.5.3
- Accelerate version: 1.4.0
- Accelerate config:    not found
- DeepSpeed version: 0.15.4
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA A800-SXM4-80GB

### Who can help?

@amyeroberts, @qubvel

### Information

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

### Tasks

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

### Reproduction

code sample 
```
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor

model_path = "Qwen/Qwen2.5-VL-7B-Instruct"
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
    model_path, 
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(model_path)
```



When I configured the environment and ran the code on a new machine as usual today, I encountered the following error
```
Loading checkpoint shards:   0%|                                                                                                                                                             
 | 0/5 [00:00<?, ?it/s]                                                                                                                                                                      
[rank0]: Traceback (most recent call last):                                                                                                                                                  
[rank0]:   File "/mnt/……/Qwen2.5-VL/…r/script.py", line 14, in <module>                                                                         
[rank0]:     model = Qwen2_5_VLForConditionalGeneration.from_pretrained(                                                                                                                     
[rank0]:   File "/opt/conda/envs/…/lib/python3.10/site-packages/transformers/modeling_utils.py", line 269, in _wrapper                           
[rank0]:     return func(*args, **kwargs)                                                                                                                                                    
[rank0]:   File "/opt/conda/envs/…/lib/python3.10/site-packages/transformers/modeling_utils.py", line 4417, in from_pretrained
[rank0]:     ) = cls._load_pretrained_model(                                                  
[rank0]:   File "/opt/conda/envs/…/lib/python3.10/site-packages/transformers/modeling_utils.py", line 4985, in _load_pretrained_model                                                   
[rank0]:     new_error_msgs, offload_index, state_dict_index = _load_state_dict_into_meta_model(                                                                                             
[rank0]:   File "/opt/conda/envs/…/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context                                                              
[rank0]:     return func(*args, **kwargs)                                                     
[rank0]:   File "/opt/conda/envs/…/lib/python3.10/site-packages/transformers/modeling_utils.py", line 795, in _load_state_dict_into_meta_model                                          
[rank0]:     full_tp_plan.update(getattr(submodule, "_tp_plan", {}))                                                                                                                         
[rank0]: TypeError: 'NoneType' object is not iterable                                                                                                                                        
[rank0]:[W303 15:32:35.530123370 ProcessGroupNCCL.cpp:1250] Warning: WARNING: process group has NOT been destroyed before we destruct ProcessGroupNCCL. On normal program exit, the applicati
on should call destroy_process_group to ensure that any pending NCCL operations have finished in this process. In rare cases this process can exit before this point and block the progress o
f another member of the process group. This constraint has always been present,  but this warning has only been added since PyTorch 2.4 (function operator())
```

The version of transformers I use is 4.50.dev0, downloaded from github.
This environment will not report errors when running the same code on the machine I configured a few days ago, but today's new environment reports errors.
I solved the problem by downgrading the transformers version from 4.50.dev0 to 4.49.0.

### Expected behavior

I want to load model

Comments:
this feels like an issue with the recent TP changes, cc @arthurzucker @Cyrilvallez 

Can you give us some information on the hardware you're running this on?

- transformers  version: 4.50.dev0 
- Platform: Linux-5.10.101-1.el8.ssai.x86_64-x86_64-with-glibc2.31 
- Python version: 3.10.16 
- Huggingface_hub version: 0.29.1 
- Safetensors version: 0.5.3 
- Accelerate version: 1.4.0 
- Accelerate config: not found - DeepSpeed version: 0.15.4 
- PyTorch version (GPU?): 2.5.1+cu124 (True) - Tensorflow version (GPU?): not installed (NA) 
- Flax version (CPU?/GPU?/TPU?): not installed (NA) - Jax version: not installed 
- JaxLib version: not installed - Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in> 
- GPU type: NVIDIA A800-SXM4-80GB

Since my cloud server has been stopped, I cannot provide more hardware information

https://github.com/om-ai-lab/VLM-R1/commit/ed94a1286e689c5c3d6ae4b2d6517d79c2ee65b9
I believe this commit was also prompted by the problem described in this issue

cc @arthurzucker @cyrilvallez for that comment as well - it seems like other codebases are pinning at 4.49 to avoid this issue?

Hey! Could you check again on latest `main`? I believe this has been fixed 🤗

Thank you for your maintenance. 

Could you tell me what caused it?

Well we changed the loading logic a lot recently, so we had a few bumps along the road!

@Cyrilvallez Which PR was it changed in?

Hey @Alex-Songs! Sorry, I can't remember the exact PR that fixed this one... 🥲🤗