Ascend-SACT/Qwen3.8-27B-Lora
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Qwen3.8-27B基于MindSpeed-MM框架LoRA微调

0. 模型介绍

Qwen3.8-27B 建立在 Qwen3.5 架构之上,与 Qwen3.5-27B Dense 同构,面向编码、专业工作、科研与长程 Agent 场景;为原生视觉-语言模型,支持图像与视频理解,并提供可开关的思考模式与可调的思考深度。

模型概览:

  • 类型:带视觉编码器的因果语言模型

  • 训练阶段:预训练与后训练

  • 语言模型

    • 参数量:27B
    • 隐藏层维度:5120
    • Token 嵌入维度:248320(已填充)
    • 层数:64
    • 隐藏层结构:16 × (3 × (门控 DeltaNet → FFN) → 1 × (门控注意力 → FFN))
    • 门控 DeltaNet:
      • 线性注意力头数量:V 为 48,QK 为 16
      • 头维度:128
    • 门控注意力:
      • 注意力头数量:Q 为 24,KV 为 4
      • 头维度:256
      • 旋转位置嵌入维度:64
    • 前馈网络(FFN):
      • 中间层维度:17408
    • 语言模型输出维度:248320(已填充)
    • MTP:采用多步训练
  • 上下文长度:原生支持 262,144 tokens,可扩展至最多 1,010,000 tokens。

  • Qwen3.8 对话控制(官方 chat_template 运行时参数,训练拼样本与推理拼输入共用):

    • enable_thinking:本轮是否走思考通道,默认开启
    • preserve_thinking:多轮是否保留历史思考,默认开启
    • reasoning_effort:xhigh / medium / low,默认 xhigh(向 system 注入对应思考强度说明;medium 通常不注入)
    • 当前文档 MindSpeed-MM SFT 已验证 enable_thinking 参与训练拼样本;暂未验证 reasoning_effort 和 preserve_thinking。

1. 环境搭建

Qwen3.8-27B LoRA SFT 可用 8 卡(单机)。配套版本如下表格:

配套版本
硬件910B2、910B4
架构arm
CANN8.5.2
torch2.7.1
torch_npu2.7.1.post6
flash-linear-attention-npu26.6.0
triton-ascend3.2.0
transformers5.8.0
mindspeed-mmv26.1.0

1.1 训练镜像制作

拉取基础镜像cann:8.5.2-910b-openeuler24.03-py3.11,并且基于基础镜像启动容器

docker pull quay.io/ascend/cann:8.5.2-910b-openeuler24.03-py3.11

docker run -itd \
  --name mindspeed-mm-install \
  --privileged \
  --network=host --ipc=host --shm-size=128g \
  --device=/dev/davinci0 --device=/dev/davinci1 \
  --device=/dev/davinci2 --device=/dev/davinci3 \
  --device=/dev/davinci4 --device=/dev/davinci5 \
  --device=/dev/davinci6 --device=/dev/davinci7 \
  --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver:ro \
  -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware:ro \
  -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi:ro \
  -v /etc/ascend_install.info:/etc/ascend_install.info:ro \
  quay.io/ascend/cann:8.5.2-910b-openeuler24.03-py3.11 \
  bash

启动容器,拉取MindSpeed-MM代码,切换到v26.1.0版本:

docker exec -it mindspeed-mm-install bash
git clone https://gitcode.com/Ascend/MindSpeed-MM.git
cd MindSpeed-MM
git checkout v26.1.0

执行如下指令一键安装MindSpeed-MM所需依赖:

bash scripts/install.sh --msid eb10b92 && bash examples/qwen3_5/install_extensions.sh

安装 fla-npu。执行如下命令下载 flash_linear_attention_npu 的 v26.6.0 版本:

wget https://github.com/flashserve/flash-linear-attention-npu/releases/download/v26.6.0/flash_linear_attention_npu-26.6.0-910b.aarch64-py3-none-any.whl

执行如下命令安装flash_linear_attention_npu:

python -m pip install --force-reinstall --no-deps flash_linear_attention_npu-26.6.0-910b.aarch64-py3-none-any.whl

升级torch-npu到2.7.1.post6版本:

pip install torch-npu==2.7.1.post6

LoRA 与文本 parquet 转换依赖:

pip install peft pyarrow

1.2 使用已有镜像

也可以使用已上传镜像 mindspeed-mm_qwen3_5_sft.tar,镜像下载后,使用如下命令加载镜像:

docker load -i mindspeed-mm_qwen3_5_sft.tar

启动训练容器命令:

export IMAGE_NAME=mindspeed-mm:qwen3.5-sft
docker run -itd \
  --name mindspeed-mm-qwen3-8 \
  --privileged \
  --network=host --ipc=host --shm-size=128g \
  --device=/dev/davinci0 --device=/dev/davinci1 \
  --device=/dev/davinci2 --device=/dev/davinci3 \
  --device=/dev/davinci4 --device=/dev/davinci5 \
  --device=/dev/davinci6 --device=/dev/davinci7 \
  --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver:ro \
  -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware:ro \
  -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi:ro \
  -v /etc/ascend_install.info:/etc/ascend_install.info:ro \
  -v /var/log/npu:/var/log/npu \
  ${IMAGE_NAME} \
  /bin/bash

注意: Qwen3.8-27B 与 Qwen3.5-27B Dense 同构,以上镜像已测试可以训练Qwen3.8 27B。

2. 模型权重转换

2.1 下载模型

git clone https://www.modelscope.cn/Qwen/Qwen3.8-27B.git # 从modelscope下载
git clone https://huggingface.co/Qwen/Qwen3.8-27B # 从huggingface下载

2.2 权重转换

mm-convert Qwen35Converter hf_to_dcp \
--hf_dir /models/Qwen/Qwen3.8-27B \
--dcp_dir /workspace/host/Qwen3.8-27B_dcp \
--num_workers 4

转换器名称为 Qwen35Converter(Qwen3.8 27B 与Qwen3.5 27B同构,model_id 为qwen3_5)。

3. 训练数据准备

训练数据只接受 json / jsonl。纯文本与图文的字段约定见 3.1,转换步骤见 3.2、3.3。

3.1 目标数据格式

纯文本 · 思考

{
  "messages": [
    {"role": "user", "content": "..."},
    {"role": "assistant", "content": "最终回答", "reasoning_content": "思考过程"}
  ],
  "tools": []
}

qwen3.8 约定:思考写在 reasoning_content,最终回答写在 content;不要在 content 里再手写 <think>...</think>。有工具轨迹时保留 tools / tool_calls;没有则 tools 为空列表。

多模态(图文)

{
  "messages": [
    {"role": "user", "content": "<image>\nWhat types of food can be seen in the image?"},
    {"role": "assistant", "content": "..."}
  ],
  "images": ["./train2017/000000000009.jpg"]
}

<image> 个数必须与 images 条数一致。

3.2 纯文本数据准备(以 openai_messages 为例)

数据说明

本文微调使用 r0b0tlab/qwen3.8-max-glm5.2-distillation-51389 的 openai_messages 视图。该视图共 51,389 条(train 46,250 / validation 2,569 / test 2,570),思考在 reasoning_content,终答在 content,有工具时带 tools / tool_calls,符合 Qwen3.8 字段约定。约 84% 含思考过程;约 10% 为工具轨迹(多为单问 + 多轮 assistant/tool),其余以单轮对话为主。数据集内还有其它视图,本文验证只用 openai_messages。

下载数据集

git clone https://huggingface.co/datasets/r0b0tlab/qwen3.8-max-glm5.2-distillation-51389 /workspace/host/dataset_src

转为 jsonl格式

MindSpeed-MM 不提供该视图的转换,使用本仓库 convert_qwen38_csv_to_jsonl.py:

python /workspace/host/Qwen3.8-27B-SFT/script/convert_qwen38_csv_to_jsonl.py \
  --input /workspace/host/dataset_src/data/openai_messages \
  --output /workspace/host/dataset_think/openai_messages_think.jsonl \
  --split train

--input 指向 openai_messages 子集,不要传数据集根目录。

3.3 多模态-图文数据准备(以 COCO2017 + LLaVA-Instruct-150K 为例)

下载 COCO 图片

下载 COCO2017 训练集并解压,使目录中存在 train2017/。说明页:COCO download。

mkdir -p /workspace/host/dataset_vl
cd /workspace/host/dataset_vl
wget -c http://images.cocodataset.org/zips/train2017.zip
unzip train2017.zip

下载 LLaVA 标注

wget -c /workspace/host/dataset_vl/llava_instruct_150k.json \
  https://huggingface.co/datasets/liuhaotian/LLaVA-Instruct-150K/resolve/main/llava_instruct_150k.json

LLaVA 标注转为训练 JSON

LLaVA 源格式(image + conversations),不能直接作为训练数据。使用 MindSpeed-MM 已有脚本,把 LLaVA 源格式转成训练读取的 JSON 数组:

python /workspace/MindSpeed-MM/mindspeed_mm/fsdp/tools/data_tool/llava_instruct_2_mllm_demo_format.py \
  --coco_path /workspace/host/dataset_vl/train2017 \
  --llava_json_path /workspace/host/dataset_vl/llava_instruct_150k.json \
  --output_json_path /workspace/host/dataset_vl/mllm_format_llava_instruct_data.json

mock数据集验证

多模态数据集比较大,下载耗时,可mock数据集快速验证流程,注意不要用于精度结论。使用 MindSpeed-MM 已有脚本:

python /workspace/MindSpeed-MM/mindspeed_mm/fsdp/tools/data_tool/generate_mock_data_for_vlmodel.py \
  --tokenizer_path /models/Qwen/Qwen3.8-27B \
  --pic_width 1024 \
  --pic_height 1024 \
  --num_pics 1 \
  --text_length 16384 \
  --num_samples 512 \
  --save_dir /workspace/host/dataset_vl_fake

将 --save_dir 下生成的 mock_data_pic_num_*_textlen_*.json 作为图文训练数据。建议文本尽量长一些,避免截断图片占位符。

4. Qwen3.8-27B 训练配置文件

4.1 配置文件

以下是主要配置信息。本仓库给出了几组配置样例,完整文件在 script/:多模态 LoRA 见 qwen3_8_27B_A_lora_nothink_mm.yaml;纯文本 LoRA 见 qwen3_8_27B_B_lora_think_text.yaml。

使用前请把 model_name_or_path、dataset_dir、dataset、load、save、cache_dir 改成现场路径。

4.2 关键参数配置

参数参数解释
ulysses_parallel_size长序列训练的序列并行大小,用于将长序列切分到多卡并行计算以降低显存压力,序列不长时设为 1 表示不开启
cutoff_len训练时输入序列的最大长度
shuffle是否在数据加载时打乱样本顺序
micro_batch_size单张 NPU 上每次计算的样本数
gradient_accumulation_steps梯度累计步数,GBS=micro_batch_size * gradient_accumulation_steps * DP
train_iters总训练迭代次数。也可改成 train_epochs(一个epoch遍历一次全量数据)
save_interval模型保存间隔,即每训练多少 iteration 保存一次 checkpoint
skip_gdn_recompute是否跳过 GDN 相关算子的重计算
skip_flash_attn_recompute是否跳过 Flash Attention 的重计算
template / enable_thinking必须与数据一致。思考数据用 qwen3_6 + true;非思考用 qwen3_vl_nothink + false
model_idqwen3_5
init_model_with_meta_device保持 true
images图文设为 images;纯文本设为 null
observation_tag对话里工具回执的角色名。图文非思考(5.3)用 observation;文本思考(5.4,数据含 tool_calls)用 tool
freeze纯文本默认冻 model.visual;图文微调不要冻视觉塔
cache_dir预处理缓存
load / saveload 为 2.2 转换得到的 DCP 目录(release 的上一级);save 为 checkpoint 输出

以下为 Lora 相关配置项,本仓库 LoRA 验证为 单机 8 卡。

training:
  lora:
    enable: true
    rank: 8
    alpha: 16
    target_modules:
      - "model.language_model.layers.{*}.self_attn.q_proj"
      - "model.language_model.layers.{*}.self_attn.k_proj"
      - "model.language_model.layers.{*}.self_attn.v_proj"
      - "model.language_model.layers.{*}.self_attn.o_proj"
      - "model.language_model.layers.{*}.mlp.gate_proj"
      - "model.language_model.layers.{*}.mlp.up_proj"
      - "model.language_model.layers.{*}.mlp.down_proj"
    dropout: 0.0
    pretrained_lora_path: null
参数含义
enable是否开启 LoRA。开启后基座冻结,只训适配器
rank低秩维度。越小越省显存,表达能力越弱。本仓库验证值为 8
alpha缩放系数,实际缩放为 alpha/rank。本仓库验证值为 16(即 2.0)
target_modules注入位置。本仓库打在语言模型 Attention 与 MLP 线性层,不打视觉塔
dropoutLoRA dropout,验证值为 0
pretrained_lora_path续训已有 LoRA 时填写;新建训练保持 null
init_lora_weights初始化方式。Qwen3.5-4B 示例可写 "kaiming";本仓库 LoRA yaml 未写该字段,使用框架默认

4.3 配置比对

本仓库验证了两种微调配置,yaml配置差异如下:

配置卡数micro_batch_sizelora.enablefreeze visualtemplateenable_thinkingformatting数据
单机 LoRA 图文非思考81true否qwen3_vl_nothinkfalsesharegptCOCO + LLaVA,见 3.3
单机 LoRA 文本思考81true是qwen3_6trueopenaiopenai_messages 保留思考,见 3.2

现场还可改 cutoff_len、train_iters(或 train_epochs)、lr、dataset 路径等,含义见 4.2。

5. 训练拉起

5.1 训练脚本配置

单机 LoRA 微调使用 finetune_qwen3_8_27B_A_lora_nothink_mm.sh 执行多模态任务, 或 finetune_qwen3_8_27B_B_lora_think_text.sh 执行纯文本任务, NNODES=1、NODE_RANK=0。

5.2 关键参数配置

参数参数解释
MASTER_ADDR分布式训练中主节点的IP地址
MASTER_PORT分布式训练中主节点的通信端口
NODE_RANK当前节点在整个分布式训练中的编号(从0开始)
NPUS_PER_NODE每个节点上使用的NPU数量
NNODES分布式训练中使用的节点总数

请先 cd 到本仓库 script 目录,保证 ./$YAML 能找到同目录配置。

5.3 单机 LoRA 图文多模态执行

数据按 3.3 准备。配置如 qwen3_8_27B_A_lora_nothink_mm.yaml:lora.enable: true,不冻 visual,images: images,micro_batch_size: 1,train_iters: 260,save_interval: 65。

bash finetune_qwen3_8_27B_A_lora_nothink_mm.sh

日志:train-A-lora-nothink-mm.log。

单机 LoRA 图文训练 loss

5.4 单机 LoRA 纯文本执行

数据按 3.2 准备。配置如 qwen3_8_27B_B_lora_think_text.yaml:(冻 visual、template: qwen3_6、enable_thinking: true、formatting: openai、micro_batch_size: 1、train_epochs: 3)。

bash finetune_qwen3_8_27B_B_lora_think_text.sh

日志:train-B-lora-think-text.log。

单机 LoRA 文本思考训练 loss(3 epoch)

3.2 的 openai_messages 为 Qwen3.8 教师模型生成的蒸馏监督数据。学生与教师同属 Qwen3.8 / Qwen3.5 同构系列,监督目标已接近基座模型的条件分布,因此训练起步时 token 级负对数似然(loss)即处于较低区间;可继续下降的余量有限,曲线随后下降较缓。

5.5 训练性能

与性能相关的配置:

配置节点卡数micro_batch_sizeGlobal batch sizelora.enable训 visual思考监督
单机 LoRA 图文非思考1818true是否
单机 LoRA 文本思考1818true否是

gradient_accumulation_steps 均为 1。FSDP 下 DP 等于卡数。卡数、micro_batch_size、是否跨节点、是否训视觉、是否把思考拼进序列,都会改变单步耗时。

配置日志总step首步 (ms)最短 (ms)最长 (ms)平均 (ms)
单机 LoRA 图文非思考train-A-lora-nothink-mm.log2609356.51769.03855.52193.1
单机 LoRA 文本思考train-B-lora-think-text.log65259953.51692.522156.75026.9

iteration 1 含算子编译与缓存预热,单独列出;最短、最长、平均耗时均不含首步。 单机 LoRA 文本思考把 reasoning_content 拼进序列,长度方差大,自注意力与 GDN 随序列变长,单步耗时差异较大。

6. 训练后权重转换

6.1 LoRA 微调后 合并为 Hugging Face

LoRA 训练保存的是适配器(如 lora_adapter_iteration_*.safetensors),需合并进基座 HF:

cd /workspace/MindSpeed-MM/checkpoint/common
python merge_lora_safetensors_to_base.py \
  --base_hf_dir /models/Qwen/Qwen3.8-27B \
  --lora_safetensors /workspace/host/result/qwen3-8-A/lora_adapter_iteration_260.safetensors \
  --save_merged_hf_dir /workspace/host/result/qwen3-8-A-hf \
  --lora_alpha 16 \
  --lora_r 8 \
  --device cpu

--lora_safetensors 为微调后的 LoRA 权重文件,--save_merged_hf_dir 为合并后的目标保存位置。--lora_alpha / --lora_r 必须与 4.3 的 alpha / rank 一致。上例对应图文 LoRA 的 save 目录。文本思考 LoRA 的 save 为 /workspace/host/result/qwen3-8-B,适配器文件名以实际 lora_adapter_iteration_*.safetensors 为准。

7. 推理部署

7.1 获取推理镜像

推理采用vllm_ascend部署,拉取vllm_ascend v0.23.0rc1镜像

docker pull quay.io/ascend/vllm-ascend:v0.23.0rc1

启动容器

export image_id=quay.io/ascend/vllm-ascend:v0.23.0rc1
export docker_name=qwen3_8_infer
export model_data=/workspace/host
docker run -itd --privileged --name=$docker_name --net=host \
    --shm-size 200g \
    --device=/dev/davinci0 \
    --device=/dev/davinci1 \
    --device=/dev/davinci2 \
    --device=/dev/davinci3 \
    --device=/dev/davinci4 \
    --device=/dev/davinci5 \
    --device=/dev/davinci6 \
    --device=/dev/davinci7 \
    --device=/dev/davinci_manager \
    --device=/dev/hisi_hdc \
    --device /dev/devmm_svm \
    -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
    -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
    -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi \
    -v /usr/local/sbin:/usr/local/sbin \
    -v /etc/hccn.conf:/etc/hccn.conf \
    -v $model_data:/workspace/host \
    $image_id \
    bash

进入容器

docker exec -it qwen3_8_infer bash

7.2 多模态图文推理

在容器内先改 weight_path(必须是 HF 目录,对应 6.1 合并结果)。思考由请求里的 chat_template_kwargs 打开。--allowed-local-media-path 允许 file:// 读本地图片,请求路径须落在该白名单下。

export PYTORCH_NPU_ALLOC_CONF="expandable_segments:True"
export HCCL_OP_EXPANSION_MODE="AIV"
export HCCL_BUFFERSIZE=1024
export OMP_NUM_THREADS=10
export OMP_PROC_BIND=false

weight_path="/workspace/host/result/qwen3-8-A-hf"

# 替换为使用的NPU卡
ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 \
vllm serve $weight_path \
    --served-model-name "qwen3.8-27B-mm" \
    --host 0.0.0.0 \
    --port 8011 \
    --data-parallel-size 1 \
    --tensor-parallel-size 4 \
    --max-model-len 32768 \
    --max-num-batched-tokens 16384 \
    --max-num-seqs 128 \
    --gpu-memory-utilization 0.94 \
    --trust-remote-code \
    --async-scheduling \
    --allowed-local-media-path / \
    --mm-processor-cache-gb 0 \
    --compilation-config '{"cudagraph_mode": "FULL_DECODE_ONLY"}' \
    --additional-config '{"enable_cpu_binding":true, "multistream_overlap_shared_expert": true}'

请求中的 model 必须与 --served-model-name 一致。000000000009.jpg 为 COCO train2017 中的常见样本。未挂 reasoning parser 时,接口 content 中 </think> 之前为思考过程,之后为最终回答。以下输出将这两段提取展示。

COCO 000000000009

问句要求根据上图判断离镜头最近的是哪样物品,以及这顿饭处于准备上桌还是已经吃完,用 2~3 句作答。下面两组请求问句相同,仅 reasoning_effort 不同。

长思考如下: 终答最近的是画面最前的黄色餐盒(西兰花与肉饼);食物分格摆放、未见食用痕迹,判断为便当正在打包或待上桌,不是已经吃完。

curl http://127.0.0.1:8011/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
  "model": "qwen3.8-27B-mm",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "file:///workspace/host/dataset_vl/train2017/000000000009.jpg"
          }
        },
        {
          "type": "text",
          "text": "Look at the tableware and food layout. Which item appears closest to the camera, and what does the arrangement suggest about whether this meal is being prepared, served, or already finished? Answer in 2-3 short sentences."
        }
      ]
    }
  ],
  "max_tokens": 1000,
  "temperature": 0,
  "top_p": 1,
  "chat_template_kwargs": {
    "enable_thinking": true,
    "preserve_thinking": true,
    "reasoning_effort": "xhigh"
  }
}'
{
  "think": "The user wants me to look at the image and determine two things: which item is closest to the camera, and what the arrangement suggests about the meal's state (prepared, served, or finished).\n\nLet me look carefully at the image. There's a blue bento-style tray with compartments. In the foreground, a yellow container holds broccoli and what looks like a meat patty or meatball. This yellow container is at the bottom of the frame, closest to the viewer/camera. Behind it are pink/magenta containers with bread and cream cheese, almonds, dried fruit, and pineapple chunks. To the right are cookies or brownies.\n\nSo the closest item to the camera is the yellow container with broccoli and the meat patty. The broccoli is in the very front.\n\nNow the arrangement: the food is neatly portioned into separate compartments, untouched, no crumbs scattered, no plates or utensils, no signs of eating. This suggests the meal is being prepared or packed (like a bento box being assembled) or is ready to be served. It's not finished because nothing is eaten. The neat compartmentalization suggests preparation/packing for a meal, likely a lunch box.\n\nThe question asks to choose among prepared, served, or finished. The arrangement with everything neatly in compartments and untouched suggests it's being prepared/packed or is ready to serve. I'd say it suggests preparation or serving rather than finished. The neatness and lack of any eaten items points to it being in the preparation/packing stage or just served and untouched.\n\nLet me think about which is most accurate. The food is in a bento tray, which is typically packed in advance. The cream cheese on bread is spread, the almonds are placed, the fruit is in a separate container. This looks like a packed lunch, i.e., being prepared or packed. But \"served\" could also fit because it's all laid out. The question wants me to reason about whether it's prepared, served, or finished. Since nothing is consumed and everything is neatly arranged in compartments, it's not finished. Between prepared and served: a bento box is usually prepared/packed before eating, and the compartmentalization indicates it's a packed meal. I think the most natural reading is that it's being prepared/packed or is ready to be served. I'll say the arrangement suggests it's being prepared or packed (a bento-style lunch) rather than already eaten, and it's ready to be served.\n\nThe instruction: answer in 2-3 short sentences. So I need to be concise.\n\nLet me draft: \"The yellow container holding the broccoli and the meat patty sits at the very front, making it the item closest to the camera. The food is neatly portioned into separate compartments and shows no signs of being eaten, such as crumbs or used utensils. This tidy, untouched layout indicates the meal is being prepared or packed (a bento-style lunch) and is ready to be served, rather than already finished.\"\n\nThat's three sentences. Good. Let me ensure it's self-contained and answers both parts. Yes.\n\nI'll finalize.",
  "content": "The yellow container holding the broccoli and the meat patty sits at the very front of the frame, making it the item closest to the camera. The food is neatly portioned into separate compartments and shows no signs of consumption—no crumbs, no used utensils, no half-eaten pieces. This tidy, untouched layout indicates the meal is being prepared or packed (a bento-style lunch) and is ready to be served, rather than already finished."
}

短思考:同一服务上改 reasoning_effort 为 low。 终答同样指向前景黄色餐盒;分格整齐且未动,判断为刚准备好或刚上桌、尚未吃完。思考过程更短。

curl http://127.0.0.1:8011/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
  "model": "qwen3.8-27B-mm",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "file:///workspace/host/dataset_vl/train2017/000000000009.jpg"
          }
        },
        {
          "type": "text",
          "text": "Look at the tableware and food layout. Which item appears closest to the camera, and what does the arrangement suggest about whether this meal is being prepared, served, or already finished? Answer in 2-3 short sentences."
        }
      ]
    }
  ],
  "max_tokens": 1000,
  "temperature": 0,
  "top_p": 1,
  "chat_template_kwargs": {
    "enable_thinking": true,
    "preserve_thinking": true,
    "reasoning_effort": "low"
  }
}'
{
  "think": "The user wants me to look at the image and determine two things: which item is closest to the camera, and what the arrangement suggests about the meal's state (prepared, served, or finished).\n\nLooking at the image, there's a blue lunchbox with compartments. The yellow container in the foreground holds broccoli and a meatball-like item. The pink container on the left has bread with cream cheese, almonds, and dried apple slices. Another pink container top right has pineapple chunks. On the right there are cookies.\n\nThe closest item to the camera: the yellow container is at the bottom, nearest the viewer. Within it, the broccoli and the meatball are prominent. The yellow container's front edge is closest. So the broccoli/meatball in the yellow tray is closest.\n\nArrangement: food is neatly portioned into compartments, untouched, no crumbs or eaten remnants. This suggests it's prepared/served, ready to eat, not finished.\n\nI need 2-3 short sentences. Let me draft: \"The yellow container in the foreground, holding the broccoli and meatball, sits closest to the camera. The food is neatly portioned into separate compartments and appears untouched, with no crumbs or remnants. This suggests the meal has just been prepared or served and is ready to eat, rather than already finished.\"\n\nThat's three sentences. Good. Keep concise.",
  "content": "The yellow container in the foreground, holding the broccoli and the meatball, sits closest to the camera. The food is neatly portioned into separate compartments and looks untouched, with no crumbs or remnants. This suggests the meal has just been prepared or served and is ready to eat, rather than already finished."
}

7.3 常用参数

参数含义
weight_pathHF 目录(LoRA 合并结果),不是 DCP
--served-model-name请求体里的 model 必须与此完全一致
--tensor-parallel-size张量并行卡数,需与 ASCEND_RT_VISIBLE_DEVICES 数量一致
--gpu-memory-utilizationHBM 占用比例。过高可能在长请求或图捕获时 OOM,建议从 0.90~0.94 调
--max-model-len单请求上下文上限(输入+输出)
--allowed-local-media-path本地 file:// 图片白名单根目录。请求路径必须落在该目录下
chat_template_kwargs请求侧思考控制。本次验证均开思考,字段为 enable_thinking
enable_thinking本轮是否思考。不传时模板默认常为开
preserve_thinking / reasoning_effortQwen3.8 多轮保留思考、思考深度。xhigh 为长思考,low 为短思考

可选:--reasoning-parser qwen3 把 <think> 拆到 reasoning 字段。本次验证未挂 parser,思考留在 content 中,以 </think> 分隔思考过程与最终答案。 说明:多模态任务推理也支持开思考,qwen3.8 27B 发布模型已具备该能力。只是本文档使用的多模态微调数据集中没有思考过程。