Skip to content

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.

Bug fixes

Daniel Hane88cb620ab1b
diff --git a/unsloth/__init__.py b/unsloth/__init__.py
index b48bc42dbec..9fb2e0dc40f 100644
--- a/unsloth/__init__.py
+++ b/unsloth/__init__.py
@@ -57,25 +57,14 @@ os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
# Log Unsloth is being used
os.environ["UNSLOTH_IS_PRESENT"] = "1"
-# Try importing PyTorch and check version
-try:
- import torch
-except ModuleNotFoundError:
- raise ImportError(
- "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
-pass
-
import importlib.util
from pathlib import Path
from importlib.metadata import version as importlib_version
+from importlib.metadata import PackageNotFoundError
# Check for unsloth_zoo
try:
unsloth_zoo_version = importlib_version("unsloth_zoo")
- if Version(unsloth_zoo_version) < Version("2025.10.12"):
+ if Version(unsloth_zoo_version) < Version("2025.10.13"):
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`"
@@ -89,10 +78,22 @@ try:
# except:
# raise ImportError("Unsloth: Please update unsloth_zoo via `pip install --upgrade --no-cache-dir --no-deps unsloth_zoo`")
import unsloth_zoo
-except NotImplementedError as e:
- raise NotImplementedError(str(e))
-except Exception as e:
- raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` Also error = {str(e)}")
+except PackageNotFoundError:
+ raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!")
+except:
+ raise
+pass
+
+# Try importing PyTorch and check version
+try:
+ import torch
+except ModuleNotFoundError:
+ raise ImportError(
+ "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
pass
from unsloth_zoo.device_type import (
diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py
index 7eb4d5721fc..27582b0b018 100644
--- a/unsloth/import_fixes.py
+++ b/unsloth/import_fixes.py
@@ -137,7 +137,7 @@ def ignore_logger_messages():
pass
def patch_ipykernel_hf_xet():
- # HF-XET == 1.1.10 and ipykernel == 7.0.0 causes issues
+ # HF-XET == 1.1.10 and ipykernel == 7.0.0 / 7.0.1 causes issues
# See https://github.com/huggingface/xet-core/issues/526
# 2025-10-13T20:37:33.028737Z ERROR Python exception updating progress:, error: PyErr { type: <class 'LookupError'>, value: LookupError(<ContextVar name='shell_parent' at 0x7535b4cebd80>), traceback: Some(<traceback object at 0x753408489f40>) }, caller: "src/progress_update.rs:313"
# at /home/runner/work/xet-core/xet-core/error_printer/src/lib.rs:28
@@ -150,12 +150,11 @@ def patch_ipykernel_hf_xet():
Version(importlib_version("hf_xet")) == Version("1.1.10")
) and (
(ipykernel_version == Version("7.0.0")) or \
- (ipykernel_version == Version("7.0.1")) or \ # 7.0.1 seems to also break with LookupError: <ContextVar name='shell_parent' at 0x7a9775143ec0>
- (ipykernel_version >= Version("7.0.2"))
+ (ipykernel_version == Version("7.0.1")) # 7.0.1 seems to also break with LookupError: <ContextVar name='shell_parent' at 0x7a9775143ec0>
):
print(
- "#### Unsloth: `hf_xet==1.1.10` and `ipykernel>=7.0.0` breaks progress bars. Using ASCII progress bars.\n"\
- "#### Unsloth: To re-enable progress bars, please downgrade to `ipykernel<7.0.0` or wait for a fix to\n"\
+ "#### Unsloth: `hf_xet==1.1.10` and `ipykernel==7.0.0` or `ipykernel==7.0.1` breaks progress bars. Using ASCII progress bars.\n"\
+ "#### Unsloth: To re-enable progress bars, please upgrade to `ipykernel>=7.1.0` or wait for a fix to\n"\
"https://github.com/huggingface/xet-core/issues/526"
)
# from huggingface_hub.utils import disable_progress_bars
@@ -168,7 +167,6 @@ def patch_ipykernel_hf_xet():
_tauto.trange = _tstd.trange
_tnb.tqdm = _tstd.tqdm
_tnb.trange = _tstd.trange
- pass
pass
def patch_trackio():
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index f65b7e9b249..b9ae4282cd8 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.11"
+__version__ = "2025.10.12"
__all__ = [
"SUPPORTS_BFLOAT16",
@@ -975,12 +975,12 @@ def _get_statistics(statistics = None, force_download = True):
from huggingface_hub import snapshot_download
from unsloth_zoo.rl_environments import execute_with_time_limit
if has_internet():
- @execute_with_time_limit(120)
def stats_check():
with tempfile.TemporaryDirectory(ignore_cleanup_errors = True) as f:
snapshot_download(f"unslothai/{statistics}", force_download = True, cache_dir = f, local_dir = f)
+ time_limited_stats_check = execute_with_time_limit(120)(stats_check)
try:
- stats_check()
+ time_limited_stats_check()
except TimeoutError:
raise TimeoutError(
"Unsloth: HuggingFace seems to be down after trying for 120 seconds :(\n"\
@@ -993,6 +993,9 @@ def _get_statistics(statistics = None, force_download = True):
"model = FastLanguageModel.from_pretrained('unsloth/gpt-oss-20b')\n"\
"```"
)
+ except:
+ # Try no time limit check
+ stats_check()
pass
pass
pass
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 5f92999f447..aea1a4cc1c2 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -133,6 +133,7 @@ class FastLanguageModel(FastLlamaModel):
revision = None,
use_exact_model_name = False,
offload_embedding = False,
+ float32_mixed_precision = None, # Forces float32 mixed precision
fast_inference = False, # uses vLLM
gpu_memory_utilization = 0.5,
@@ -172,7 +173,7 @@ class FastLanguageModel(FastLlamaModel):
fullgraph = True, # No graph breaks
use_exact_model_name = use_exact_model_name,
offload_embedding = offload_embedding,
-
+ float32_mixed_precision = float32_mixed_precision,
# Pass vLLM/inference parameters
fast_inference = fast_inference,
gpu_memory_utilization = gpu_memory_utilization,
@@ -449,7 +450,7 @@ class FastLanguageModel(FastLlamaModel):
fullgraph = True, # No graph breaks
use_exact_model_name = use_exact_model_name,
offload_embedding = offload_embedding,
-
+ float32_mixed_precision = float32_mixed_precision,
# Pass vLLM/inference parameters
fast_inference = fast_inference,
gpu_memory_utilization = gpu_memory_utilization,
@@ -594,7 +595,7 @@ class FastModel(FastBaseModel):
whisper_task = None,
unsloth_force_compile = False,
offload_embedding = False,
-
+ float32_mixed_precision = None, # Forces float32 mixed precision
# Add the missing vLLM/inference parameters
fast_inference = False, # uses vLLM
gpu_memory_utilization = 0.5,
@@ -1008,7 +1009,7 @@ class FastModel(FastBaseModel):
whisper_task = whisper_task,
auto_config = model_config,
offload_embedding = offload_embedding,
-
+ float32_mixed_precision = float32_mixed_precision,
# Pass vLLM/inference parameters
fast_inference = fast_inference,
gpu_memory_utilization = gpu_memory_utilization,
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index f6661eee6e3..dfcb9964fe8 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -316,6 +316,7 @@ class FastBaseModel:
whisper_task = None,
auto_config = None,
offload_embedding = False,
+ float32_mixed_precision = None, # Forces float32 mixed precision
# vLLM parameters
fast_inference = False,
gpu_memory_utilization = 0.5,
@@ -780,6 +781,7 @@ class FastBaseModel:
trust_remote_code = trust_remote_code,
model_type = model_type_arch,
tokenizer = tokenizer,
+ float32_mixed_precision = float32_mixed_precision,
)
# Clear deleted GPU items
for _ in range(3):
@@ -940,13 +942,17 @@ class FastBaseModel:
trust_remote_code = False,
model_type = None,
tokenizer = None,
+ float32_mixed_precision = None,
):
full_finetuning = os.environ.get("UNSLOTH_ENABLE_FULL_FINETUNING", "0") == "1"
- float32_mixed_precision = True
- if _get_dtype(dtype_from_config(model.config)) == torch.bfloat16 and full_finetuning:
- # Use bfloat16 precision for full finetuning
- float32_mixed_precision = False
+ if type(float32_mixed_precision) is bool:
+ # Respect whatever it was set before
+ else:
+ float32_mixed_precision = True
+ if _get_dtype(dtype_from_config(model.config)) == torch.bfloat16 and full_finetuning:
+ # Use bfloat16 precision for full finetuning
+ float32_mixed_precision = False
model = prepare_model_for_training(
model,