From 4fff3a484f77650c2eb437dda937a543df79e3c9 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 17 Mar 2025 19:42:49 -0700 Subject: [PATCH] move float32 --- unsloth/models/_utils.py | 5 ----- unsloth/models/loader.py | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index cdd5f97b98..a150b1004c 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -121,11 +121,6 @@ from unsloth_zoo.temporary_patches import ( for temporary_patch in TEMPORARY_PATCHES: temporary_patch() -global FORCE_FLOAT32 -FORCE_FLOAT32 = [ - "gemma3", -] - # ============================================= # Disable some warnings which can get annoying warnings.filterwarnings(action = "ignore", category = UserWarning, module = "torch") diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py index 4d2fc1a300..1861a7107d 100644 --- a/unsloth/models/loader.py +++ b/unsloth/models/loader.py @@ -67,6 +67,11 @@ from ._utils import ( unsloth_compile_transformers, ) +global FORCE_FLOAT32 +FORCE_FLOAT32 = [ + "gemma3", +] + class FastLanguageModel(FastLlamaModel): @staticmethod def from_pretrained( @@ -630,6 +635,7 @@ class FastModel(FastBaseModel): os.environ["UNSLOTH_FORCE_FLOAT32"] = "0" do_forced_float32 = False model_type_arch = model_types[1] + global FORCE_FLOAT32 for disable_name in FORCE_FLOAT32: if (disable_name.lower() == model_type_arch.lower() or \ disable_name.lower() in model_name.lower()) and \