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
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot]967434c94848
diff --git a/unsloth/kernels/fp8.py b/unsloth/kernels/fp8.pyindex 7968c2c429d..435a6e83d25 100644--- a/unsloth/kernels/fp8.py+++ b/unsloth/kernels/fp8.py@@ -532,23 +532,26 @@ def test_has_fbgemm():block_scale = torch.ones(M // 128, K // 128, dtype = torch.float32, device = "cuda")has_fbgemm = Falsetry:- out = torch.ops.fbgemm.f8f8bf16_blockwise(- xq, wq, block_scale, block_scale- )+ out = torch.ops.fbgemm.f8f8bf16_blockwise(xq, wq, block_scale, block_scale)assert torch.unique(out).item() == 128has_fbgemm = Truedel outexcept Exception as e:e = str(e)if "cutlass cannot initialize" in e.lower():- print(f"Unsloth: FBGEMM on the current GPU cannot load - will switch to Triton kernels")+ print(+ f"Unsloth: FBGEMM on the current GPU cannot load - will switch to Triton kernels"+ )else:- print(f"Unsloth: FBGEMM on the current GPU cannot load with error = {e} - will switch to Triton kernels")+ print(+ f"Unsloth: FBGEMM on the current GPU cannot load with error = {e} - will switch to Triton kernels"+ )has_fbgemm = Falsedel block_scale, xqtorch.cuda.empty_cache()return has_fbgemm+fp8_block_quant_linear = fp8_torch_block_quant_forwardif "UNSLOTH_HAS_FBGEMM" not in os.environ:os.environ["UNSLOTH_HAS_FBGEMM"] = "0"diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex cbc5c51c5ee..951bcb1e0c9 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -223,7 +223,9 @@ class FastLanguageModel(FastLlamaModel):old_model_name = model_namefp8_mode = Noneif not use_exact_model_name:- new_model_name = get_model_name(model_name, load_in_4bit = load_in_4bit, load_in_fp8 = load_in_fp8)+ new_model_name = get_model_name(+ model_name, load_in_4bit = load_in_4bit, load_in_fp8 = load_in_fp8+ )if new_model_name is None and load_in_fp8 != False:fp8_mode = _get_fp8_mode_and_check_settings(load_in_fp8,@@ -378,7 +380,7 @@ class FastLanguageModel(FastLlamaModel):if model_name.lower().endswith("-bf16"):load_in_4bit = Falseload_in_8bit = False- load_in_fp8 = False+ load_in_fp8 = Falseload_in_16bit = Truemodel_config = AutoConfig.from_pretrained(@@ -730,7 +732,9 @@ class FastModel(FastBaseModel):old_model_name = model_namefp8_mode = Noneif not use_exact_model_name:- new_model_name = get_model_name(model_name, load_in_4bit = load_in_4bit, load_in_fp8 = load_in_fp8)+ new_model_name = get_model_name(+ model_name, load_in_4bit = load_in_4bit, load_in_fp8 = load_in_fp8+ )if new_model_name is None and load_in_fp8 != False:fp8_mode = _get_fp8_mode_and_check_settings(load_in_fp8,@@ -757,7 +761,7 @@ class FastModel(FastBaseModel):if model_name.lower().endswith("-bf16"):load_in_4bit = Falseload_in_8bit = False- load_in_fp8 = False+ load_in_fp8 = Falseload_in_16bit = True# Check modelscope@@ -1018,7 +1022,7 @@ class FastModel(FastBaseModel):if model_name.lower().endswith("-bf16"):load_in_4bit = Falseload_in_8bit = False- load_in_fp8 = False+ load_in_fp8 = Falseload_in_16bit = Truemodel_config = AutoConfig.from_pretrained(diff --git a/unsloth/models/loader_utils.py b/unsloth/models/loader_utils.pyindex 0898b81cf42..7bcddde2d97 100644--- a/unsloth/models/loader_utils.py+++ b/unsloth/models/loader_utils.py@@ -242,6 +242,7 @@ def _offline_quantize_to_fp8(model_name: str, fp8_mode: str) -> str:TorchAoConfig,AutoConfig,)+qconfig = _get_torchao_fp8_config(fp8_mode)qconfig = TorchAoConfig(qconfig)config = AutoConfig.from_pretrained(model_name)@@ -334,11 +335,15 @@ def _get_fp8_mode_and_check_settings(and torch.version.cudaand torch.cuda.get_device_capability() >= (9, 0)):- raise ValueError("Unsloth: On the fly `load_in_fp8` requires H100 GPUs or after. Try `unsloth/Qwen3-8B` instead.")+ raise ValueError(+ "Unsloth: On the fly `load_in_fp8` requires H100 GPUs or after. Try `unsloth/Qwen3-8B` instead."+ )# Check if torch >= 2.9.0if Version(torch.__version__) < Version("2.9.0"):- raise ValueError("Unsloth: On the fly `load_in_fp8` requires torch 2.9.0+. Try `unsloth/Qwen3-8B` instead.")+ raise ValueError(+ "Unsloth: On the fly `load_in_fp8` requires torch 2.9.0+. Try `unsloth/Qwen3-8B` instead."+ )# Check if torchao has this PR: https://github.com/pytorch/ao/pull/3158,# which will be released in 0.15.0.diff --git a/unsloth/models/mapper.py b/unsloth/models/mapper.pyindex 522324524ce..dcfe890e92e 100644--- a/unsloth/models/mapper.py+++ b/unsloth/models/mapper.py@@ -1281,7 +1281,6 @@ for key, values in __INT_TO_FLOAT_MAPPER.items():for k in float8_values:FLOAT_TO_FP8_BLOCK_MAPPER[k.lower()] = blockFLOAT_TO_FP8_ROW_MAPPER[k.lower()] = row- passvalues = float16_valuesINT_TO_FLOAT_MAPPER[key] = values[0]