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
Update loader.py
Daniel Han52e3a2bf9af0
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 8dcdebab120..cafb1282f7b 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -44,24 +44,23 @@ if SUPPORTS_GEMMA2:from .gemma2 import FastGemma2Modelpass-def get_dtype_from_input(- dtype-):- '''Converts user-defined dtype input string to a usable dtype'''- TORCH_FLOAT16_SYNONYMS = {"torch.float16"}- TORCH_BFLOAT16_SYNONYMS = {"torch.bfloat16"}- TORCH_FLOAT32_SYNONYMS = {"torch.float32"}- if dtype in TORCH_FLOAT16_SYNONYMS:++def _get_dtype(dtype):+ __DTYPE_MAP = {+ "float32": torch.float32,+ torch.float32: torch.float32,+ "float16": torch.float16,+ torch.float16: torch.float16,+ "bfloat16": torch.bfloat16,+ torch.bfloat16: torch.bfloat16,+ }+ if dtype in __DTYPE_MAP:+ return __DTYPE_MAP[dtype]+ else:+ print(f"Unsloth: {dtype} is not recognized, so we'll default to torch.float16")return torch.float16- if dtype in TORCH_BFLOAT16_SYNONYMS:- return torch.bfloat16- if dtype in TORCH_FLOAT32_SYNONYMS:- return torch.float32- if dtype != "None":- print(f"--------------------------------------------------\n"\- f"User-specified dtype not recognised. Defaulting to dtype = None\n"\- f"--------------------------------------------------")- return None+ pass+passdef __get_model_name(@@ -351,7 +350,7 @@ class FastLanguageModel(FastLlamaModel):model, tokenizer = dispatch_model.from_pretrained(model_name = model_name,max_seq_length = max_seq_length,- dtype = get_dtype_from_input(dtype),+ dtype = _get_dtype(dtype),load_in_4bit = load_in_4bit,token = token,device_map = device_map,