From e6bb5b83b9de42b9678a1ffc04598bc0f93ef000 Mon Sep 17 00:00:00 2001 From: Sekinal Date: Mon, 28 Jul 2025 22:47:58 -0600 Subject: [PATCH 1/2] Fix: Added specific check for Gemma so models like BERT properly initialize --- unsloth/models/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 4f004ff93a..9c899e96e9 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -221,7 +221,7 @@ class _RaiseUninitialized(logging.Handler): def __init__(self): super().__init__() def emit(self, record): - if "some weights of" in str(record).lower(): + if "some weights of" in str(record).lower() and "gemma" in str(record).lower(): raise Exception( f"Unsloth: Critical error since some weights are not initialized.\n"\ f"Please try updating Unsloth, transformers and timm via:\n"\ From 76ceebd9c221e8df656436afee9a0ef74d342fd8 Mon Sep 17 00:00:00 2001 From: Sekinal Date: Mon, 28 Jul 2025 23:16:05 -0600 Subject: [PATCH 2/2] Fixed wrong syntax in f-string for exception --- unsloth/models/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 9c899e96e9..c7602ed193 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -226,7 +226,7 @@ class _RaiseUninitialized(logging.Handler): f"Unsloth: Critical error since some weights are not initialized.\n"\ f"Please try updating Unsloth, transformers and timm via:\n"\ f"`pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo transformers timm`\n"\ - f"".str(record)) + f"{record}") pass class RaiseUninitialized: def __init__(self):