# AttributeError: 'CustomQwen3Model' object has no attribute 'config'

**URL:** <https://discuss.huggingface.co/t/attributeerror-customqwen3model-object-has-no-attribute-config/155479>\
**Category:** 🤗Transformers\
**Created:** [May 16, 2025, 6:41am UTC](https://discuss.huggingface.co/t/attributeerror-customqwen3model-object-has-no-attribute-config/155479 "2025-05-16T06:41:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luohuashijieyoufengj](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@luohuashijieyoufengj](https://discuss.huggingface.co/u/luohuashijieyoufengj)\
**Post date:** [May 16, 2025, 6:41am UTC](https://discuss.huggingface.co/t/attributeerror-customqwen3model-object-has-no-attribute-config/155479/1 "2025-05-16T06:41:33Z")

</div>

I added some layers to pretrained model and trained it. But when I wanted to push it to huggingface by calling push\_to\_hub(), it gave the error as shown in title. How to fix it?

```auto
import torch.nn as nn

class CustomQwen3Model(nn.Module):
    def __init__ (self, pretrained_model):
        super(CustomQwen3Model, self). __init__ ()
        self.base_model = pretrained_model
        self.act_fn = nn.SiLU()
        self.additional_layer = nn.Linear(151936, 22)

    def forward(self, input_ids, attention_mask=None):
        outputs = self.base_model(input_ids=input_ids, attention_mask=attention_mask)
        base_model_output = outputs.logits
        output = self.act_fn(base_model_output)
        output = self.additional_layer(output)
        return output
    
my_model = CustomQwen3Model(qwen_model)

```

Below is my training args:

```auto
training_args = TrainingArguments(
    output_dir=output_dir,
    learning_rate=2e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    num_train_epochs=20,
    weight_decay=0.01,
    eval_strategy="epoch",
    save_strategy="epoch",
# load_best_model_at_end=True,
    push_to_hub=False,
    save_total_limit=1,
    fp16=True,
    label_names=["label"],
    save_safetensors=False,
)

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 16, 2025, 9:51am UTC](https://discuss.huggingface.co/t/attributeerror-customqwen3model-object-has-no-attribute-config/155479/2 "2025-05-16T09:51:28Z")

</div>

Hmm… Maybe it’s because it doesn’t inherit `PreTrainedModel`…

> [@Problem with push\_to\_hub](https://discuss.huggingface.co/t/problem-with-push-to-hub/8273):
>
> Hello everyone. I’m trying to upload my fine-tuned GPT-2 Model to Model Hub. When I try to use the uploading function push\_to\_hub I get the following error: AttributeError: 'GPT2Model' object has no attribute 'push\_to\_hub' In the documentation it says that I can push the model with this function. Can anybody help please?

> [@'GPT2LMHeadModel' object has no attribute 'push\_to\_hub'](https://discuss.huggingface.co/t/gpt2lmheadmodel-object-has-no-attribute-push-to-hub/11566):
>
> Hello everybody, I recently fine-tuned a GPT model (GPT2LMHeadModel) and tried to push it to hub. I followed the tutorial but got this strange error: ‘GPT2LMHeadModel’ object has no attribute ‘push\_to\_hub’ I’ve updated the transformers library to the latest version, as shown in the screenshot. Can anybody help me with that? I’ve been working on this problem for 3 hours but still in vain… (By the way I was coding on Kaggle) Any help is appreciated!

> **[Create a custom architecture](https://huggingface.co/docs/transformers/main/en/create_a_model)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.
