模型名称: lerobot/smolvla_metaworld
模型链接: HuggingFace
模型描述: SmolVLA 是一个轻量级视觉-语言-动作(VLA)模型,专为机器人操作任务设计。基于 SmolVLM2-500M 视觉语言模型,附加动作专家(action expert)头,用于 MetaWorld 机器人操纵任务的端到端策略学习。
模型架构: SmolVLM2 (Vision-Language Model) + Action Expert
参数规模: 450M (450,046,176)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| lerobot | 0.4.4 | LeRobot 框架 |
| transformers | 4.57.6 | HuggingFace Transformers |
| accelerate | >= 1.0.0 | 模型加载加速 |
| safetensors | >= 0.8.0 | 安全张量格式 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch_npu lerobot transformers accelerate safetensors# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download lerobot/smolvla_metaworld --local-dir ./smolvla_metaworld方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download https://ai.gitcode.com/hf_mirrors/lerobot/smolvla_metaworld --local-dir ./smolvla_metaworld# 启动推理服务
python3 inference.py --model-path ./smolvla_metaworld --device 0 --num-steps 10推理脚本支持以下参数:
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --device | int | 0 | NPU 设备 ID |
| --num-steps | int | 10 | 推理步数 |
| python3 inference.py --model-path ./smolvla_metaworld |
python3 inference.py --model-path ./smolvla_metaworld --device 0
python3 inference.py --model-path ./smolvla_metaworld --num-steps 10
### 3.4 推理参数说明
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --device | int | 0 | NPU 设备 ID |
| --num-steps | int | 10 | 推理步数 |
### 3.5 NPU 兼容性说明
本模型在昇腾 NPU 上推理时做了以下适配:
1. **精度转换**: 模型默认使用 bfloat16 权重,但 NPU 的 `torch.bucketize` 不支持 bfloat16。推理时将模型 cast 到 float32。
2. **Attention Mask 类型**: NPU 的 `torch.where` 要求条件 tensor 为 bool/uint8 类型,代码中对 attention_mask 添加了 `.bool()` 转换。
---
## 4. 推理成功日志
### 4.1 单条推理日志[模型] lerobot/smolvla_metaworld [设备] Ascend910_9362 (npu:0) [输入] 3x (3,256,256) 图像 + (6,) 状态 + (48,) 语言token [输出] 4D 动作 (x, y, z, gripper) [动作块] 50 steps [耗时] 143ms/step [状态] SUCCESS
### 4.2 批量推理日志[基准测试] 5次推理统计: 总耗时: 0.72s 平均: 143ms/step 最小: ~140ms 最大: ~150ms
---
## 5. 测试样例及输出结果
### 样例 1:基础推理(5步)
**运行命令:**
```bash
python3 inference.py --model-path /tmp/adapt_lerobot_smolvla_metaworld/weights --num-steps 5输出:
[模型] lerobot/smolvla_metaworld
[设备] Ascend910_9362 (npu:0)
[权重路径] /tmp/adapt_lerobot_smolvla_metaworld/weights
[1] Loading model...
参数量: 450,046,176 (450.0M)
NPU 显存: 1741.6 MB
[2] Creating observation...
输入: 3x (3,256,256) 图像 + (6,) 状态 + (48,) 语言token
[3] Running inference (5 steps)...
总耗时: 0.72s
平均延迟: 143ms/step
[4] Results:
动作空间: 4D (x, y, z, gripper)
动作块大小: 50 steps
动作序列:
Step 1: [-0.4250, -0.4035, -0.1919, +0.5135]
Step 2: [-0.5211, -0.3565, -0.0445, +0.5309]
Step 3: [-0.4019, -0.2931, -0.1610, +0.5480]
Step 4: [-0.3981, -0.3156, -0.2119, +0.5418]
Step 5: [-0.3989, -0.3384, -0.2119, +0.5894]
[状态] SUCCESS


测试数据: MetaWorld MT50 数据集 (模拟推理)
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 模型参数量 | 450M | 含 VLM backbone + action expert |
| NPU 显存占用 | 1741.6 MB | float32 精度 |
| 推理延迟 | 143 ms/step | Ascend910_9362 |
| 动作维度 | 4D | x, y, z, gripper |
| 动作块大小 | 50 steps | 连续动作预测窗口 |
| 输入图像 | 3x 256x256 | 3个相机视角 |
评测命令:
python3 inference.py --model-path ./smolvla_metaworld --num-steps 50acl.nnSearchSorted 不支持 bfloat16 输入。推理时将模型 cast 到 float32,会增加约 2x 显存占用。acl.nnSWhere 要求条件 tensor 为 bool/uint8 类型。代码中对 attention_mask 添加了 .bool() 转换。