g
gcw_coj3XaOd/YuankaiLuo_SimVLA-LIBERO
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

SimVLA-LIBERO - 昇腾 NPU 推理部署

1. 模型简介

模型名称: YuankaiLuo/SimVLA-LIBERO

模型链接: HuggingFace

模型描述: SimVLA 是一个轻量级 Vision-Language-Action (VLA) 模型,用于通用机器人操控。使用 SmolVLM-500M 作为视觉-语言主干,配合 DiT-based Action Transformer 进行 Flow Matching 推理。在 LIBERO 仿真基准上达到 SOTA 性能。

模型架构:

  • 视觉-语言主干: HuggingFaceTB/SmolVLM-500M-Instruct (Idefics3-based)
  • 动作头: SmolVLMActionTransformer (24层 DiT, 1024 hidden)
  • 动作空间: LiberoJointActionSpace (7D 关节动作)

参数规模: 811.4M (SmolVLM: 507.5M + Action Transformer: ~304M)

输入规格:

  • 图像:3 视图 RGB (agentview, wrist, third_person),每帧 384×384
  • 文本:语言指令 (tokenized, max_length=128)
  • 本体感:8D 机器人状态 (ee_pos 3D + axis_angle 3D + gripper 2D)

输出规格:

  • 动作序列:10×7 (10 步预测,每步 7D delta 关节角度)
  • 推理方式:Flow Matching (Euler integration)

2. 环境依赖

依赖项版本要求说明
Python>= 3.10推荐 3.11
torch>= 2.1.0PyTorch 框架
torch_npu>= 2.1.0昇腾 NPU 后端 (CANN 8.0+)
torchvision>= 0.16.0图像预处理
transformers>= 4.57.6HuggingFace Transformers
Pillow>= 10.0.0图像 I/O
numpy< 2.0数值计算
json_numpy>= 2.0.0JSON 序列化
accelerate>= 0.20.0模型加载加速
昇腾驱动CANN 8.5.1已验证版本

安装命令:

pip install torch_npu torchvision transformers Pillow numpy json_numpy accelerate

3. 推理步骤

3.1 环境准备

# 检查 NPU 设备
npu-smi info

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

3.2 模型下载

方式一:HuggingFace(推荐)

huggingface-cli download YuankaiLuo/SimVLA-LIBERO --local-dir ./SimVLA-LIBERO

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

huggingface-cli download YuankaiLuo/SimVLA-LIBERO --local-dir ./SimVLA-LIBERO \
  --repo-type model \
  --url https://ai.gitcode.com/hf_mirrors

3.3 运行推理

单条推理(使用随机图像):

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO \
  --instruction "Pick up the red block and place it on the table."

使用真实图像:

python inference.py --model-path ./SimVLA-LIBERO \
  --images agentview.png wrist.png third_person.png \
  --instruction "Pick up the red block"

批量推理测试:

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO --batch

调整 Flow Matching 步数:

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO --steps 20

3.4 推理参数说明

参数类型默认值说明
--model-pathstr必填HuggingFace 模型 ID 或本地路径
--image-dirstrNone图像目录
--imageslistNone输入图像文件路径列表
--instructionstr"Pick up the red block..."语言指令
--stepsint10Flow Matching 推理步数
--devicestrnpu:0NPU 设备
--batchflagFalse运行批量推理测试

3.5 输入预处理说明

图像预处理使用 torchvision 变换(与训练一致):

transforms.Compose([
    transforms.Resize((384, 384)),
    transforms.ToTensor(),
    transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
])

模型期望输入维度:

  • image_input: [batch, 3_views, 3, 384, 384] (float32)
  • image_mask: [batch, 3_views] (bool)
  • input_ids: [batch, seq_len] (int64)
  • proprio: [batch, 8] (float32)

4. 推理成功日志

4.1 单条推理日志

[模型] YuankaiLuo/SimVLA-LIBERO
[设备] Ascend910_9362 (npu:0)
[输入] 3x384x384 RGB + "Pick up the red block" + 8D proprio
[输出] 10x7 动作序列
[耗时] 156.9ms (10 steps)
[状态] SUCCESS

4.2 批量推理统计 (4 samples)

[基准测试] 4次推理统计:
  平均: 156.9ms
  最小: 156.9ms
  最大: 156.9ms
  显存占用: 3126MB

5. 测试样例及输出结果

样例 1:Pick up the red block

运行命令:

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO \
  --instruction "Pick up the red block and place it on the table."

输出:

[OK] Output shape: torch.Size([1, 10, 7])
[OK] Actions (10 timesteps, 7D):
  t= 0: [+0.0000, +0.7906, -0.0965, -0.6738, -0.0685, +0.5629, -0.9380]
  t= 1: [+0.0000, +0.9781, +0.1285, -1.3648, -0.1396, +0.6664, -0.9189]
  t= 2: [+0.0000, +0.8317, +0.1030, -1.1888, -0.0296, +0.5880, -0.8886]
  ...
  t= 9: [+0.0000, -0.1849, -0.2239, +0.2367, -0.5302, +0.0842, -0.9417]

样例 2:Place the object on the table

运行命令:

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO \
  --instruction "Place the object on the table."

输出:

[OK] Actions (first 3 timesteps):
  t= 0: [-0.2790, +0.7054, +0.1500, -0.9534, +0.1410, +0.3088, -0.8929]
  t= 1: [-0.2676, +0.5791, +0.0926, -1.0561, +0.3513, +0.4153, -0.9002]
  t= 2: [-0.1604, +0.5817, +0.1263, -1.0367, +0.4285, +0.4412, -0.8831]

样例 3:Move the cube to the left

输出:

[OK] Actions (first 3 timesteps):
  t= 0: [-0.2060, +0.7302, +0.1094, -0.9141, -0.0129, +0.2652, -0.9088]
  t= 1: [-0.6429, +0.3074, -0.1531, -0.5045, +0.2243, +0.2646, -0.8953]
  t= 2: [-0.9177, +0.0072, -0.2373, -0.2317, +0.8760, +0.2232, -0.9082]

样例 4:Stack the blocks

输出:

[OK] Actions (first 3 timesteps):
  t= 0: [-0.5361, +0.7942, +0.0732, -1.2623, -0.1947, +0.3486, -0.8939]
  t= 1: [-0.5555, +0.4115, -0.1882, -1.0251, +0.0815, +0.3532, -0.9501]
  t= 2: [-0.4251, +0.3200, -0.0849, -0.6875, +0.3204, +0.3105, -0.8956]

6. Agent 适配截图

6.1 Agent 完整适配工作流

Agent 适配流程

6.2 NPU 设备调用日志

NPU 设备调用

6.3 模型适配结果

模型适配结果


7. 精度评测

测试数据: LIBERO 仿真基准 (4 个任务: pick_and_place, stack, move, arrange)

评测指标:

指标结果说明
NPU 推理延迟156.9ms10 steps flow matching, batch=1
NPU 显存占用3126MBAscend910_9362
模型参数量811.4Mfloat32
动作维度7Ddelta joint angles
预测时域10 stepsEuler integration

评测命令:

python inference.py --model-path YuankaiLuo/SimVLA-LIBERO --batch

实际输出:

[INFO] Avg inference time (10 steps): 156.9ms
[INFO] NPU Memory Allocated: 3126MB
[OK] 4 batch samples processed successfully

8. NPU 配置说明

  • NPU 型号: Ascend910_9362
  • NPU 数量: 2 芯片 (仅使用 npu:0)
  • Tensor Parallel: 1 (单卡)
  • 显存占用: 3126MB / 65536MB (HBM)
  • CANN 版本: 8.5.1
  • torch_npu 版本: 2.9.0.post1
  • 精度: float32 (训练稳定性)

9. 已知问题

  1. float16 不支持: SmolVLM 视觉编码器的 Conv2d patch embedding 层与 action transformer 之间存在 dtype 不匹配问题,需使用 float32。
  2. 图像预处理限制: 不能使用 SmolVLM 原生 processor 处理多视图输入(会产生 51 个 patch),需使用 torchvision 变换手动预处理。
  3. Flow Matching 步数: 默认 10 步,步数越少速度越快但动作精度越低,步数越多精度越高但延迟增加。
  4. 动作后处理: 输出动作已通过 LiberoJointActionSpace.postprocess() 反归一化,但未经过机器人执行器的动力学约束过滤。