swift 推理SFT后的Qwen3.5-9B 卡顿
Checklist / 检查清单
- [x] I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述
使用swift infer使用CPT+SFT后的Qwen3.5-9B推理,输出一个
环境:swift 4.0.2, transformers 5.2.0
How to Reproduce / 如何复现
swift 4.0.2, transformers 5.2.0 SFT数据为领域问题和通用指令的混合
Additional Information / 补充信息
No response
Looking into this — inference stuttering after SFT suggests a tensor or memory handling issue. I'll investigate the inference pipeline. Happy to submit a fix.
Please provide more information, such as the shell scripts for training and inference.
我使用ms-swift训练了Qwen3.5-4B-Base模型后,使用Vlmevalkit框架 (使用vllm部署这个模型)然后输出测评 速度相差了20倍 (只是模型输出分布变化应当没有这么剧烈)
怀疑是save_safetensor方面有点问题或者是两个架构转化存在问题,导致了vllm推理架构的异常 ?
训练脚本:
add_non_thinking_prefix=false
NNODES=${NNODES}
NODE_RANK=${NODE_RANK}
MASTER_ADDR=${MASTER_ADDR}
MASTER_PORT=${MASTER_PORT}
NPROC_PER_NODE=${GPUS_PER_NODE}
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
SKIP_MULTIMODAL_MTP_VALIDATION=1
SWIFT_USE_MCORE_GDN=1
megatron sft
--model ${RETRAIN_CHECKPOINT_PATH}
--tuner_type full
--dataset ${dataset_dir}
--load_from_cache_file ${LOAD_FROM_CACHE_FILE}
--split_dataset_ratio 0.0
--num_train_epochs ${max_epochs}
--lr ${lr}
--lr_warmup_fraction 0.1
--min_lr ${min_lr}
--add_non_thinking_prefix ${add_non_thinking_prefix}
--max_length ${max_length}
--dataloader_num_workers ${num_workers}
--dataset_num_proc ${dataset_num_proc}
--eval_steps 1000000
--save_steps ${save_interval}
--tensor_model_parallel_size ${tensor_model_parallel_size}
--pipeline_model_parallel_size ${pipeline_model_parallel_size}
--context_parallel_size ${context_parallel_size}
--expert_tensor_parallel_size ${expert_tensor_parallel_size}
--expert_model_parallel_size ${expert_model_parallel_size}
--freeze_llm false
--freeze_vit false
--freeze_aligner false
--padding_free ${padding_free}
--packing ${packing}
--sequence_parallel true
--vit_gradient_checkpointing true
--micro_batch_size ${micro_batch_size}
--global_batch_size ${global_batch_size}
${RECOMPUTE_ARGS}
--finetune ${FINETUNE_FLAG}
--cross_entropy_loss_fusion true
--output_dir "${CHECKPOINT_DIR}"
--tensorboard_dir "${TENSORBOARD_DIR}"
--no_save_optim false
--no_save_rng false
--attention_backend flash
--logging_steps 20
--async_save true
--use_persistent_ckpt_worker true
--overlap_grad_reduce true
--check_model false
测试部署内部脚本:
self.llm = LLM(
model=self.model_path,
max_num_seqs=8,
limit_mm_per_prompt=limit_mm,
tensor_parallel_size=tp_size,
enable_expert_parallel=enable_expert_parallel,
seed=0, # 按实际需求设置
gpu_memory_utilization=kwargs.get("gpu_utils", 0.9),
trust_remote_code=True,
)
sampling_params = SamplingParams(
temperature=self.temperature,
max_tokens=self.max_new_tokens,
top_p=self.top_p,
top_k=self.top_k,
repetition_penalty=self.repetition_penalty,
presence_penalty=self.presence_penalty,
stop_token_ids=None
)
"Qwen3.5-4B": partial(
Qwen3VLChat,
model_path=f"{os.environ.get('')}/{os.environ.get('')}",
use_custom_prompt=False,
use_vllm=True,
temperature=1.0,
top_p=0.95,
top_k=20,
presence_penalty=1.5,
repetition_penalty=1.0,
max_new_tokens=8192
),
This issue has been inactive for over 3 months and will be automatically closed in 7 days. If this issue is still relevant, please reply to this message.
This issue has been automatically closed due to inactivity. If needed, it can be reopened.