Repository navigation
Closed
Labels
Description
I refer the sample https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen3_5_(4B)_Vision.ipynb#scrollTo=zoNA7J-RP3l1 to finetune Qwen3.5-0.8B ,but cannot use vllm to infer ,how to resolve it
and vllm can infer the Qwen3.5-0.8B pretrained model, cannot infer the finetune model.
finetune script
from datasets import load_dataset
## load data
dataset = load_dataset('json', data_files='exception-error_bak_add_normal_unsloth.jsonl', split='train')
def convert_to_conversation(sample):
mes_list = sample['messages']
for mes_ in mes_list:
# if mes_['role'] == "user":
content = mes_['content']
for content_v in content:
if content_v['type'] == "text":
del content_v['image']
if content_v['type'] == "image":
del content_v['text']
return sample
converted_dataset = [convert_to_conversation(sample) for sample in dataset]
## load model
from unsloth import FastVisionModel # FastLanguageModel for LLMs
import torch
model, tokenizer = FastVisionModel.from_pretrained(
"../Qwen3.5-0.8B",
full_finetuning=True,
load_in_4bit=False, # Use 4bit to reduce memory use. False for 16bit LoRA.
use_gradient_checkpointing="unsloth", # True or "unsloth" for long context
)
model = FastVisionModel.get_peft_model(
model,
finetune_vision_layers=True, # False if not finetuning vision layers
finetune_language_layers=True, # False if not finetuning language layers
finetune_attention_modules=True, # False if not finetuning attention layers
finetune_mlp_modules=True, # False if not finetuning MLP layers
r=16, # The larger, the higher the accuracy, but might overfit
lora_alpha=16, # Recommended alpha == r at least
lora_dropout=0,
bias="none",
random_state=3407,
use_rslora=False, # We support rank stabilized LoRA
loftq_config=None, # And LoftQ
# target_modules = "all-linear", # Optional now! Can specify a list if needed
)
## unsloth finetune
from unsloth.trainer import UnslothVisionDataCollator
from trl import SFTTrainer, SFTConfig
FastVisionModel.for_training(model) # Enable for training!
trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
data_collator=UnslothVisionDataCollator(model, tokenizer), # Must use!
train_dataset=converted_dataset,
args=SFTConfig(
per_device_train_batch_size=2,
gradient_accumulation_steps=4,
warmup_steps=5,
max_steps=30,
# num_train_epochs = 1, # Set this instead of max_steps for full training runs
learning_rate=2e-4,
logging_steps=1,
optim="adamw_8bit",
weight_decay=0.001,
lr_scheduler_type="linear",
seed=3407,
output_dir="outputs",
report_to="none", # For Weights and Biases
# You MUST put the below items for vision finetuning:
remove_unused_columns=False,
dataset_text_field="",
dataset_kwargs={"skip_prepare_dataset": True},
max_length=2048,
),
)
trainer_stats = trainer.train()
# save model
FastVisionModel.for_inference(model)
model.save_pretrained_merged("unsloth_finetune", tokenizer,save_method="merged_16bit")vllm serve
vllm serve unsloth_finetune \
--trust-remote-code \
-tp 2 \
--max-num-batched-tokens 4096 \
--max-model-len 16384 \
--enable-prefix-caching \
--enable-chunked-prefill \
--gpu-memory-utilization 0.75 \
--compilation-config '{\"cudagraph_mode\": \"FULL_DECODE_ONLY\", \"level\": 0}' \
2>&1 | tee ${LOG_PATH}and the save files appear the Tokenizer error : "ValueError: Tokenizer class TokenizersBackend does not exist or is not currently imported." , so I copy the file tokenizer.json,tokenizer_config.json form the pretrained model file to the finetune model .
but it appear new error look likes file error
and the folder has the safetensors file.
Activity
fix(save): detect Qwen3.5 VLMs through PEFT wrappers
hexianbin1994 commentedon Aug 4, 2026
Now I upgrade unsloth version to 2026.8.1, and I found that vllm can serve with less parameters finetune , but cannot serve with the full_finetuning when i set full_finetuning=True in FastVisionModel.from_pretrained(), the error is same as #5845, ** not found in params_dict, skip loading.
danielhanchen commentedon Aug 28, 2026
The Qwen3.5 save remap only rewrites the old Qwen2-VL prefixes, so it changes nothing for a Qwen3.5 checkpoint that already uses the new names, and the
mtp.*tensors andtokenizer_classare still unhandled.