You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] Merging 4-bit Checkpoint into Phi-4 Base Model – Model Inference Inconsistent #2510
Hi everyone, I followed the Unsloth documentation (https://docs.unsloth.ai/basics/running-and-saving-models/saving-to-vllm) to merge a 4-bit checkpoint (checkpoint-105) into the Phi-4 base model. The process appeared to complete successfully, but when running inference, the model produces outputs that are significantly different from the expected results based on the fine-tuning dataset (4,000 Q&A pairs from 1,000 Thai words with 4 prompt variations each). I'm unsure whether the checkpoint merge into 4-bit format was done correctly or if something went wrong during saving/loading.
Sorry on the delay! The outputs match the base model because of the loading steps, not the merge itself:
Step 6 loads "unsloth/Phi-4" again, which is the original base model, so none of your fine-tuning is used. Point model_name at your saved folder instead.
save_method = "lora" only saves the LoRA adapter, it does not merge anything. Use save_method = "merged_16bit" for a merged model (for vLLM), or "merged_4bit_forced" if you really need 4-bit weights.
load_adapter(..., adapter_name = "Checkpoint-105") after get_peft_model adds the checkpoint as a second adapter, but the active one stays the new, untrained default adapter. You would need Phi4_model.set_adapter("Checkpoint-105").
The simplest way is to load the checkpoint folder directly, since Unsloth reads the base model from the adapter config:
fromunslothimportFastLanguageModelmodel, tokenizer=FastLanguageModel.from_pretrained(
model_name="D:/LLMs/FineTune_Phi_4_Checkpoints_4kRecords/checkpoint-105",
max_seq_length=2048,
load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
# Optional: merge for vLLM, then load this folder (not "unsloth/Phi-4")model.save_pretrained_merged("D:/LLMs/Phi4_merged_16bit", tokenizer, save_method="merged_16bit")
Also make sure you prompt with the same chat template and system prompt you trained with. I checked all three points on the latest Unsloth with a small Phi model: your steps give outputs identical to the base model, while loading the checkpoint folder directly (or calling set_adapter) reproduces the trained adapter's outputs exactly.
I'll close this for now, but feel free to reopen if you still see a mismatch after loading the checkpoint this way.
Activity
github-actions commentedon Jul 1, 2025
Is this issue still important to you? Apologies in advance we might have missed this issue as well. For faster response times, please post on our Reddit server - https://www.reddit.com/r/unsloth or our Discord - https://discord.com/invite/unsloth
danielhanchen commentedon Oct 8, 2026
Sorry on the delay! The outputs match the base model because of the loading steps, not the merge itself:
"unsloth/Phi-4"again, which is the original base model, so none of your fine-tuning is used. Pointmodel_nameat your saved folder instead.save_method = "lora"only saves the LoRA adapter, it does not merge anything. Usesave_method = "merged_16bit"for a merged model (for vLLM), or"merged_4bit_forced"if you really need 4-bit weights.load_adapter(..., adapter_name = "Checkpoint-105")afterget_peft_modeladds the checkpoint as a second adapter, but the active one stays the new, untraineddefaultadapter. You would needPhi4_model.set_adapter("Checkpoint-105").The simplest way is to load the checkpoint folder directly, since Unsloth reads the base model from the adapter config:
Also make sure you prompt with the same chat template and system prompt you trained with. I checked all three points on the latest Unsloth with a small Phi model: your steps give outputs identical to the base model, while loading the checkpoint folder directly (or calling
set_adapter) reproduces the trained adapter's outputs exactly.I'll close this for now, but feel free to reopen if you still see a mismatch after loading the checkpoint this way.
DeepSeek-V4.1 tests: capability-gated on the companion unsloth_zoo, C…
Native DeepSeek-V4.1: modeling ported from the deepseek-ai reference,…