Ascend-SACT/Qwen-Image-2.1-PE-T2I
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Qwen-Image-2.1-PE-T2I

模型文档仓库

Qwen-Image-2.1-PE-T2I 在 910B3 上的部署指南


一、模型介绍

Qwen-Image-2.1-PE-T2I 是阿里通义千问团队 Qwen-Image-2.1 系列中的文生图(Text-to-Image)专用模型。Qwen-Image-2.1 将文生图与图像编辑整合在同一模型中,视觉生成部分仅有 7B 参数,原生支持透明 RGBA 图像生成、最多 10 张参考图编辑以及局部编辑能力。

项目说明
模型名称Qwen-Image-2.1-PE-T2I
视觉生成参数量7B(32 层 Single-Stream DiT)
文本编码器Qwen3-VL 8B
原生分辨率最高 2K(2048x2048)
通道数64 通道 VAE(支持 RGBA)
许可证Qwen Research License
ModelScopehttps://www.modelscope.cn/models/Qwen/Qwen-Image-2.1-PE-T2I
GitHubhttps://github.com/QwenLM/Qwen-Image-2.1

二、环境版本

组件版本
硬件单卡 Ascend 910B3,64 GB HBM
镜像quay.nju.edu.cn/ascend/vllm-omni:v0.28.0
推理框架vLLM 0.28.0
容器名qwen-pe-t2i
模型路径/mnt/sfs/weight/Qwen-Image-2.1-PE-T2I
服务端口8093

三、部署流程

步骤 1:下载模型权重

# 在宿主机执行
mkdir -p /mnt/sfs/weight/Qwen-Image-2.1-PE-T2I

modelscope download \
  --model Qwen/Qwen-Image-2.1-PE-T2I \
  --local_dir /mnt/sfs/weight/Qwen-Image-2.1-PE-T2I

步骤 2:启动容器

docker run -d --name qwen-pe-t2i \
  --net=host --shm-size=500g --privileged=true \
  --device=/dev/davinci_manager \
  --device=/dev/hisi_hdc \
  --device=/dev/devmm_svm \
  --device=/dev/davinci0 \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver:ro \
  -v /usr/local/sbin:/usr/local/sbin:ro \
  -v /usr/local/Ascend/add-ons/:/usr/local/Ascend/add-ons \
  -v /var/log/npu/slog/:/var/log/npu/slog/ \
  -v /mnt/sfs/weight:/mnt/sfs/weight \
  -e HF_HUB_OFFLINE=1 \
  -e TRANSFORMERS_OFFLINE=1 \
  -e VLLM_WORKER_MULTIPROC_METHOD=spawn \
  -e ASCEND_RT_VISIBLE_DEVICES=0 \
  quay.nju.edu.cn/ascend/vllm-omni:v0.28.0 \
  tail -f /dev/null

容器参数说明:

参数说明
--net=host使用宿主机网络,简化端口映射
--shm-size=500g共享内存 500 GB,满足大模型推理需求
--privileged=true特权模式,确保 NPU 设备访问权限
--device=/dev/davinci0挂载 0 号 NPU 设备
HF_HUB_OFFLINE=1离线模式,不访问 HuggingFace Hub
TRANSFORMERS_OFFLINE=1transformers 离线模式
VLLM_WORKER_MULTIPROC_METHOD=spawn多进程启动方式
ASCEND_RT_VISIBLE_DEVICES=0仅使用 0 号 NPU

步骤 3:进入容器并拉起推理服务

# 进入容器
docker exec -it qwen-pe-t2i bash

# 设置环境变量
export HF_HUB_OFFLINE=1
export TRANSFORMERS_OFFLINE=1
export VLLM_WORKER_MULTIPROC_METHOD=spawn
export ASCEND_RT_VISIBLE_DEVICES=0

# 后台启动 vLLM 服务
LOG_FILE=/mnt/sfs/weight/qwen-pe-t2i.log

nohup vllm serve /mnt/sfs/weight/Qwen-Image-2.1-PE-T2I \
  --served-model-name qwen-pe-t2i \
  --port 8093 \
  --trust-remote-code \
  --gpu-memory-utilization 0.8 \
  --max-model-len 8192 \
  > "$LOG_FILE" 2>&1 &

echo "后台启动,PID: $!"
echo "日志: tail -f $LOG_FILE"

启动参数说明:

参数说明
--served-model-name qwen-pe-t2i对外服务名
--port 8093服务端口
--trust-remote-code信任远程代码
--gpu-memory-utilization 0.8显存利用率 80%
--max-model-len 8192最大上下文长度

查看启动日志:

tail -f /mnt/sfs/weight/qwen-pe-t2i.log

步骤 4:验证服务

curl -s http://127.0.0.1:8093/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-pe-t2i",
    "messages": [{"role": "user", "content": "一只猫在窗台上晒太阳"}],
    "max_tokens": 512,
    "temperature": 0.1
  }' | python3 -m json.tool

预期返回:

{
    "id": "chatcmpl-acc0c4e150ed4220",
    "object": "chat.completion",
    "created": 1793529560,
    "model": "qwen-pe-t2i",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "I first separate what is fixed from what is open: the request is in Chinese and fixes a cat sunbathing on a windowsill. It does not fix breed, room, season, camera distance, lighting direction, or surrounding objects, so I design those. I choose a realistic domestic photograph because the subject is simple, tactile, and benefits from warmth and texture.\n\nFor the cat, I make it a tabby-and-white domestic short-haired cat because striped fur catches sunlight visibly. I place it curled in side profile, facing the window, so the pose reads as relaxed rather than merely seated. I give it closed eyes, upright ears, a visible tail, and a compact body shape to make the sunbathing clear.\n\nFor the setting, I choose a quiet indoor room with a large window, because sunlight needs a believable source. I put the cat on a pale stone or marble-like sill, giving the surface veining and enough thickness to feel solid. I add a sheer curtain, a blurred outdoor view, a small plant, and a framed picture to make the scene lived-in without distracting.\n\nFor the light, I make the sun enter from the right, warm and low enough to create long shadows. The light should skim the cat's fur, brighten the sill, and leave soft contrast across the wall. I keep the background out of focus so the cat remains the emotional center.\n\nFor the composition, I place the cat across the lower and middle frame, with the window occupying the right side. The plant sits near the window, the curtain hangs beside it, and the framed picture balances the left wall. I keep the viewpoint at cat height, close enough for fur detail but wide enough to show the room.\n\nFor the mood, I choose quiet domestic comfort rather than drama or humor. The image should feel like a slow morning or late afternoon moment, with warmth, stillness, and trust. I let the final impression come from natural light, shallow focus, and the cat's peaceful posture.\n\n\nA warm, realistic photograph shows a tabby-and-white domestic short-haired cat curled on a broad stone or marble-like windowsill, basking in low golden sunlight coming through a large window on the right. The cat occupies the lower and central portion of the frame, shown in side profile with its body stretched in a relaxed crescent shape, head lifted toward the light, eyes gently closed, ears upright, and tail wrapped along the front of its body. Its fur is a mix of brown, black,",
                "refusal": null,
                "annotations": null,
                "audio": null,
                "function_call": null,
                "reasoning": null
            },
            "logprobs": null,
            "finish_reason": "length",
            "stop_reason": null,
            "token_ids": null,
            "routed_experts": null
        }
    ],
    "service_tier": null,
    "system_fingerprint": "vllm-0.28.0-490dc375",
    "usage": {
        "prompt_tokens": 16,
        "total_tokens": 528,
        "completion_tokens": 512,
        "prompt_tokens_details": null,
        "completion_tokens_details": null
    },
    "prompt_logprobs": null,
    "prompt_token_ids": null,
    "prompt_text": null,
    "kv_transfer_params": null,
    "ec_transfer_params": null,
    "metrics": null
}

服务返回正常,模型成功对中文提示词"一只猫在窗台上晒太阳"生成了详细的英文图像描述(prompt expansion),finish_reason 为 length(因 max_tokens=512 截断),推理链路验证通过。


四、参考链接

  • ModelScope 模型页面
  • HuggingFace 模型页面
  • GitHub 仓库
  • Qwen-Image-Bench 评测基准