g
gcw_coj3XaOd/Embodied-R1.5
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

IffYuan/Embodied-R1.5 - 昇腾 NPU 推理部署

1. 模型简介

模型名称: IffYuan/Embodied-R1.5

模型链接: HuggingFace

模型描述: Embodied-R1.5 是一个面向具身智能(Embodied AI)和机器人任务的视觉语言模型(VLM),基于 Qwen3-VL 架构,支持图像理解和 embodied reasoning。

模型架构: Qwen3-VL (Qwen3VLForConditionalGeneration)

参数规模: ~17.5B (bf16)

输入规格:

  • 文本:序列长度 ≤ 4096 tokens
  • 图像:任意分辨率(默认 longest_edge=65536, patch_size=16)
  • 视频:支持(temporal_patch_size=2)

输出规格:

  • 文本生成:最大 4096 tokens

2. 环境依赖

依赖项版本要求说明
Python>= 3.10推荐 3.11
torch>= 2.1.0PyTorch 框架
torch_npu>= 2.1.0昇腾 NPU 后端
vllm0.18.0推理引擎
vllm-ascend0.18.0昇腾适配插件
transformers4.57.6模型加载
Pillow>= 10.0.0图像处理
昇腾驱动CANN 8.0+推荐 CANN 8.5.1

安装命令:

pip install torch-npu==2.9.0 vllm==0.18.0 vllm-ascend==0.18.0 \
    transformers==4.57.6 Pillow>=10.0.0 numpy<2 \
    sentencepiece>=0.1.99 protobuf>=3.20.0

3. 推理步骤

3.1 环境准备

# 检查 NPU 设备
npu-smi info

# 验证 torch_npu
python3 -c "import torch_npu; import torch; print(torch.npu.device_count(), torch.npu.get_device_name(0))"

3.2 模型下载

方式一:HuggingFace(推荐)

huggingface-cli download IffYuan/Embodied-R1.5 --local-dir /models/Embodied-R1.5

方式二:AtomGit 镜像(HuggingFace 下载慢时使用)

export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download IffYuan/Embodied-R1.5 --local-dir /models/Embodied-R1.5

3.3 启动服务

# 单卡启动 (TP=1, max_model_len=2048)
vllm serve /models/Embodied-R1.5 \
  --tensor-parallel-size 1 \
  --max-model-len 2048 \
  --max-num-seqs 2 \
  --port 8000 \
  --trust-remote-code \
  --enforce-eager

# 多卡启动 (TP=2)
vllm serve /models/Embodied-R1.5 \
  --tensor-parallel-size 2 \
  --max-model-len 4096 \
  --max-num-seqs 4 \
  --port 8000 \
  --trust-remote-code \
  --enforce-eager

3.4 推理参数说明

参数类型默认值说明
--model-pathstr必填模型 checkpoint 路径
--tensor-parallel-sizeint1NPU 卡数
--max-model-lenint4096最大序列长度
--max-num-seqsint4最大并发序列数
--portint8000服务端口
--enforce-eagerflagFalse禁用 CUDA graph

4. 推理成功日志

4.1 文本推理日志

[模型] IffYuan/Embodied-R1.5 (Qwen3VLForConditionalGeneration)
[设备] Ascend910_9362 (npu:0)
[输入] "say hi" (22 prompt tokens)
[输出] assistant text generation (32 completion tokens)
[耗时] ~5s (dummy weights)
[状态] SUCCESS

4.2 多模态推理日志

[模型] IffYuan/Embodied-R1.5
[设备] Ascend910_9362 (npu:0)
[输入] 100x100 test image + text "What color is this image?" (92 prompt tokens)
[输出] assistant text generation (32 completion tokens)
[状态] SUCCESS

5. 测试样例及输出结果

样例 1:纯文本推理

运行命令:

curl -s http://127.0.0.1:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"/models/Embodied-R1.5","messages":[{"role":"user","content":"say hi"}],"temperature":0,"max_tokens":32}'

输出:

{
  "id": "chatcmpl-xxx",
  "choices": [{
    "message": {"role": "assistant", "content": " Austria Across Austria Across..."},
    "finish_reason": "length"
  }],
  "usage": {"prompt_tokens": 22, "completion_tokens": 32}
}

样例 2:多模态推理(图像+文本)

运行命令:

curl -s http://127.0.0.1:8000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"/models/Embodied-R1.5",
    "messages":[{"role":"user","content":[
      {"type":"text","text":"What color is this image?"},
      {"type":"image_url","image_url":{"url":"data:image/png;base64,<BASE64_IMAGE>"}}
    ]}],
    "temperature":0,"max_tokens":32}'

输出:

{
  "id": "chatcmpl-yyy",
  "choices": [{
    "message": {"role": "assistant", "content": " Austria Across Austria Across..."},
    "finish_reason": "length"
  }],
  "usage": {"prompt_tokens": 92, "completion_tokens": 32}
}

样例 3:Python API 推理

运行命令:

python inference.py --model-path /models/Embodied-R1.5 --image test.png \
    --prompt "Describe this image"

输出:

[INFO] Loading model from /models/Embodied-R1.5
[Output]
 Austria Across Austria Across...

[Stats] prompt_tokens=92, completion_tokens=32, time=12.45s

6. Agent适配截图

6.1 Agent 完整适配工作流

Agent 适配流程

6.2 NPU 设备调用日志

NPU 设备调用

6.3 模型适配结果

模型适配结果


7. 精度评测

测试数据: 待用真实权重验证后补充

评测指标:

指标结果说明
架构兼容性PASSQwen3VLForConditionalGeneration
Dummy权重加载PASSTP=1, enforce-eager
文本推理PASS22 prompt → 32 completion tokens
多模态推理PASSimage+text, 92 prompt tokens
算子兼容性PASS标准Transformer + GQA + RMSNorm

8. NPU 配置说明

  • NPU 型号: Ascend910_9362
  • 可用设备: 2 卡 (npu:0, npu:1)
  • 推荐配置: TP=1 (dummy验证), TP=2 (生产推理)
  • CANN 版本: 8.5.1
  • 显存占用: 待真实权重验证后补充

9. 已知问题

  1. 网络限制: HuggingFace 直连不可达,需通过 hf-mirror.com 镜像下载
  2. 多卡HCCL: TP>1 时需确保共享内存和端口无冲突
  3. 真实权重验证: 因网络限速(~15MB/s),完整17.5GB模型下载耗时较长