Skip to content

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.

Update _utils.py

Daniel Hanaffa585b3fa8
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index b021e89e9d5..5a2e85997fc 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -393,7 +393,10 @@ def patch_tokenizer(model, tokenizer):
tokenizer.pad_token = possible_pad_token
if model is not None:
config = model.config.update({"pad_token_id" : tokenizer.pad_token_id})
- pass
+ else:
+ if model is not None:
+ if model.config.pad_token_id is None:
+ config = model.config.update({"pad_token_id" : tokenizer.pad_token_id})
return model, tokenizer
pass