Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates multiple Jupyter Notebooks to migrate from Hugging Face TRL's SFTTrainer and SFTConfig to Unsloth's native UnslothTrainer and UnslothTrainingArguments. Additionally, it replaces manual PyTorch CUDA memory tracking and cache clearing with Unsloth's utility functions get_gpu_memory_stats and clear_gpu_memory, and removes redundant import torch statements. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Migrates supported SFT-style notebooks to use the backend-aware public Unsloth trainer API (UnslothTrainer / UnslothTrainingArguments) so notebooks run without manual trainer import changes across CUDA/ROCm/XPU and MLX.
Changes:
- Replace TRL
SFTTrainer/SFTConfigusage withUnslothTrainer/UnslothTrainingArgumentsacross supported notebooks. - Replace CUDA-only memory stat cells with
get_gpu_memory_stats()and CUDA-only cleanup calls withclear_gpu_memory(). - Remove
torchimports where they were only used for the replaced CUDA memory helpers.
Reviewed changes
Copilot reviewed 258 out of 258 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| original_template/gpt_oss_(20B)_500K_Context_Fine_tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/gpt-oss-(20B)-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/gpt-oss-(120B)_A100-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Qwen3_(4B)-Thinking.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Qwen3_(4B)-Instruct.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Qwen3_(14B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Qwen3_(14B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Qwen2_(7B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Meta_Synthetic_Data_Llama3_2_(3B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Magistral_(24B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Llama3_(8B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Llama3.2_(1B)-RAFT.ipynb | Switch trainer class to UnslothTrainer; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Granite4.0_350M.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Granite4.0.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma4_(12B)_Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma4_(12B)_Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma3_(4B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma3_(27B)_A100-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma3_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma3N_(4B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma2_(9B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Gemma2_(2B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/Falcon_H1_(0.5B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| original_template/CodeGemma_(7B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/gpt_oss_(20B)_500K_Context_Fine_tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/gpt-oss-(20B)-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/gpt-oss-(120B)_A100-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/TinyQwen3_MoE.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA cache clear with clear_gpu_memory() |
| nb/Qwen3_VL_(8B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Qwen3_MoE.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA cache clear with clear_gpu_memory() |
| nb/Qwen3_(4B)-Thinking.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Qwen3_(4B)-Instruct.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Qwen3_(14B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Qwen3_(14B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Meta_Synthetic_Data_Llama3_2_(3B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Magistral_(24B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Llama3_(8B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Llama3.2_(1B)-RAFT.ipynb | Switch trainer class to UnslothTrainer; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-gpt_oss_(20B)_500K_Context_Fine_tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-gpt-oss-(20B)-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-gpt-oss-(120B)_A100-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Qwen3_(4B)-Thinking.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Qwen3_(4B)-Instruct.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Qwen3_(14B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Magistral_(24B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Llama3_(8B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Llama3.2_(1B)-RAFT.ipynb | Switch trainer class to UnslothTrainer; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Granite4.0_350M.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Granite4.0.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma4_(12B)_Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma4_(12B)_Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma3_(4B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma3_(27B)_A100-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma3_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma3N_(4B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma2_(9B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-Gemma2_(2B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Kaggle-CodeGemma_(7B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Granite4.0_350M.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Granite4.0.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(E4B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(E4B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(E2B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(E2B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(31B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(31B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(26B_A4B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(26B_A4B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(12B)_Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma4_(12B)_Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma3_(4B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma3_(27B)_A100-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma3_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma3N_(4B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma2_(9B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Gemma2_(2B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/GLM_Flash_A100(80GB).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/FunctionGemma_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/Falcon_H1_(0.5B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/CodeGemma_(7B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-gpt_oss_(20B)_500K_Context_Fine_tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-gpt-oss-(20B)-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-gpt-oss-(120B)_A100-Fine-tuning.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-TinyQwen3_MoE.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA cache clear with clear_gpu_memory() |
| nb/AMD-Qwen3_MoE.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA cache clear with clear_gpu_memory() |
| nb/AMD-Qwen3_(4B)-Thinking.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Qwen3_(4B)-Instruct.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Qwen3_(14B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Magistral_(24B)-Reasoning-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Llama3_(8B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Llama3.2_(1B)-RAFT.ipynb | Switch trainer class to UnslothTrainer; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Granite4.0_350M.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Granite4.0.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(E4B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(E4B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(E2B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(E2B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(31B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(31B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(26B_A4B)-Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(26B_A4B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(12B)_Vision.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma4_(12B)_Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma3_(4B).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma3_(27B)_A100-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma3_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma3N_(4B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma2_(9B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Gemma2_(2B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-GLM_Flash_A100(80GB).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-FunctionGemma_(270M).ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-Falcon_H1_(0.5B)-Alpaca.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| nb/AMD-CodeGemma_(7B)-Conversational.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| kaggle/Gemma4_(E4B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
| kaggle/Gemma4_(31B)-Text.ipynb | Switch trainer/config imports to Unsloth API; replace CUDA memory stats with get_gpu_memory_stats() |
Comments suppressed due to low confidence (3)
original_template/gpt-oss-(20B)-Fine-tuning.ipynb:1
- Using positional indexing into
get_gpu_memory_stats()is brittle and harder to read. Consider unpacking the returned tuple instead (e.g., assignused_memoryvia unpacking) so the notebook remains clear and resilient if the helper's return order ever changes.
nb/gpt_oss_(20B)_500K_Context_Fine_tuning.ipynb:1 - Same issue as other notebooks: avoid
get_gpu_memory_stats()[1]and unpack the tuple to extractused_memory. This improves readability and reduces the chance of silently breaking ifget_gpu_memory_stats()changes.
nb/Qwen3_MoE.ipynb:1 - The cleanup order is suboptimal: calling
gc.collect()before clearing GPU caches is typically more effective because it frees Python-side references first. Consider reordering toimport gc->gc.collect()->clear_gpu_memory()soclear_gpu_memory()can release memory from objects actually reclaimed by GC.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60b3decb0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Reviewed and tested the migration on CUDA, and checked generator consistency. Verified on GPU
One thing to fix before merge:
|
…er and get_gpu_memory_stats
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7202a148e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Companion PR for the main unsloth MLX trainer API PR: unslothai/unsloth#6462
This migrates supported SFT notebooks, plus explicitly selected near-term notebook surfaces, to the backend-aware public Unsloth trainer API. Users should not need to edit trainer imports by hand for MLX: notebooks import
UnslothTrainer/UnslothTrainingArgumentsfromunsloth, and the runtime routes to CUDA/ROCm/XPU or MLX as appropriate when the task surface is supported.Companion PRs
Notebook Scope
This PR updates SFT-style notebook trainer surfaces that are supported by the MLX route now, plus selected notebook surfaces that should not need another public API migration when backend-owned support lands. It intentionally excludes task families that are not in the MLX notebook target set.
The mechanical notebook migration is intentionally narrow:
from trl import SFTTrainer, SFTConfigwithfrom unsloth import UnslothTrainer, UnslothTrainingArguments.SFTTrainer(...)calls withUnslothTrainer(...).SFTConfig(...)calls withUnslothTrainingArguments(...).get_gpu_memory_stats()fromunsloth.clear_gpu_memory()fromunslothwhere the notebook had a cleanup helper.import torchlines when they were only used by the replaced CUDA memory-stat cells.SFTTrainerdocs.TrainOutput.metricsand the MLX trainer's metrics dict.The broadened notebook set now includes:
UnslothVisionDataCollatorand map to MLX training-qualified VLM families.DataCollatorForSeq2SeqSFT notebooks, including Llama 3.2, Llama 3.3, Phi-4, Qwen2.5 Coder, and Synthetic Data Hackathon variants.packing=TrueTinyLlama SFT notebooks, so packing recipes are already routed through the public Unsloth trainer API.What this PR avoids:
update_all_notebooks.py; the migration was a one-time generated replacement and the replacement script is not tracked.UnslothTrainingArgumentsdescriptions to notebooks that did not already have config-related explanatory text.torchusage such as inference tensors, generation snippets, or examples that still need PyTorch on CUDA/ROCm.Documentation Link Updates
Some notebooks had markdown text changed from
SFTTrainertoUnslothTrainer. Those descriptions no longer point to TRLSFTTrainerdocs.Notebooks Touched
The diff updates 258 notebook files across:
nb/kaggle/original_template/Representative migrated notebook families include supported Gemma/Gemma2/Gemma3/Gemma4 text and chat notebooks, Llama, Mistral, Qwen, Phi, AMD/Kaggle variants, Synthetic text notebooks, verified Vision/VL notebooks,
packing=TrueTinyLlama variants, and text-onlyDataCollatorForSeq2Seqconversational/hackathon variants.Verified Vision/VL families included in this PR:
Unsupported or uncertain task/model families remain unchanged, including Audio/OCR/TTS task notebooks, GRPO/RL notebooks, QAT/deployment notebooks, custom trainer subclass notebooks, stale alternate Falcon templates, ERNIE VL, Paddle OCR Vision, Qwen3.5 Vision variants, and LFM2.5-VL.
LFM2.5-VL is intentionally excluded because the current MLX compile qualification reports
lfm2_vlas fallback-only / not training-qualified, with compile blockers around Python data extraction and ragged control flow.Non-Goals / Deferred Work
data_collatorexecution on MLX remains deferred in the runtime PRs. The 44 Vision/VL notebooks are included becauseUnslothVisionDataCollatoris a supported backend-aware compatibility path that routes processor/image batches intoMLXTrainer.DataCollatorForSeq2Seqnotebooks are included in the public API surface so they do not need another notebook migration when the backend support lands.packing=Trueruntime behavior on MLX remains backend-owned. This PR only routes packing notebooks through the public Unsloth trainer API.Real Gemma3 Notebook Parity Run
I ran a real supported Gemma3 SFT notebook path from
nb/Gemma3_(270M).ipynbon three variants. The runner follows the notebook cells for model load, LoRA setup, Gemma3 chat template,Thytu/ChessInstructformatting, andtrain_on_responses_only; the only training change ismax_steps=100 -> 10so the PR can record a short curve. No model weights over 5GB were downloaded.Run configuration:
unsloth/gemma-3-270m-itThytu/ChessInstruct,train[:10000]2048r=128,lora_alpha=128, target modulesq_proj/k_proj/v_proj/o_proj/gate_proj/up_proj/down_projper_device_train_batch_size=4,gradient_accumulation_steps=1, effective batch size 4warmup_steps=5,learning_rate=5e-5,lr_scheduler_type="linear"optim="adamw_8bit"34072.11.0+cu128, Transformers5.5.0, TRL0.24.0mlx-lm 0.31.3, Transformers5.5.0, TRL0.24.0Variant commits:
unslothai/unsloth@45f060899e56d8a8d218529733075814148f6b19+unslothai/unsloth-zoo@28063c2a28b148b32390476dc86d2940395416af, using notebook-maintrl.SFTTrainer/SFTConfigLyxot/unsloth@60385efb06d236202a8adc2540a0210935f94511+Lyxot/unsloth-zoo@6685266e567511fd2e582ab677834dc0345a62b7, using branchUnslothTrainer/UnslothTrainingArgumentsLyxot/unsloth@1040ccccf0905df2ae4f237fb6953bfad1715827+Lyxot/unsloth-zoo@6685266e567511fd2e582ab677834dc0345a62b7, using branchUnslothTrainer/UnslothTrainingArgumentsResults:
Curve summary:
0.0; max absolute grad-norm delta0.0.0.0357; mean absolute loss delta0.0147; final loss0.8565vs CUDA0.8521; final grad norm8.8934vs CUDA8.8184.481, matching the previous 30-step parity run's first 10 steps after removing the extra EOS token.1.8009, CUDA branch1.8009, MLX branch1.7881.Notebook Audit / Validation
Notebook-specific audits performed for this branch:
SFTTrainer/SFTConfigimports in the migration scope.import torchintroduced only by the old memory-stat cells, includingkaggle/Gemma4_(31B)-Text.ipynb.UnslothTrainerdescriptions do not still link to TRLSFTTrainerdocs or the continued-pretraining docs.DataCollatorForSeq2Seqnotebooks, with Orpheus TTS collator notebooks intentionally left unchanged.packing=TrueTinyLlama notebooks.UnslothVisionDataCollator.gemma3,gemma3n,gemma4,mllama,mistral3,pixtral,qwen2_vl,qwen2_5_vl, andqwen3_vlare training-qualified.lfm2_vlis not training-qualified and that LFM2.5-VL notebooks remain unchanged.trainer_stats.metrics[...]directly where the final stats cell needs backend-compatible metrics access.Gemma3_(270M).ipynbpath above against CUDA main, CUDA branch, and MLX branch.The CUDA branch result is exactly identical to CUDA main for 10 logged training steps, which is the key regression check for existing NVIDIA behavior after replacing notebook imports with
UnslothTrainer.