Skip to content

Commit 180ffd3

Browse files
committed
Merge main, resolve E4B-Audio header conflict (keep L4 Colab Pro wording)
2 parents 83cb0fb + 4698457 commit 180ffd3

14 files changed

+96
-1764
lines changed

nb/Gemma4_(26B-A4B)-Inference.ipynb

Lines changed: 0 additions & 405 deletions
This file was deleted.

nb/Gemma4_(26B_A4B)-Text.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "64duhI2Gsavq"
77
},
88
"source": [
9-
"To run this, press \"*Runtime*\" and press \"*Run all*\" on a **free** Tesla T4 Google Colab instance!\n",
9+
"To run this, press \"*Runtime*\" and press \"*Run all*\" on a Google Colab A100 instance!\n",
1010
"<div class=\"align-center\">\n",
1111
"<a href=\"https://unsloth.ai/\"><img src=\"https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png\" width=\"115\"></a>\n",
1212
"<a href=\"https://discord.gg/unsloth\"><img src=\"https://github.com/unslothai/unsloth/raw/main/images/Discord button.png\" width=\"145\"></a>\n",
@@ -75,7 +75,7 @@
7575
" xformers = 'xformers==' + {'2.10':'0.0.34','2.9':'0.0.33.post1','2.8':'0.0.32.post2'}.get(v, \"0.0.34\")\n",
7676
" !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n",
7777
" !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n",
78-
"!pip install --no-deps git+https://github.com/huggingface/transformers.git\n",
78+
"!pip install --no-deps transformers==5.5.0\n",
7979
"!pip install torchcodec\n",
8080
"import torch; torch._dynamo.config.recompile_limit = 64;"
8181
]
@@ -114,15 +114,16 @@
114114
"from unsloth import FastModel\n",
115115
"import torch\n",
116116
"\n",
117-
"fourbit_models = [\n",
118-
" # Gemma 4 models\n",
117+
"gemma4_models = [\n",
118+
" # Gemma-4 instruct models:\n",
119+
" \"unsloth/gemma-4-E2B-it\",\n",
120+
" \"unsloth/gemma-4-E4B-it\",\n",
119121
" \"unsloth/gemma-4-31B-it\",\n",
122+
" \"unsloth/gemma-4-26B-A4B-it\",\n",
123+
" # Gemma-4 base models:\n",
120124
" \"unsloth/gemma-4-E2B\",\n",
121-
" \"unsloth/gemma-4-E4B-it\",\n",
122125
" \"unsloth/gemma-4-E4B\",\n",
123-
" \"unsloth/gemma-4-31B-it\",\n",
124126
" \"unsloth/gemma-4-31B\",\n",
125-
" \"unsloth/gemma-4-26B-A4B-it\",\n",
126127
" \"unsloth/gemma-4-26B-A4B\",\n",
127128
"] # More models at https://huggingface.co/unsloth\n",
128129
"\n",

nb/Gemma4_(26B_A4B)-Vision.ipynb

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "gOpYt-Zgspvw"
77
},
88
"source": [
9-
"To run this, press \"*Runtime*\" and press \"*Run all*\" on a **free** Tesla T4 Google Colab instance!\n",
9+
"To run this, press \"*Runtime*\" and press \"*Run all*\" on a Google Colab A100 instance!\n",
1010
"<div class=\"align-center\">\n",
1111
"<a href=\"https://unsloth.ai/\"><img src=\"https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png\" width=\"115\"></a>\n",
1212
"<a href=\"https://discord.gg/unsloth\"><img src=\"https://github.com/unslothai/unsloth/raw/main/images/Discord button.png\" width=\"145\"></a>\n",
@@ -75,7 +75,7 @@
7575
" xformers = 'xformers==' + {'2.10':'0.0.34','2.9':'0.0.33.post1','2.8':'0.0.32.post2'}.get(v, \"0.0.34\")\n",
7676
" !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n",
7777
" !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n",
78-
"!pip install --no-deps git+https://github.com/huggingface/transformers.git\n",
78+
"!pip install --no-deps transformers==5.5.0\n",
7979
"!pip install torchcodec\n",
8080
"import torch; torch._dynamo.config.recompile_limit = 64;"
8181
]
@@ -112,16 +112,16 @@
112112
"from unsloth import FastVisionModel # FastLanguageModel for LLMs\n",
113113
"import torch\n",
114114
"\n",
115-
"# 4bit pre quantized models we support for 4x faster downloading + no OOMs.\n",
116-
"fourbit_models = [\n",
117-
" # Gemma 4 models\n",
115+
"gemma4_models = [\n",
116+
" # Gemma-4 instruct models:\n",
118117
" \"unsloth/gemma-4-E2B-it\",\n",
119-
" \"unsloth/gemma-4-E2B\",\n",
118+
" \"unsloth/gemma-4-E4B-it\",\n",
119+
" \"unsloth/gemma-4-31B-it\",\n",
120120
" \"unsloth/gemma-4-26B-A4B-it\",\n",
121+
" # Gemma-4 base models:\n",
122+
" \"unsloth/gemma-4-E2B\",\n",
121123
" \"unsloth/gemma-4-E4B\",\n",
122-
" \"unsloth/gemma-4-31B-it\",\n",
123124
" \"unsloth/gemma-4-31B\",\n",
124-
" \"unsloth/gemma-4-26B-A4B-it\",\n",
125125
" \"unsloth/gemma-4-26B-A4B\",\n",
126126
"] # More models at https://huggingface.co/unsloth\n",
127127
"\n",
@@ -394,8 +394,6 @@
394394
},
395395
"outputs": [],
396396
"source": [
397-
"FastVisionModel.for_inference(model) # Enable for inference!\n",
398-
"\n",
399397
"image = dataset[2][\"image\"]\n",
400398
"instruction = \"Write the LaTeX representation for this image.\"\n",
401399
"\n",
@@ -453,8 +451,6 @@
453451
"from unsloth.trainer import UnslothVisionDataCollator\n",
454452
"from trl import SFTTrainer, SFTConfig\n",
455453
"\n",
456-
"FastVisionModel.for_training(model) # Enable for training!\n",
457-
"\n",
458454
"trainer = SFTTrainer(\n",
459455
" model = model,\n",
460456
" train_dataset = converted_dataset,\n",
@@ -463,23 +459,19 @@
463459
" args = SFTConfig(\n",
464460
" per_device_train_batch_size = 1,\n",
465461
" gradient_accumulation_steps = 4,\n",
466-
" gradient_checkpointing = True,\n",
467-
"\n",
468-
" # use reentrant checkpointing\n",
469-
" gradient_checkpointing_kwargs = {\"use_reentrant\": False},\n",
470-
" max_grad_norm = 0.3, # max gradient norm based on QLoRA paper\n",
462+
" max_grad_norm = 0.3,\n",
471463
" warmup_ratio = 0.03,\n",
472464
" max_steps = 60,\n",
473-
" #num_train_epochs = 2, # Set this instead of max_steps for full training runs\n",
465+
" # num_train_epochs = 2, # Set this instead of max_steps for full training runs\n",
474466
" learning_rate = 2e-4,\n",
475467
" logging_steps = 1,\n",
476468
" save_strategy = \"steps\",\n",
477-
" optim = \"adamw_torch_fused\",\n",
469+
" optim = \"adamw_8bit\",\n",
478470
" weight_decay = 0.001,\n",
479471
" lr_scheduler_type = \"cosine\",\n",
480472
" seed = 3407,\n",
481473
" output_dir = \"outputs\",\n",
482-
" report_to = \"none\", # For Weights and Biases\n",
474+
" report_to = \"none\", # For Weights and Biases or others\n",
483475
"\n",
484476
" # You MUST put the below items for vision finetuning:\n",
485477
" remove_unused_columns = False,\n",
@@ -563,8 +555,6 @@
563555
},
564556
"outputs": [],
565557
"source": [
566-
"FastVisionModel.for_inference(model) # Enable for inference!\n",
567-
"\n",
568558
"image = dataset[10][\"image\"]\n",
569559
"instruction = \"Write the LaTeX representation for this image.\"\n",
570560
"\n",
@@ -642,9 +632,6 @@
642632
" model_name = \"gemma_4_lora\", # YOUR MODEL YOU USED FOR TRAINING\n",
643633
" load_in_4bit = True, # Set to False for 16bit LoRA\n",
644634
" )\n",
645-
" FastVisionModel.for_inference(model) # Enable for inference!\n",
646-
"\n",
647-
"FastVisionModel.for_inference(model) # Enable for inference!\n",
648635
"\n",
649636
"sample = dataset[1]\n",
650637
"image = sample[\"image\"].convert(\"RGB\")\n",

0 commit comments

Comments
 (0)