getting error while fine tuning gemma 3 #2376
Unanswered
peteparker123
asked this question in
Q&A
Replies: 3 comments 1 reply
-
hi, can you show your code here ? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @uscneps , I am getting the same error with gemma3 12b it and gemma3 4b it model model, tokenizer = FastModel.from_pretrained(
model_name = "unsloth/gemma-3-12b-it",
max_seq_length = 2048, # Choose any for long context!
load_in_4bit = True, # 4 bit quantization to reduce memory
load_in_8bit = False,
full_finetuning = False, # [NEW!] We have full finetuning now!
)
model = FastModel.get_peft_model(
model,
finetune_vision_layers = False, # Turn off for just text!
finetune_language_layers = True, # Should leave on!
finetune_attention_modules = True, # Attention good for GRPO
finetune_mlp_modules = True, # SHould leave on always!
r = 8, # Larger = higher accuracy, but might overfit
lora_alpha = 8, # Recommended alpha == r at least
lora_dropout = 0,
bias = "none",
random_state = 3407,
)
# <data preparation and stuff copied from official unsloth gemma3 collab notebook>
from trl import SFTTrainer, SFTConfig
from transformers import TrainingArguments, DataCollatorForSeq2Seq, EarlyStoppingCallback
from unsloth import is_bfloat16_supported
trainer = SFTTrainer(
model = model,
data_collator=DataCollatorForSeq2Seq(tokenizer=tokenizer),
# tokenizer = tokenizer,
train_dataset = train_dataset,
eval_dataset = val_dataset,
callbacks=[EarlyStoppingCallback(early_stopping_patience=3)],
args=SFTConfig(
dataset_text_field = "text",
dataset_num_proc = 2,
max_seq_length = 2048,
packing = False,
learning_rate = 2e-4,
output_dir = "gemma-4b-it-checkpoints",
eval_strategy="epoch",
per_device_train_batch_size = 8,
per_device_eval_batch_size = 8,
gradient_accumulation_steps=4,
torch_empty_cache_steps = 16,
weight_decay = 0.01,
num_train_epochs=6,
lr_scheduler_type = "cosine",
warmup_steps = 50,
logging_steps = 1,
logging_nan_inf_filter = False,
save_strategy="epoch",
save_total_limit=3,
seed = 42,
bf16 = False,
fp16= False,
run_name="gemma3-4b-it-trial-01",
load_best_model_at_end=True,
metric_for_best_model="loss",
optim = "adamw_8bit",
report_to = "wandb",
),
)
trainer_stats = unsloth_train(trainer) Error:
Detailed Error Stack
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I got the same error when I tried to fine-tune "sarvamai/sarvam-translate", which is a gemma-3-based model
error
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i tried to fine tune gemma 3 model using unsloth but i am getting the below error.
RuntimeError: expected mat1 and mat2 to have the same dtype, but got: float != c10::Half
i have already fine tuned deepseek,qwen,llama but i didn't get this error but i am getting this error for only this. i tried to resolve it but it didn't work out.
Beta Was this translation helpful? Give feedback.
All reactions