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

Embodied-R1.5 昇腾 NPU 适配

本仓库为 IffYuan/Embodied-R1.5 (基于 Qwen3-VL-8B-Instruct 微调的统一具身基础模型)的 昇腾 NPU (Ascend910 / torch-npu) 适配版本。已完整清除 CUDA 依赖,模型与输入张量全部迁移至 npu:0 运行。

模型信息

  • 架构: Qwen3VLForConditionalGeneration (qwen3_vl)
  • 参数规模: 约 8B(权重总量约 17.5GB, bf16)
  • 输入模态: 图像 + 文本
  • 输出: 文本 / 结构化 <answer>(点、框、深度等 embodied 推理结果)
  • 原始权重: https://huggingface.co/IffYuan/Embodied-R1.5

环境要求

  • 昇腾 Ascend910(本仓库在 2×Ascend910 上验证)
  • Python 3.11 + PyTorch + torch_npu(版本需匹配 CANN)
  • transformers >= 4.51(含 Qwen3VL 支持)

推理用法

1. 命令行单图推理

python inference.py --img test_input.png
# 可选自定义任务提示词:
python inference.py --img test_input.png --prompt "你的 embodied 任务描述"

2. FastAPI 服务

uvicorn inference:app --host 0.0.0.0 --port 8000
curl -F "file=@test_input.png" http://127.0.0.1:8000/predict

返回结构化 JSON,含 response(完整回复)与 answer(<answer> 标签内容)。

适配说明

  1. 入口脚本顶部注入 import torch_npu + torch.npu.set_device(0),并用 try-except 捕获 NPU 初始化异常。
  2. 全代码域无任何 CUDA 调用(无 .cuda()、torch.cuda.*、device="cuda")。
  3. 模型以 torch_dtype=torch.bfloat16 加载(Ascend910 原生支持 bf16), attn_implementation="eager" 规避 NPU 上 sdpa/flash-attn 潜在兼容问题。
  4. 权重缓存于 model_weights/IffYuan/Embodied-R1.5(本仓库不包含大权重,按需下载)。