# Issue while loading file-tuned gemma2

**URL:** <https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613>\
**Category:** Models\
**Created:** [November 13, 2024, 1:16pm UTC](https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613 "2024-11-13T13:16:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amanpreetsingh459](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/amanpreetsingh459/32/34583_2.png) [@amanpreetsingh459](https://discuss.huggingface.co/u/amanpreetsingh459)\
**Post date:** [November 13, 2024, 1:16pm UTC](https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613/1 "2024-11-13T13:16:54Z")

</div>

Getting this warning while loading fine-tuned Gemma2-2b model. And getting weird outputs too when go with this  
Some weights of the model checkpoint at \<model\_dir\> were not used when initializing Gemma2ForCausalLM

---

<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:** [November 13, 2024, 1:23pm UTC](https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613/2 "2024-11-13T13:23:34Z")

</div>

In the HF library, this is a message that often appears in both image generation AI and LLM, but the fact that it is only a warning means that the warning itself probably does not interfere with operation.  
I think the cause of the strange output is something else.

> [@Unable to load checkpoint after finetuning](https://discuss.huggingface.co/t/unable-to-load-checkpoint-after-finetuning/50693):
>
> Hi, So I’m running into trouble when trying to load the model weights after finetuning a pretrained base model, steps I’m taking: model= BertForSequenceClassification.from\_pretrained("model/repo") model.classifier = torch.nn.Sequential( torch.nn.Dropout(0.4), torch.nn.Linear(model.config.hidden\_size, 256), torch.nn.ReLU(), torch.nn.Dropout(0.4), torch.nn.Linear(256, 2), ) getting a warning here which I guess is fine for the moment: Some weights of the model checkpoint at…

---

<div class="post-metadata">

**Author:** ![Sidakdeep22](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Sidakdeep22](https://discuss.huggingface.co/u/Sidakdeep22)\
**Post date:** [December 24, 2024, 4:01am UTC](https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613/3 "2024-12-24T04:01:27Z")

</div>

@amanpreetsingh459 I’m facing the same issue. How did you resolve it?

---

<div class="post-metadata">

**Author:** ![amanpreetsingh459](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/amanpreetsingh459/32/34583_2.png) [@amanpreetsingh459](https://discuss.huggingface.co/u/amanpreetsingh459)\
**Post date:** [December 29, 2024, 5:39am UTC](https://discuss.huggingface.co/t/issue-while-loading-file-tuned-gemma2/118613/4 "2024-12-29T05:39:59Z")

</div>

I resolved it by following below steps:-

1. push adapter weights(from trainer)  
trainer.push\_to\_hub(“your\_huggingface\_dir”)

2. push the base model as well  
base\_model.push\_to\_hub(“your\_huggingface\_dir”)

3. then loading the model with:  
model\_finetuned = AutoModelForCausalLM.from\_pretrained(  
finetuned\_model\_name,  
device\_map=“auto”,  
torch\_dtype=torch.bfloat16  
)
