Qwen2.5-GGUF loading failed with transformers v5
Author: Kaihui-intel
Pull request: no
Labels: name: bug

### System Info

transformers v5.0.0rc3

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [x] 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

test script
```python
from transformers import AutoModelForCausalLM, AutoTokenizer

gguf_dir = "Qwen/Qwen2.5-0.5B-Instruct-GGUF"
gguf_file = "qwen2.5-0.5b-instruct-q4_0.gguf"
model = AutoModelForCausalLM.from_pretrained(gguf_dir, gguf_file=gguf_file, device_map="auto")
```
error log:
```bash
qwen2.5-0.5b-instruct-q4_0.gguf: 100%|████████████████████████████████████████████████████████| 429M/429M [00:04<00:00, 87.1MB/s]
Converting and de-quantizing GGUF tensors...: 100%|███████████████████████████████████████████| 291/291 [00:02<00:00, 104.11it/s]
[W125 22:27:15.868069607 OperatorEntry.cpp:218] Warning: Warning only once for all operators,  other operators may also be overridden.
  Overriding a previously registered kernel for the same operator and the same dispatch key
  operator: aten::_addmm_activation(Tensor self, Tensor mat1, Tensor mat2, *, Scalar beta=1, Scalar alpha=1, bool use_gelu=False) -> Tensor
    registered at /pytorch/build/aten/src/ATen/RegisterSchema.cpp:6
  dispatch key: AutocastCPU
  previous kernel: registered at /pytorch/aten/src/ATen/autocast_mode.cpp:327
       new kernel: registered at /opt/workspace/ipex-cpu-dev/csrc/cpu/autocast/autocast_mode.cpp:112 (function operator())
[2026-01-25 22:27:15,514] [INFO] [real_accelerator.py:219:get_accelerator] Setting ds_accelerator to cpu (auto detect)
Loading weights: 100%|████████████████████████████████| 291/291 [00:00<00:00, 9150.59it/s, Materializing param=model.norm.weight]
Traceback (most recent call last):
  File "/home/sdp/xinhe/transformers/src/transformers/generation/utils.py", line 402, in adjust_generation_fn
    self.generation_config = GenerationConfig.from_pretrained(
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/generation/configuration_utils.py", line 930, in from_pretrained
    resolved_config_file = cached_file(
                           ^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/utils/hub.py", line 276, in cached_file
    file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/utils/hub.py", line 523, in cached_files
    raise OSError(
OSError: Qwen/Qwen2.5-0.5B-Instruct-GGUF does not appear to have a file named generation_config.json. Checkout 'https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/tree/main' for available files.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sdp/kaihui/auto-round/test/test_gguf_loading.py", line 7, in <module>
    model = AutoModelForCausalLM.from_pretrained(gguf_dir, gguf_file=gguf_file, device_map="auto")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/models/auto/auto_factory.py", line 372, in from_pretrained
    return model_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/modeling_utils.py", line 4077, in from_pretrained
    model.adjust_generation_fn(
  File "/home/sdp/xinhe/transformers/src/transformers/generation/utils.py", line 415, in adjust_generation_fn
    self.generation_config = GenerationConfig.from_pretrained(
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/generation/configuration_utils.py", line 959, in from_pretrained
    config_dict = cls._dict_from_json_file(resolved_config_file)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sdp/xinhe/transformers/src/transformers/generation/configuration_utils.py", line 982, in _dict_from_json_file
    with open(json_file, "r", encoding="utf-8") as reader:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

### Expected behavior

The gguf file should be able to load directly.

Comments:
This was fixed on main with #43465