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 save.py

Daniel Han7d82555dc8e4
diff --git a/unsloth/save.py b/unsloth/save.py
index f5ea8d7d8f3..5fa2df7b185 100644
--- a/unsloth/save.py
+++ b/unsloth/save.py
@@ -2745,6 +2745,17 @@ def _unsloth_save_torchao_with_attached_config(
"""Save a QAT-trained model by converting fake-quantized weights to real quantized weights."""
# Convert QAT fake-quantized weights to real quantized weights
_convert_torchao_model(model)
+ # PEFT models also might come here, so parse it
+ if isinstance(model, PeftModelForCausalLM):
+ _unsloth_save_torchao_with_given_config(
+ model = model,
+ save_directory = save_directory,
+ tokenizer = tokenizer,
+ torchao_config = model.config.quantization_config,
+ push_to_hub = push_to_hub,
+ token = token,
+ )
+ return
# TorchAO does not support safe_serialization reliably
safe_serialization = False
@@ -2897,7 +2908,7 @@ def unsloth_save_pretrained_torchao(
)
if torchao_config is not None:
- # PTQ path: user provided a config, model must NOT have QAT config
+ # PTQ path: user provided a config, model must NOT have QAT config unless PEFT
assert not has_qat_config, (
"Unsloth: You passed `torchao_config` but this model was trained with `qat_scheme`. "
"For QAT models, do not pass `torchao_config` - the quantization config is already "