# After llama fine tuning, model merging fails

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fafter-llama-fine-tuning-model-merging-fails%2F155944%3E%5C
**Category:** Beginners\
**Created:** [May 19, 2025, 7:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fafter-llama-fine-tuning-model-merging-fails%2F155944 "2025-05-19T19:05:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbuwel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kbuwel/32/46076_2.png) [@kbuwel](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkbuwel)%5C
**Post date:** [May 19, 2025, 7:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fafter-llama-fine-tuning-model-merging-fails%2F155944%2F1 "2025-05-19T19:05:14Z")

</div>

The error message is as follows:  
raise RuntimeError(  
RuntimeError: Error(s) in loading state\_dict for PeftModelForCausalLM:  
size mismatch for base\_model.model.model.embed\_tokens.base\_layer.weight: copying a param with shape torch.Size([  
128257, 3072]) from checkpoint, the shape in current model is torch.Size([128256, 3072]).  
size mismatch for base\_model.model.model.embed\_tokens.lora\_embedding\_A.default: copying a param with shape torch  
.Size([64, 128257]) from checkpoint, the shape in current model is torch.Size([64, 128256]).  
size mismatch for base\_model.model.lm\_head.base\_layer.weight: copying a param with shape torch.Size([128257, 307  
2]) from checkpoint, the shape in current model is torch.Size([128256, 3072]).  
size mismatch for base\_model.model.lm\_head.lora\_B.default.weight: copying a param with shape torch.Size([128257,  
64]) from checkpoint, the shape in current model is torch.Size([128256, 64]).  
Here is the code I learned:  
import os  
import json  
import random  
import torch  
import argparse  
from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments  
from datasets import Dataset  
from peft import get\_peft\_model, LoraConfig  
from torch.optim import AdamW  
from accelerate import Accelerator

# 명령줄 인자 설정

parser = argparse.ArgumentParser()  
parser.add\_argument(“–batch\_size”, type=int, default=2)  
parser.add\_argument(“–micro\_batch\_size”, type=int, default=5) # 마이크로 배치 사이즈 추가  
parser.add\_argument(“–lr”, type=float, default=5e-5)  
args = parser.parse\_args()

# 모델 ID 설정

model\_id = ‘llama-3.2-Korean-Bllossom-3B’

# config.json 파일 로드

config\_file = f"{model\_id}/config.json"  
if not os.path.exists(config\_file):  
raise FileNotFoundError(f"Config file not found: {config\_file}")  
with open(config\_file, ‘r’) as f:  
config = json.load(f)

# max\_position\_embeddings 값을 가져옴, 기본값은 512로 설정

max\_position\_embeddings = config.get(‘max\_position\_embeddings’, 512)

# 토크나이저 로드

tokenizer = AutoTokenizer.from\_pretrained(model\_id)

# 패딩 토큰 추가

tokenizer.add\_special\_tokens({‘pad\_token’: ‘[PAD]’})  
pad\_token\_id = tokenizer.pad\_token\_id

# LoRA 설정

lora\_config = LoraConfig(  
r=64,  
lora\_alpha=16,  
lora\_dropout=0.1,  
task\_type=“CAUSAL\_LM”,  
target\_modules=[“q\_proj”, “v\_proj”, “embed\_tokens”, “lm\_head”]  
)

# 모델을 CPU로 로드

model = AutoModelForCausalLM.from\_pretrained(model\_id)  
model.resize\_token\_embeddings(len(tokenizer))  
model = get\_peft\_model(model, lora\_config)

# pad\_token\_id 명시적으로 설정

model.generation\_config.pad\_token\_id = pad\_token\_id

# Accelerator 초기화

accelerator = Accelerator()

# 모델을 Accelerator로 준비

model, tokenizer = accelerator.prepare(model, tokenizer)

# processed\_dataset.json 파일 로드

dataset\_file = ‘processed\_dataset.json’  
if not os.path.exists(dataset\_file):  
raise FileNotFoundError(f"Dataset file not found: {dataset\_file}")  
with open(dataset\_file, ‘r’, encoding=‘utf-8’) as f:  
full\_dataset = json.load(f)

# 데이터가 리스트 형태일 경우

texts = [item[‘text’] for item in full\_dataset]  
random.shuffle(texts)

# 데이터 나누기

split\_index = int(len(texts) \* 0.8)  
train\_texts = texts[:split\_index]  
val\_texts = texts[split\_index:]

# 데이터셋 생성

train\_dataset = Dataset.from\_dict({“text”: train\_texts})  
val\_dataset = Dataset.from\_dict({“text”: val\_texts})

# 필요 없는 문자열 제거 함수

def remove\_unwanted\_strings(examples):  
examples[‘text’] = [text.replace(‘\<\>’, ‘’).replace(‘\<\>’, ‘’).strip() for text in examples[‘text’]]  
return examples

# 문자열 제거 적용

train\_dataset = train\_dataset.map(remove\_unwanted\_strings, batched=True)  
val\_dataset = val\_dataset.map(remove\_unwanted\_strings, batched=True)

# 데이터 전처리 함수

def preprocess\_function(examples):  
tokenized = tokenizer(  
examples[“text”],  
max\_length=512,  
truncation=True,  
padding=“max\_length”, # max\_length로 패딩  
return\_tensors=‘pt’  
)

```
labels = tokenized["input_ids"].clone()
labels[labels == pad_token_id] = -100 # 패딩 토큰을 -100으로 설정하여 손실에서 제외
tokenized["labels"] = labels

return tokenized

```

# 데이터셋 전처리

tokenized\_train\_dataset = train\_dataset.map(preprocess\_function, batched=True)  
tokenized\_val\_dataset = val\_dataset.map(preprocess\_function, batched=True)

# TrainingArguments 설정

training\_args = TrainingArguments(  
output\_dir=‘./results’,  
per\_device\_train\_batch\_size=args.batch\_size,  
num\_train\_epochs=5,  
learning\_rate=args.lr,  
logging\_dir=‘./logs’,  
logging\_steps=10,  
eval\_strategy=“epoch”, # 평가 전략을 'epoch’으로 설정  
save\_strategy=“epoch”, # 저장 전략도 'epoch’으로 설정  
report\_to=“wandb”,  
logging\_first\_step=True,  
bf16=True, # FP16 활성화  
gradient\_accumulation\_steps=3,  
save\_total\_limit=3,  
load\_best\_model\_at\_end=True,  
metric\_for\_best\_model=“eval\_loss”,  
)

# Optimizer 설정

optimizer = AdamW(model.parameters(), lr=training\_args.learning\_rate)

# Trainer 설정

trainer = Trainer(  
model=model,  
args=training\_args,  
train\_dataset=tokenized\_train\_dataset,  
eval\_dataset=tokenized\_val\_dataset,  
optimizers=(optimizer, None), # Custom optimizer 추가  
)

# Gradient Clipping 설정

trainer.args.max\_grad\_norm = 1.0 # Gradient Clipping 추가

# 학습 시작

trainer.train()

# 학습 후 모델과 토크나이저 저장

model.save\_pretrained(‘./results’)  
tokenizer.save\_pretrained(‘./results’)

# 추론 함수 정의

def infer(text):  
with torch.no\_grad():  
inputs = tokenizer(text, return\_tensors=‘pt’, max\_length=128, truncation=True)  
inputs = {k: v.to(accelerator.device) for k, v in inputs.items()}  
outputs = model.generate(\*\*inputs)  
return tokenizer.decode(outputs[0], skip\_special\_tokens=True)

# 학습 중간에 메모리 정리

torch.cuda.empty\_cache()  
The above code has undergone many modifications. It was written with gpt3, ms copilot, and advice from many people.  
Fine tuning was successful. The merge code used merge\_peft\_adapters.py from github.  
The command I entered was:  
python merge\_peft\_adapters.py --base\_model\_name\_or\_path llama-3.2-Korean-Bllossom-3B --peft\_model\_path results/checkpoint-65 --device cpu  
I used cpu because it was a small model, but the merge failed.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [May 20, 2025, 6:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fafter-llama-fine-tuning-model-merging-fails%2F155944%2F2 "2025-05-20T06:22:21Z")

</div>

It seems like this error can probably be resolved, but it appears that you may need to change the Embedding of the token in some cases…

That being said, the specifications for merge-related functions sometimes change, so existing scripts may not work properly.  
If you’re only using it for yourself, it might be quicker to rewrite it, as you only need to load and save it.

> <https://github.com/huggingface/peft/issues/1700>
>
> Trained model using this lora config:
> \`\`\`
> model.resize\_token\_embeddings(len(to…kenizer))
> Embedding(33004, 4096)
> 
> lora\_alpha = 2048
> lora\_dropout = 0.3
> lora\_r = 1024
> target\_modules=\[
> # "up\_proj",
> "o\_proj",
> "v\_proj",
> "gate\_proj",
> "q\_proj",
> # "down\_proj",
> "k\_proj"
> \]
> modules\_to\_save = \["lm\_head", "embed\_tokens"\]
> peft\_config = LoraConfig(
> lora\_alpha=lora\_alpha,
> lora\_dropout=lora\_dropout,
> r=lora\_r,
> target\_modules = target\_modules,
> bias="none",
> modules\_to\_save = modules\_to\_save,
> task\_type="CAUSAL\_LM")
> 
> model = prepare\_model\_for\_kbit\_training(model)
> model = get\_peft\_model(model, peft\_config)
> model.print\_trainable\_parameters()
> 
> trainable params: 1,839,038,464 || all params: 8,585,678,848 || trainable%: 21.419837575550556
> 
> trainer = Trainer(
> model=model, 
> tokenizer=tokenizer, 
> args=training\_args, 
> train\_dataset=sample\_train, 
> eval\_dataset=sample\_val, 
> )
> trainer.train()
> \`\`\`
> Where i wnated to keep my word embedding layer trainable..
> 
> Training went smooothly no problem, but while loading the checkpoints using AutoModelForCausalLM and PeftModel gettitng the same error:
> 
> \`\`\`
> from peft import LoraConfig
> from transformers import AutoModelForCausalLM
> from peft import PeftModel
> import torch
> 
> repo\_name = '/media/iiit/Karvalo/zuhair/Proj-multimodal/libri100-english-transcribe-1024,2048,0.2,kqvog-hubert\_proj\_grouped-wte/checkpoint-1'
> 
> config = LoraConfig.from\_pretrained(repo\_name)
> 
> 
> model = AutoModelForCausalLM.from\_pretrained(
> config.base\_model\_name\_or\_path,
> device\_map="auto",
> torch\_dtype=torch.bfloat16,
> trust\_remote\_code=True,
> )
> \# Load the LoRA model
> inference\_model = PeftModel.from\_pretrained(model, repo\_name)
> \`\`\`
> \`\`\`
> Loading checkpoint shards: 100%
>  2/2 \[00:08\<00:00,  3.89s/it\]
> \---------------------------------------------------------------------------
> RuntimeError Traceback (most recent call last)
> Cell In\[3\], line 18
> 11 model = AutoModelForCausalLM.from\_pretrained(
> 12 config.base\_model\_name\_or\_path,
> 13 device\_map="auto",
> 14 torch\_dtype=torch.bfloat16,
> 15 trust\_remote\_code=True,
> 16 )
> 17 # Load the LoRA model
> \---\> 18 inference\_model = PeftModel.from\_pretrained(model, repo\_name)
> 
> File ~/anaconda3/lib/python3.9/site-packages/peft/peft\_model.py:356, in PeftModel.from\_pretrained(cls, model, model\_id, adapter\_name, is\_trainable, config, \*\*kwargs)
> 354 else:
> 355 model = MODEL\_TYPE\_TO\_PEFT\_MODEL\_MAPPING\[config.task\_type\](model, config, adapter\_name)
> \--\> 356 model.load\_adapter(model\_id, adapter\_name, is\_trainable=is\_trainable, \*\*kwargs)
> 357 return model
> 
> File ~/anaconda3/lib/python3.9/site-packages/peft/peft\_model.py:730, in PeftModel.load\_adapter(self, model\_id, adapter\_name, is\_trainable, \*\*kwargs)
> 727 adapters\_weights = load\_peft\_weights(model\_id, device=torch\_device, \*\*hf\_hub\_download\_kwargs)
> 729 # load the weights into the model
> \--\> 730 load\_result = set\_peft\_model\_state\_dict(self, adapters\_weights, adapter\_name=adapter\_name)
> 731 if (
> 732 (getattr(self, "hf\_device\_map", None) is not None)
> 733 and (len(set(self.hf\_device\_map.values()).intersection({"cpu", "disk"})) \> 0)
> 734 and len(self.peft\_config) == 1
> 735 ):
> 736 device\_map = kwargs.get("device\_map", "auto")
> 
> File ~/anaconda3/lib/python3.9/site-packages/peft/utils/save\_and\_load.py:249, in set\_peft\_model\_state\_dict(model, peft\_model\_state\_dict, adapter\_name)
> 246 else:
> 247 raise NotImplementedError
> \--\> 249 load\_result = model.load\_state\_dict(peft\_model\_state\_dict, strict=False)
> 250 if config.is\_prompt\_learning:
> 251 model.prompt\_encoder\[adapter\_name\].embedding.load\_state\_dict(
> 252 {"weight": peft\_model\_state\_dict\["prompt\_embeddings"\]}, strict=True
> 253 )
> 
> File ~/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py:2189, in Module.load\_state\_dict(self, state\_dict, strict, assign)
> 2184 error\_msgs.insert(
> 2185 0, 'Missing key(s) in state\_dict: {}. '.format(
> 2186 ', '.join(f'"{k}"' for k in missing\_keys)))
> 2188 if len(error\_msgs) \> 0:
> \-\> 2189 raise RuntimeError('Error(s) in loading state\_dict for {}:\\n\\t{}'.format(
> 2190 self.\_\_class\_\_.\_\_name\_\_, "\\n\\t".join(error\_msgs)))
> 2191 return \_IncompatibleKeys(missing\_keys, unexpected\_keys)
> 
> RuntimeError: Error(s) in loading state\_dict for PeftModelForCausalLM:
> size mismatch for base\_model.model.model.embed\_tokens.modules\_to\_save.default.weight: copying a param with shape torch.Size(\[33004, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> size mismatch for base\_model.model.lm\_head.modules\_to\_save.default.weight: copying a param with shape torch.Size(\[33004, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> 
> \`\`\`
> And also my checkpoints are very huge in size there is a problem please help me to clear out
> \*\*check the image of my checkpoint :\*\* 
> !\[Screenshot from 2024-05-01 02-04-02\](https://github.com/huggingface/peft/assets/104340147/0f8d2c0b-ffd6-4566-b530-a7167a4ea56c)

> <https://github.com/huggingface/peft/issues/762>
>
> \### System Info
> 
> peft, transformers
> 
> \### Who can help?
> 
> \_No response\_
> 
> \### Infor…mation
> 
> \- \[X\] The official example scripts
> \- \[\] My own modified scripts
> 
> \### Tasks
> 
> \- \[x\] An officially supported task in the \`examples\` folder
> \- \[\] My own task or dataset (give details below)
> 
> \### Reproduction
> 
> I am currently facing an issue when trying to load a pretrained model with an expanded embedding layer. I first expanded the embedding layer, wrapped the model using LoRA, and pass \`modules\_to\_save=\["embed\_tokens", "lm\_head"\]\` to make the embedding layer trainable. After training, I saved the model using \`save\_pretrained(path1)\`. However, when I try to load the model using AutoModelForCausalLM.from\_pretrained(path1), I encounter the following error:
> \`\`\`python
> Error(s) in loading state\_dict for ModelForCausalLM:  
> size mismatch for base\_model.model.model.embed\_tokens.modules\_to\_save.default.weight: copying a param with shape torch.Size(\[33049, 16\]) from checkpoint, the shape in current model is torch.Size(\[32000, 16\])  
> \`\`\`
> 
> 
> \### Expected behavior
> 
> I have a rough idea of where the problem lies, but I'm wondering if it would be better to not perform size match checking when loading pretrained models. This could potentially avoid many unnecessary issues.

> [@Loading Peft model from checkpoint leading into size missmatch](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Floading-peft-model-from-checkpoint-leading-into-size-missmatch%2F71944)%3A
>
> I am finetuning a model using peft adapters and want to check if a checkpoint that I have saved is good enough. However, I have added an extra token to the vocabulary before fine-tuning, which results in different embedding size. I try to load the model like this: Load base model model = AutoModelForCausalLM.from\_pretrained( checkpoint\_dir, quantization\_config=bnb\_config, device\_map=device\_map, ) And I run into the following error: Loading checkpoint shards: 100% 3/3 [01:10\<00:00, 23.2…

> <https://github.com/huggingface/autotrain-advanced/issues/487>
>
> \### Prerequisites
> 
> \- \[X\] I have read the \[documentation\](https://hf.co/docs/auto…train).
> \- \[X\] I have checked other issues for similar problems.
> 
> \### Backend
> 
> Colab
> 
> \### Interface Used
> 
> CLI
> 
> \### CLI Command
> 
> 
> 
> !autotrain llm \\
> \--train \\
> \--model ${MODEL\_NAME} \\
> \--project-name ${PROJECT\_NAME} \\
> \--data-path data/ \\
> \--text-column text \\
> \--lr ${LEARNING\_RATE} \\
> \--batch-size ${BATCH\_SIZE} \\
> \--epochs ${NUM\_EPOCHS} \\
> \--block-size ${BLOCK\_SIZE} \\
> \--warmup-ratio ${WARMUP\_RATIO} \\
> \--lora-r ${LORA\_R} \\
> \--lora-alpha ${LORA\_ALPHA} \\
> \--lora-dropout ${LORA\_DROPOUT} \\
> \--weight-decay ${WEIGHT\_DECAY} \\
> \--gradient-accumulation ${GRADIENT\_ACCUMULATION} \\
> \--quantization ${QUANTIZATION} \\
> \--mixed-precision ${MIXED\_PRECISION} \\
> $( \[\["$MERGE\_ADAPTER" == "True" \]\] && echo "--merge\_adapter" ) \\
> $( \[\["$PEFT" == "True" \]\] && echo "--peft" ) \\
> $( \[\["$PUSH\_TO\_HUB" == "True" \]\] && echo "--push-to-hub --token ${HF\_TOKEN} --repo-id ${REPO\_ID}" )
> 
> \### UI Screenshots & Parameters
> 
> !\[image\](https://github.com/huggingface/autotrain-advanced/assets/4874/81e42bb4-e0e1-4488-8e30-ba1d23f45924)
> !\[image\](https://github.com/huggingface/autotrain-advanced/assets/4874/de6c6564-ae3b-46eb-ae86-adb873437eca)
> 
> 
> \### Error Logs
> 
> {'train\_runtime': 138.1913, 'train\_samples\_per\_second': 1.65, 'train\_steps\_per\_second': 0.203, 'train\_loss': 1.3923424993242537, 'epoch': 0.98}
> 100% 28/28 \[02:18\<00:00, 4.94s/it\]
> 🚀 INFO | 2024-02-03 05:42:13 | \_\_main\_\_:train:477 - Finished training, saving model...
> 🚀 INFO | 2024-02-03 05:42:16 | \_\_main\_\_:train:488 - Merging adapter weights...
> 🚀 INFO | 2024-02-03 05:42:16 | autotrain.trainers.clm.utils:merge\_adapter:192 - Loading adapter...
> Loading checkpoint shards: 100% 10/10 \[00:30\<00:00, 3.10s/it\]
> /usr/local/lib/python3.10/dist-packages/transformers/generation/configuration\_utils.py:392: UserWarning: \`do\_sample\` is set to \`False\`. However, \`temperature\` is set to \`0.9\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`temperature\`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.
> warnings.warn(
> /usr/local/lib/python3.10/dist-packages/transformers/generation/configuration\_utils.py:397: UserWarning: \`do\_sample\` is set to \`False\`. However, \`top\_p\` is set to \`0.6\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`top\_p\`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.
> warnings.warn(
> ⚠️ WARNING | 2024-02-03 05:42:48 | \_\_main\_\_:train:500 - Failed to merge adapter weights: Error(s) in loading state\_dict for PeftModelForCausalLM:
> size mismatch for base\_model.model.model.embed\_tokens.weight: copying a param with shape torch.Size(\[32001, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> size mismatch for base\_model.model.lm\_head.weight: copying a param with shape torch.Size(\[32001, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> ⚠️ WARNING | 2024-02-03 05:42:48 | \_\_main\_\_:train:501 - Skipping adapter merge. Only adapter weights will be saved.
> 🚀 INFO | 2024-02-03 05:42:49 | \_\_main\_\_:train:510 - Pushing model to hub...
> adapter\_model.safetensors: 0% 0.00/1.08G \[00:00\<?, ?B/s\]
> adapter\_model.safetensors: 0% 0.00/1.08G \[00:00\<?, ?B/s\]
> 
> \### Additional Information
> 
> When running the example colab notebook for autotrain LLM with --merge\_adapter, it failed because size mismatch.
> 
> 
> 🚀 INFO | 2024-02-03 05:42:16 | \_\_main\_\_:train:488 - Merging adapter weights...
> 🚀 INFO | 2024-02-03 05:42:16 | autotrain.trainers.clm.utils:merge\_adapter:192 - Loading adapter...
> Loading checkpoint shards: 100% 10/10 \[00:30\<00:00, 3.10s/it\]
> /usr/local/lib/python3.10/dist-packages/transformers/generation/configuration\_utils.py:392: UserWarning: \`do\_sample\` is set to \`False\`. However, \`temperature\` is set to \`0.9\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`temperature\`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.
> warnings.warn(
> /usr/local/lib/python3.10/dist-packages/transformers/generation/configuration\_utils.py:397: UserWarning: \`do\_sample\` is set to \`False\`. However, \`top\_p\` is set to \`0.6\` -- this flag is only used in sample-based generation modes. You should set \`do\_sample=True\` or unset \`top\_p\`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.
> warnings.warn(
> ⚠️ WARNING | 2024-02-03 05:42:48 | \_\_main\_\_:train:500 - Failed to merge adapter weights: Error(s) in loading state\_dict for PeftModelForCausalLM:
> size mismatch for base\_model.model.model.embed\_tokens.weight: copying a param with shape torch.Size(\[32001, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> size mismatch for base\_model.model.lm\_head.weight: copying a param with shape torch.Size(\[32001, 4096\]) from checkpoint, the shape in current model is torch.Size(\[32000, 4096\]).
> ⚠️ WARNING | 2024-02-03 05:42:48 | \_\_main\_\_:train:501 - Skipping adapter merge. Only adapter weights will be saved.

> [@Size mismatch error in PEFT fine tuned model](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsize-mismatch-error-in-peft-fine-tuned-model%2F95040)%3A
>
> RuntimeError: Error(s) in loading state\_dict for MistralForCausalLM: size mismatch for lm\_head.base\_layer.weight: copying a param with shape torch.Size([32002, 4096]) from checkpoint, the shape in current model is torch.Size([32000, 4096]). size mismatch for lm\_head.lora\_B.default.weight: copying a param with shape torch.Size([32002, 16]) from checkpoint, the shape in current model is torch.Size([32000, 16]). Iam gettting size mismatch error while i try to load my PEFT fine tuned model which …
