Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Bug fixes (#3546)
Daniel Hana9ff4e23c950
diff --git a/pyproject.toml b/pyproject.tomlindex 8e2648865ad..146c5a85f81 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -55,11 +55,11 @@ huggingfacenotorch = ["hf_transfer","diffusers","transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,<=4.57.2",- "trl>=0.18.2,!=0.19.0,<=0.23.0",+ "trl>=0.18.2,!=0.19.0,<=0.24.0",]huggingface = ["unsloth[huggingfacenotorch]",- "unsloth_zoo>=2025.10.13",+ "unsloth_zoo>=2025.11.1","torchvision","unsloth[triton]",]@@ -489,7 +489,7 @@ colab-ampere-torch220 = ["flash-attn>=2.6.3 ; ('linux' in sys_platform)",]colab-new = [- "unsloth_zoo>=2025.10.13",+ "unsloth_zoo>=2025.11.1","packaging","tyro","transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,<=4.57.2",@@ -507,7 +507,7 @@ colab-new = []colab-no-deps = ["accelerate>=0.34.1",- "trl>=0.18.2,!=0.19.0,<=0.23.0",+ "trl>=0.18.2,!=0.19.0,<=0.24.0","peft>=0.7.1","xformers ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')","bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0",diff --git a/unsloth/__init__.py b/unsloth/__init__.pyindex 9fb2e0dc40f..a7ee579241f 100644--- a/unsloth/__init__.py+++ b/unsloth/__init__.py@@ -29,7 +29,6 @@ already_imported = [mod for mod in critical_modules if mod in sys.modules]# their code at import time. If they're imported first, the original (slower,# more memory-intensive) implementations will be used instead of Unsloth's# optimized versions, potentially causing OOM errors or slower training.-if already_imported:# stacklevel=2 makes warning point to user's import line rather than this library code,# showing them exactly where to fix the import order in their script@@ -40,7 +39,7 @@ if already_imported:f"Please restructure your imports with 'import unsloth' at the top of your file.",stacklevel = 2,)-pass+del already_imported, critical_modules# Unsloth currently does not work on multi GPU setups - sadly we are a 2 brother team so# enabling it will require much more work, so we have to prioritize. Please understand!@@ -57,14 +56,12 @@ os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"# Log Unsloth is being usedos.environ["UNSLOTH_IS_PRESENT"] = "1"-import importlib.util-from pathlib import Pathfrom importlib.metadata import version as importlib_versionfrom importlib.metadata import PackageNotFoundError# Check for unsloth_zootry:unsloth_zoo_version = importlib_version("unsloth_zoo")- if Version(unsloth_zoo_version) < Version("2025.10.13"):+ if Version(unsloth_zoo_version) < Version("2025.11.1"):print("Unsloth: Please update Unsloth and Unsloth-Zoo to the latest version!\n"\"Do this via `pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo`"@@ -82,7 +79,7 @@ except PackageNotFoundError:raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!")except:raise-pass+del PackageNotFoundError, importlib_version# Try importing PyTorch and check versiontry:@@ -92,8 +89,8 @@ except ModuleNotFoundError:"Unsloth: Pytorch is not installed. Go to https://pytorch.org/.\n"\"We have some installation instructions on our Github page.")-except Exception as exception:- raise exception+except:+ raisepassfrom unsloth_zoo.device_type import (@@ -130,7 +127,7 @@ if DEVICE_TYPE == "cuda":else:def is_bf16_supported(): return SUPPORTS_BFLOAT16torch.cuda.is_bf16_supported = is_bf16_supported- pass+ del major_version, minor_versionelif DEVICE_TYPE == "hip":SUPPORTS_BFLOAT16 = torch.cuda.is_bf16_supported()elif DEVICE_TYPE == "xpu":@@ -179,6 +176,8 @@ if DEVICE_TYPE == "cuda":latest_cuda = np.argsort([float(find_number.search(x).group(1)) for x in possible_cudas])[::-1][0]latest_cuda = possible_cudas[latest_cuda]os.system(f"ldconfig /usr/local/{latest_cuda}")+ del find_number, latest_cuda+ del possible_cudas, find_cudapassimportlib.reload(bnb)@@ -200,7 +199,7 @@ if DEVICE_TYPE == "cuda":"Also try `sudo ldconfig /usr/local/cuda-xx.x` - find the latest cuda version.\n"\"Unsloth will still run for now, but maybe it might crash - let's hope it works!")- pass+ del libcuda_dirselif DEVICE_TYPE == "hip":# NO-OP for rocm devicepassdiff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex b9ae4282cd8..0e79b7ce88e 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -12,7 +12,7 @@# See the License for the specific language governing permissions and# limitations under the License.-__version__ = "2025.10.12"+__version__ = "2025.11.1"__all__ = ["SUPPORTS_BFLOAT16",@@ -235,6 +235,9 @@ del transformers_training_args_logger# No label_names provided for model classfrom transformers.trainer import logger as transformers_trainer_loggertransformers_trainer_logger.addFilter(HideLoggingMessage("No label_names"))++# The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config.+transformers_trainer_logger.addFilter(HideLoggingMessage("The tokenizer has new"))del transformers_trainer_logger# Using the default loss: `ForCausalLMLoss`.diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex 9ced8f1992c..67b407075cf 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -752,11 +752,11 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):" scale_rewards = False\n"\"elif loss_type.lower() == 'dapo':\n"\" if mask_truncated_completions != True:\n"\- " print('Unsloth: The DAPO paper recommends `mask_truncated_completions = True`')\n"\+ " print('Unsloth: The DAPO paper recommends `mask_truncated_completions = True` - we will set it.')\n"\" if epsilon_high != 0.28:\n"\- " print('Unsloth: The DAPO paper recommends `epsilon_high = 0.28`')\n"\+ " print('Unsloth: The DAPO paper recommends `epsilon_high = 0.28` - we will set it.')\n"\" if beta != 0.0:\n"\- " print('Unsloth: The DAPO paper recommends setting `beta = 0.0` to remove the KL term')\n"\+ " print('Unsloth: The DAPO paper recommends setting `beta = 0.0` to remove the KL term - we will set it.')\n"\" mask_truncated_completions = True\n"\" epsilon_high = 0.28\n"\" beta = 0.0\n"\@@ -1085,10 +1085,13 @@ def patch_functions(RLTrainer, trainer_file, RLTrainer_name, all_imports, import)# Replace self.llm.generate and self.llm.chat- lora_name = trainer_file + "_lora_model"+ if "CUDA_VISIBLE_DEVICES" in os.environ:+ lora_name = trainer_file + "_lora_model_' + " + "(os.environ.get('CUDA_VISIBLE_DEVICES', '0').replace(',',''))"+ else:+ lora_name = trainer_file + "_lora_model'"source = re.sub(r"(self\.llm\.(?:generate|chat)\([^\)]{1,})\)",- r"\1, lora_request = self.model.load_lora('" + lora_name + r"', load_tensors = True))",+ r"\1, lora_request = self.model.load_lora('" + lora_name + r", load_tensors = True))",source)# Prefer using unsloth's sampling params and fallback to trl's if not founddiff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.pyindex ea7183fc5af..281e3a71df2 100644--- a/unsloth/models/rl_replacements.py+++ b/unsloth/models/rl_replacements.py@@ -216,17 +216,17 @@ def grpo_trainer__generate_and_score_completions(function_name, function):replacement_lines = """batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_sizetry:- #TRL 0.23.1 and below path+ # TRL 0.23.1 and below pathif not has_images:# Left pad prompt before calculation old and ref hidden statesprompt_completion_ids = left_pack_padding(prompt_completion_ids, self.processing_class.pad_token_id)self.model.for_training()- except:- #TRL 0.24.0 and below path+ except:+ # TRL 0.24.0 and below pathif images is None:# Left pad prompt before calculation old and ref hidden statesprompt_completion_ids = left_pack_padding(prompt_completion_ids, self.processing_class.pad_token_id)- self.model.for_training()"""+ self.model.for_training()"""function = function.replace(line_to_replace, replacement_lines)diff --git a/unsloth/models/vision.py b/unsloth/models/vision.pyindex 65ba9ccf9b1..3ec4c46f7ff 100644--- a/unsloth/models/vision.py+++ b/unsloth/models/vision.py@@ -91,6 +91,7 @@ VLLM_SUPPORTED_VLM = ["qwen2_5_vl","gemma3","mistral3",+ "qwen3_vl",]VLLM_NON_LORA_VLM = ["mllama",