Merge branch 'pr/3052'

This commit is contained in:
Daniel Han 2025-07-29 00:38:50 -07:00
commit 5ceb280a42
3 changed files with 6 additions and 4 deletions

View file

@ -221,11 +221,13 @@ class _RaiseUninitialized(logging.Handler):
def __init__(self):
super().__init__()
def emit(self, record):
if "some weights of" in str(record).lower():
record_lower = str(record).lower()
if "some weights of" in record_lower and "score.weight" not in 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"\
f"`pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo transformers timm`\n"
f"`pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo transformers timm`\n"\
f"{str(record)}"
)
pass
class RaiseUninitialized:

View file

@ -858,7 +858,7 @@ class FastModel(FastBaseModel):
trust_remote_code = trust_remote_code,
)
# Patch it as well!
model = FastBaseModel.post_patch_model(model, use_gradient_checkpointing)
model = FastBaseModel.post_patch_model(model, use_gradient_checkpointing, trust_remote_code = trust_remote_code)
pass
return model, tokenizer
pass

View file

@ -608,7 +608,7 @@ class FastBaseModel:
finetune_mlp_modules = finetune_mlp_modules,
)
else:
assert(type(target_modules) in (list, tuple,))
assert(type(target_modules) in (list, tuple, str,))
pass
# Clear deleted GPU items