Skip to content

Commit 8ef15ba

Browse files
Fix Gemma 4, Qwen 2.5 VL GRPO, Qwen 3.5 27B handling in update_all_notebooks.py and run it (#232)
This PR fixes four bugs in update_all_notebooks.py that were silently corrupting notebooks, ports a Qwen 2.5 VL GRPO hotfix into the template so the script stops reverting it, then commits the result of a clean re-run of the fixed script. Script fixes ------------ 1. _get_base_name_from_filename now recognizes Gemma 4. It already had explicit cases for Gemma 3 and Gemma 3n but no case for Gemma 4, so Gemma 4 notebooks fell through to the generic path which stripped the "4" and returned just "gemma". That caused the model-path rewrite to rename gemma_4_lora / gemma_4_finetune to gemma_lora / gemma_finetune on every run across the four Gemma 4 Text notebooks. Added _RE_GEMMA4 and a return "gemma_4" branch. 2. Added a dedicated installation_gemma4_content block and a dispatch case in update_notebook_sections matching paths containing "gemma4". The default installation_content forces transformers==4.56.2 and appends --no-deps trl==0.22.2 via update_or_append_pip_install, both of which are wrong for Gemma 4. The new block contains the required --no-deps transformers==5.5.0, !pip install torchcodec, and torch._dynamo.config.recompile_limit = 64 lines, and does NOT go through update_or_append_pip_install so the bad pins are never applied. 3. Qwen 3.5 dispatch now matches both "qwen3_5" and "qwen_3_5" so that the inconsistently-named Qwen_3_5_27B_A100(80GB).ipynb (with an underscore between Qwen and 3) also hits its proper installation block. Previously it fell through to the default installation_content which clobbered the custom torch==2.8.0 / xformers==0.0.32.post2 / flash-linear-attention / causal_conv1d==1.6.0 install block, which would make the notebook fail to load the model (Qwen 3.5 has mamba layers and needs causal_conv1d). Template patch -------------- 4. original_template/Qwen2_5_7B_VL_GRPO.ipynb now contains the same isinstance(prompt, list) guard that was added to the three nb/ siblings in c75716f ("Fix fast_generate crash in Qwen2.5-VL GRPO notebooks with TRL >= 0.24.0"). The hotfix was applied directly to nb/ but never propagated to original_template/, so every subsequent run of this script was reverting it. With the template patched, the script regenerates all three sibling notebooks with the guard intact. Affected code appears at dataset rows 100 and 165 and is a ~10-line change per cell that renders the multimodal prompt via tokenizer.apply_chat_template before passing it to fast_generate. Changes produced by re-running the fixed script (275 files, +7777 / -1433) ------------------------------------------------------------------------- - update_all_notebooks.py: the four fixes above. - original_template/Qwen2_5_7B_VL_GRPO.ipynb: +8 / -2 for the hotfix. - .gitignore: new file (the repo had none). Covers __pycache__ / *.pyc. - README.md: +17 lines of new Vision / Audio rows. - nb/*.ipynb: 17 notebooks touched. - python_scripts/*.py: 243 regenerated + 11 new (missing Gemma 4 exports + Openenv_wordle_grpo.py). ~72% of the line churn (5608 / 7777 added lines) is the 11 brand-new python_scripts/ files. Verification ------------ Gemma 4 Text notebooks: | notebook | gemma_4_lora | gemma_lora | torchcodec | --no-deps t5.5.0 | trl==0.22.2 (bad) | | --------------- | ------------ | ---------- | ---------- | ---------------- | ----------------- | | 26B_A4B-Text | 8 | 0 | 1 | 1 | 0 | | 31B-Text | 8 | 0 | 1 | 1 | 0 | | E2B-Text | 8 | 0 | 1 | 1 | 0 | | E4B-Text | 8 | 0 | 1 | 1 | 0 | Qwen 2.5 VL GRPO siblings all contain the isinstance(prompt, list) hotfix (2 occurrences each in Qwen2_5_7B_VL_GRPO.ipynb, HuggingFace Course-Qwen2_5_7B_VL_GRPO.ipynb, and Kaggle-Qwen2_5_7B_VL_GRPO.ipynb). Qwen_3_5_27B_A100(80GB).ipynb has a net 1-line diff (transformers 5.2.0 -> 5.3.0 from _normalize_transformers_v5_pin) and preserves torch==2.8.0, xformers==0.0.32.post2, flash-linear-attention, and causal_conv1d==1.6.0.
1 parent fa372ba commit 8ef15ba

File tree

275 files changed

+7777
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+7777
-1433
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Python bytecode
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Below are Colab notebooks, organized by model. You can also view all [notebooks
5454
| **LFM2.5** **(1.2B)** | GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/LFM2.5_(1.2B)-GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
5555
| **DeepSeek R1 0528 Qwen3** **(8B)** | GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/DeepSeek_R1_0528_Qwen3_(8B)_GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
5656
| **Mistral v0.3** **(7B)** | GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Mistral_v0.3_(7B)-GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
57+
| **Openenv wordle** | GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Openenv_wordle_grpo.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
5758

5859
### Text-to-Speech (TTS) Notebooks
5960
| Model | Type | Notebook Link |
@@ -69,11 +70,16 @@ Below are Colab notebooks, organized by model. You can also view all [notebooks
6970
| Model | Type | Notebook Link |
7071
| --- | --- | --- |
7172
| **Pixtral** **(12B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Pixtral_(12B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
73+
| **Gemma4** **(E4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E4B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
74+
| **Gemma4** **(E2B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E2B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
75+
| **Gemma4** **(31B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(31B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
76+
| **Gemma4** **(26B A4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(26B_A4B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7277
| **ERNIE 4 5 VL 28B A3B PT** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/ERNIE_4_5_VL_28B_A3B_PT_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7378
| **Llama3.2** **(11B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.2_(11B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7479
| **Qwen3 VL** **(8B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_VL_(8B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7580
| **Qwen3 VL** **(8B)** | Vision GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_VL_(8B)-Vision-GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7681
| **Qwen3 5** **(4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
82+
| **Qwen3 5** **(4B)** | Vision GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)_Vision_GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7783
| **Qwen3 5** **(2B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(2B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7884
| **Qwen3 5** **(0 8B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(0_8B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
7985
| **Ministral3 VL** **(3B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Ministral_3_VL_(3B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
@@ -159,6 +165,16 @@ Below are Colab notebooks, organized by model. You can also view all [notebooks
159165
| **FunctionGemma** **(270M)** | Conversational | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/FunctionGemma_(270M).ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
160166
| **(A100) Gemma3** **(27B)** | Conversational | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3_(27B)_A100-Conversational.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
161167
| **CodeGemma** **(7B)** | Conversational | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/CodeGemma_(7B)-Conversational.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
168+
| **Gemma4** **(E4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E4B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
169+
| **Gemma4** **(E4B)** | Audio | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E4B)-Audio.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
170+
| **Gemma4** **(E4B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E4B)-Text.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
171+
| **Gemma4** **(E2B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E2B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
172+
| **Gemma4** **(E2B)** | Audio | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E2B)-Audio.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
173+
| **Gemma4** **(E2B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(E2B)-Text.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
174+
| **Gemma4** **(31B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(31B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
175+
| **Gemma4** **(31B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(31B)-Text.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
176+
| **Gemma4** **(26B A4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(26B_A4B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
177+
| **Gemma4** **(26B A4B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma4_(26B_A4B)-Text.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
162178
| **Gemma3N** **(4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3N_(4B)-Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
163179
| **Gemma3N** **(4B)** | Multimodal | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3N_(4B)-Conversational.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
164180
| **Gemma3N** **(4B)** | Audio | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Gemma3N_(4B)-Audio.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
@@ -255,6 +271,7 @@ Below are Colab notebooks, organized by model. You can also view all [notebooks
255271
| **Qwen3 Embedding** **(4B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_Embedding_(4B).ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
256272
| **Qwen3 Embedding** **(0 6B)** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_Embedding_(0_6B).ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
257273
| **Qwen3 5** **(4B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
274+
| **Qwen3 5** **(4B)** | Vision GRPO | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)_Vision_GRPO.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
258275
| **Qwen3 5** **(2B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(2B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
259276
| **Qwen3 5** **(0 8B)** | Vision | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(0_8B)_Vision.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |
260277
| **Qwen3 5 MoE** | | <a href="https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_MoE.ipynb" target="_blank" rel="noopener noreferrer"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a> |

nb/Gemma4_(26B_A4B)-Text.ipynb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,7 @@
6565
"id": "A6wGqvTjsavr"
6666
},
6767
"outputs": [],
68-
"source": [
69-
"%%capture\n",
70-
"import os, re\n",
71-
"if \"COLAB_\" not in \"\".join(os.environ.keys()):\n",
72-
" !pip install unsloth # Do this in local & cloud setups\n",
73-
"else:\n",
74-
" import torch; v = re.match(r'[\\d]{1,}\\.[\\d]{1,}', str(torch.__version__)).group(0)\n",
75-
" 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",
76-
" !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n",
77-
" !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n",
78-
"!pip install --no-deps transformers==5.5.0\n",
79-
"!pip install torchcodec\n",
80-
"import torch; torch._dynamo.config.recompile_limit = 64;"
81-
]
68+
"source": "%%capture\nimport os, re\nif \"COLAB_\" not in \"\".join(os.environ.keys()):\n !pip install unsloth # Do this in local & cloud setups\nelse:\n import torch; v = re.match(r'[\\d]{1,}\\.[\\d]{1,}', str(torch.__version__)).group(0)\n 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 !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n!pip install --no-deps transformers==5.5.0\n!pip install torchcodec\nimport torch; torch._dynamo.config.recompile_limit = 64;"
8269
},
8370
{
8471
"cell_type": "code",
@@ -416,7 +403,7 @@
416403
" return_tensors = \"pt\",\n",
417404
" ).to(\"cuda\"),\n",
418405
" max_new_tokens = max_new_tokens,\n",
419-
" use_cache=True,\n",
406+
" use_cache = True,\n",
420407
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
421408
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
422409
" )"
@@ -1555,6 +1542,9 @@
15551542
"data": {
15561543
"text/plain": [
15571544
"['<bos><|turn>user\\nContinue the sequence: 1, 1, 2, 3, 5, 8,<turn|>\\n<|turn>model\\n<|channel>thought\\n<channel|>13, 21, 34, 55, 89, 144, ...\\n\\nThis is the **Fibonacci sequence**, where each number is the sum of the two preceding ones.<turn|>']"
1545+
],
1546+
"text/html": [
1547+
"<pre>[&#x27;&lt;bos&gt;&lt;|turn&gt;user\\nContinue the sequence: 1, 1, 2, 3, 5, 8,&lt;turn|&gt;\\n&lt;|turn&gt;model\\n&lt;|channel&gt;thought\\n&lt;channel|&gt;13, 21, 34, 55, 89, 144, ...\\n\\nThis is the **Fibonacci sequence**, where each number is the sum of the two preceding ones.&lt;turn|&gt;&#x27;]</pre>"
15581548
]
15591549
},
15601550
"metadata": {},
@@ -1584,7 +1574,7 @@
15841574
"outputs = model.generate(\n",
15851575
" **inputs,\n",
15861576
" max_new_tokens = 64, # Increase for longer outputs!\n",
1587-
" use_cache=True,\n",
1577+
" use_cache = True,\n",
15881578
" # Recommended Gemma-3 settings!\n",
15891579
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
15901580
")\n",
@@ -1642,7 +1632,7 @@
16421632
"_ = model.generate(\n",
16431633
" **inputs,\n",
16441634
" max_new_tokens = 64, # Increase for longer outputs!\n",
1645-
" use_cache=True,\n",
1635+
" use_cache = True,\n",
16461636
" # Recommended Gemma-3 settings!\n",
16471637
" temperature = 1.0, top_p = 0.95, top_k = 64,\n",
16481638
" streamer = TextStreamer(tokenizer, skip_prompt = True),\n",
@@ -7723,7 +7713,8 @@
77237713
"_view_name": "StyleView",
77247714
"description_width": ""
77257715
}
7726-
}
7716+
},
7717+
"state": {}
77277718
}
77287719
}
77297720
},

nb/Gemma4_(26B_A4B)-Vision.ipynb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,7 @@
6565
"id": "f6leZW9xspvx"
6666
},
6767
"outputs": [],
68-
"source": [
69-
"%%capture\n",
70-
"import os, re\n",
71-
"if \"COLAB_\" not in \"\".join(os.environ.keys()):\n",
72-
" !pip install unsloth # Do this in local & cloud setups\n",
73-
"else:\n",
74-
" import torch; v = re.match(r'[\\d]{1,}\\.[\\d]{1,}', str(torch.__version__)).group(0)\n",
75-
" 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",
76-
" !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n",
77-
" !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n",
78-
"!pip install --no-deps transformers==5.5.0\n",
79-
"!pip install torchcodec\n",
80-
"import torch; torch._dynamo.config.recompile_limit = 64;"
81-
]
68+
"source": "%%capture\nimport os, re\nif \"COLAB_\" not in \"\".join(os.environ.keys()):\n !pip install unsloth # Do this in local & cloud setups\nelse:\n import torch; v = re.match(r'[\\d]{1,}\\.[\\d]{1,}', str(torch.__version__)).group(0)\n 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 !pip install sentencepiece protobuf \"datasets==4.3.0\" \"huggingface_hub>=0.34.0\" hf_transfer\n !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth\n!pip install --no-deps transformers==5.5.0\n!pip install torchcodec\nimport torch; torch._dynamo.config.recompile_limit = 64;"
8269
},
8370
{
8471
"cell_type": "code",
@@ -943,7 +930,7 @@
943930
"source": [
944931
"<a name=\"Train\"></a>\n",
945932
"### Train the model\n",
946-
"Now let's train our model. We do 60 steps to speed things up, but you can set `num_train_epochs=1` for a full run, and turn off `max_steps=None`. We also support `DPOTrainer` and `GRPOTrainer` for reinforcement learning!!\n",
933+
"Now let's train our model. We do 60 steps to speed things up, but you can set `num_train_epochs=1` for a full run, and turn off `max_steps=None`. We also support `DPOTrainer` and `GRPOTrainer` for reinforcement learning!\n",
947934
"\n",
948935
"We use our new `UnslothVisionDataCollator` which will help in our vision finetuning setup."
949936
]
@@ -6429,7 +6416,8 @@
64296416
"_view_name": "StyleView",
64306417
"description_width": ""
64316418
}
6432-
}
6419+
},
6420+
"state": {}
64336421
}
64346422
}
64356423
},

0 commit comments

Comments
 (0)