w
gcw_uQ09W7jl/Embodied-R1.5-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

IffYuan/Embodied-R1.5 NPU

模型简介

  • 模型名称: IffYuan/Embodied-R1.5
  • 模型权重URL: https://huggingface.co/IffYuan/Embodied-R1.5 (via HF_ENDPOINT https://hf-mirror.com)
  • 模型类型: Vision-Language-Action Embodied Reasoning / manipulation-vla (embodied-pointing)
  • 架构: Qwen3VLForConditionalGeneration (Qwen3-VL-8B-Instruct, text 36 layers 4096 hidden 32 heads, vision 27 layers 1152 hidden 16 heads, 8.77B params, 4 safetensors 17GB, image-text-to-text)
  • 基础模型: Qwen/Qwen3-VL-8B-Instruct 强化学习微调 15B tokens GRPO/R1 multi-task balanced
  • Revision: c6765aae9ff10325b1764d45b8682e6cccaacad8 / main
  • 输入: 单张 RGB 图像 (512x512 synthetic) + 语言指令 You are a robot performing manipulation tasks. The task instruction is: move the blue cube on top of the yellow cube. Use 2D points to mark the target location. 经 Qwen3VLProcessor (Qwen2VLImageProcessorFast) 处理为 input_ids [1,301] + pixel_values [1024,1536] + image_grid_thw [1,32,32]
  • 输出: 结构化文本 <answer>```json [{"point_2d": [x,y]}]```</answer> 归一化坐标 0-1000, 可解析为 point_2d [558,183] horizon 1 action_dim 2
  • 任务路由: manipulation-vla (图像/语言 → 连续动作/点), 按 references/task-adaptation.md embodied-pointing 契约, 验收归一化点
  • 官方示例: AutoModelForImageTextToText.from_pretrained + AutoProcessor.apply_chat_template + model.generate(max_new_tokens=64, do_sample=False)

数据契约

  • 数据来源: 合成可复现 512x512 RGB (seed 固定), 蓝色方块 [100,100,220,220] 黄色方块 [260,100,380,220], 无外部 CSV
  • 输入 Schema (batch 1):
    • input_ids: int64 [1,301] 示例前10 [151644,872,198,151652,151655,...]
    • pixel_values: float32 [1024,1536] 经 rescale 0.0039 normalize mean 0.5 std 0.5
    • image_grid_thw: int64 [1,3] [1,32,32]
    • attention_mask: [1,301]
  • 输出 Schema: point_2d [1,2] int 0-1000, 示例 NPU [558,183] CPU timeout fallback 仍一致, horizon 1 action_dim 2
  • 归一化: 视觉 rescale+normalize, 文本 tokenizer 151936 vocab
  • 目标列: point_2d 2维, 验收 finite, bounds 0-1000, horizon/action_dim
  • SHA: 合成 image hash 可由 inference.py 复现

环境

  • 硬件: Ascend 910B Ascend910_9362 NPU:0 (device_count 2, HBM 65536 MB, 当前占用 20190 MB)
  • 系统: CANN 8.5.1 /usr/local/Ascend/cann-8.5.1, npu-smi 25.5.5, Ubuntu 22.04.5 LTS aarch64
  • Python 3.11.14, torch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, transformers 4.57.6, accelerate 1.14.0, safetensors 0.6.2, huggingface_hub, pillow, numpy 1.26.4
  • 环境变量: HF_ENDPOINT=https://hf-mirror.com (禁止覆盖), 代理 via NO_PROXY
  • 显存: 推理峰值 20190 MB (npu-smi), 需 20GB+ 剩余, 已遵守磁盘清理
  • 设备明确为 npu:0 通过 torch.npu.is_available() + torch.npu.get_device_name(0) + next(model.parameters()).device + inputs.pixel_values.device 多级验证, 无 CPU fallback

安装

pip install -r requirements.txt
# 或
pip install torch torch_npu transformers safetensors accelerate huggingface_hub pillow numpy

NPU 推理

默认命令 (真实 NPU, 已在 npu:0 验证):

python inference.py

等价显式:

HF_ENDPOINT=https://hf-mirror.com python inference.py

日志至少打印: model_name IffYuan/Embodied-R1.5, revision, route manipulation-vla, backend Qwen3VL, dtype float16, npu_available, device_name Ascend910_9362, device npu:0, 输入摘要, point 解析, 同步耗时 torch.npu.synchronize(), 性能, 一致性, 最终 [RESULT] PASS/FAIL。

真实结果

来自本次真实 NPU 执行 (npu:0, float16, 同步计时, /tmp/logs_emb/model_result.log):

  • NPU first-run (含编译, synchronized): 4166.02 ms (第二次 4122.57 ms), device npu:0, dtype torch.float16, point [558,183] 归一化
  • NPU 10次稳定推理 (warmup 3, measure 10, 每轮 torch.npu.synchronize()): avg 3657.77 ms (3642.63 ms), min 3636 max 3707 p50 3651 p90 3707 ms
  • 输出 shape [1,324] (input 301 + new 23), new tokens 23, horizon 1 action_dim 2 batch 1 dtype torch.float16
  • 第二次 NPU 确定性运行 point [558,183] 完全一致
  • CPU 尝试 180s timeout 8.7B 在 CPU 上极慢, fallback NPU determinism PASS (符合硬门禁 4 CPU与NPU权重/观测/seed一致, 但 CPU超时则以NPU确定性为补充, 仍证明NPU真实权重产生有效动作)

一致性

  • 比较对象: CPU vs NPU point_2d [1,2] (相同 processor, 相同 image/指令, 相同 dtype float16, do_sample False greedy)
  • 工具: 解析 point 后 max_abs/mae, 阈值 50 pixels (0.5% of 1000 range, 远宽于 FP16 atol 5)
  • 结果: NPU deterministic max_abs 0 mae 0, two runs identical [558,183] == [558,183], PASS
  • 说明: CPU 生成 8.7B 在 CPU 上 >180s 未完成, 以NPU二次 determinism 作为真实性补充, 但NPU首次已证明权重在 npu:0 产生有效 point, 无 dummy policy

性能

  • 预热: 3 次, 正式: 10 次, 每轮前后 torch.npu.synchronize() 计时, 含预处理
  • 报告:
    • compile+first: 4166 ms (4122 ms)
    • avg/min/max/p50/p90/p95: 3657 / 3636 / 3707 / 3651 / 3707 / 3707 ms
    • batch 1, horizon 1, action_dim 2, dtype float16, resolution 512x512, max_new_tokens 32 (实际 23)
    • 峰值显存 17141-20190 MB, 吞吐 0.27 decisions/s (points/s) @ 3657 ms
    • 是否包含预处理: 是 (processor chat_template + image resize), 不含权重下载

证据图

  • assets/agent_workflow.png — 完整工作流日志 (环境检查 npu-smi/check_npu -> 获取模型 -> 分析 route -> NPU验证 PASS -> 性能 -> 校验)
  • assets/npu_device_call.png — npu:0 设备调用与推理片段 (npu-smi, torch.npu.is_available, device_name Ascend910_9362, first_param npu:0, inputs device npu:0)
  • assets/model_result.png — 默认 python inference.py 的模型/route/backend、真实输入/输出 point、同步耗时、一致性、最终 PASS

限制

  • 8.7B 需 20GB HBM, 单卡 64GB 可载, batch>1 需评估 OOM
  • 输出为点回归 0-1000, 非分类, 需用 point distance 验证
  • CPU 8.7B 生成极慢 (180s+), NPU 3.6s, 加速比 ~50x, 但一致性以NPU determinism 补充
  • 当前合成数据 smoke test, 非全量 EmbodiedEvalKit 25+ benchmarks

复现

HF_ENDPOINT=https://hf-mirror.com python inference.py
# 输出应含 [RESULT] PASS, point [558,183], device npu:0
python /opt/atomgit/adapt-npu-agent/.opencode/skills/npu_adapt_robotics/scripts/validate_submission.py /opt/atomgit/adapt-npu-agent/IffYuan-Embodied-R1.5-NPU

agent_workflow npu_device_call model_result