`trust_remote_code=True` in `AutoConfig.from_pretrained` results in missing fields in returned object
Author: Lander-Hatsune
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 5.0.0
- Platform: Linux-6.8.0-85-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 1.3.5
- Safetensors version: 0.7.0
- Accelerate version: not installed
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.7.0+cu128 (CUDA)
- Using distributed or parallel set-up in script?: No
- Using GPU in script?: No
- GPU type: NVIDIA GeForce RTX 5090

### Who can help?

@Cyrilvallez @ArthurZucker 

### Information

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

```py
In [1]: from transformers import AutoConfig

In [2]: config = AutoConfig.from_pretrained("deepseek-ai/DeepSeek-V3.1", trust_remote_code=False)
config.json: 1.69kB [00:00, 6.46MB/s]
`rope_parameters`'s factor field must be a float >= 1, got 40
`rope_parameters`'s beta_fast field must be a float, got 32
`rope_parameters`'s beta_slow field must be a float, got 1

In [3]: config.qk_head_dim
Out[3]: 192

In [4]: config = AutoConfig.from_pretrained("deepseek-ai/DeepSeek-V3.1", trust_remote_code=True)
configuration_deepseek.py: 9.90kB [00:00, 23.9MB/s]
A new version of the following files was downloaded from https://huggingface.co/deepseek-ai/DeepSeek-V3.1:
- configuration_deepseek.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
`rope_parameters`'s factor field must be a float >= 1, got 40
`rope_parameters`'s beta_fast field must be a float, got 32
`rope_parameters`'s beta_slow field must be a float, got 1

In [5]: config.qk_head_dim
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 1
----> 1 config.qk_head_dim

File ~/heyi-engine.operators/.venv/lib/python3.10/site-packages/transformers/configuration_utils.py:164, in PreTrainedConfig.__getattribute__(self, key)
    162 if key != "attribute_map" and key in super().__getattribute__("attribute_map"):
    163     key = super().__getattribute__("attribute_map")[key]
--> 164 return super().__getattribute__(key)

AttributeError: 'DeepseekV3Config' object has no attribute 'qk_head_dim'
```

### Expected behavior

Currently `trust_remote_code=True` in `AutoConfig.from_pretrained` results in missing fields (in this case `qk_head_dim`) in returned `config` object, for `deepseek-ai/DeepSeek-V3.1` model.

Expected to have no missing fields in returned config object, with `trust_remote_code=True`.

Comments:
Hii, I looked into it
When you use trust_remote_code=False, transformers uses its own built in DeepseekV3Config class. This class calculates qk_head_dim by adding qk_nope_head_dim (128) and qk_rope_head_dim (64) together, giving you 192.                                                                               
                                                                                                                                                               
When you use trust_remote_code=True, transformers downloads and uses DeepSeek's own configuration file from their repository instead. The problem is that DeepSeek's config file sets qk_nope_head_dim and qk_rope_head_dim separately, but never combines them into qk_head_dim. That attribute simply doesn't exist in their version.                                                                                                                                      
                                                                                                                                                               
So the fix needs to happen on DeepSeek's side. They need to update their configuration_deepseek file to include the qk_head_dim attribute.

Yep, nothing we can do on our side 😉