{hardware NPU}
SO-101 桌面机械臂「抓取-放置」专家策略(VLA, Vision-Language-Action)在华为昇腾 NPU 上的推理适配。
smolvla/ 包,权重从 checkpoint 严格加载| 组件 | 版本 |
|---|---|
| 昇腾芯片 | Ascend 910 (62GB HBM) |
| torch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| CANN | 8.5.1 |
| transformers | 4.57.6 |
注意:SmolVLM2 视觉塔与专家注意力均使用 eager attention(纯 matmul + softmax 实现),在 NPU 上避免
aclnnFlashAttentionScore报错。
| 文件 | 说明 |
|---|---|
model.safetensors | 全部权重(vlm + lm_expert + action head,约 906MB) |
policy_preprocessor_step_5_normalizer_processor.safetensors | state/action 归一化统计量 |
policy_postprocessor_step_0_unnormalizer_processor.safetensors | action 反归一化统计量 |
config.json | SmolVLA 推理配置 |
# 1. 准备权重(huggingface 直连不通时走 hf-mirror 或 gitcode LFS)
# https://hf-mirror.com/anikitakis/vla_so101_pick_n_place_full_expert/resolve/main/model.safetensors
# https://gitcode.com/hf_mirrors/anikitakis/vla_so101_pick_n_place_full_expert.git (LFS)
# 2. 准备 SmolVLM2 config + tokenizer(模型架构依赖,非权重)
# ModelScope: HuggingFaceTB/SmolVLM2-500M-Video-Instruct (config.json + tokenizer 文件)
# 3. 安装依赖
pip install -r requirements.txt
# 4. 单端推理(CPU 或 NPU)
python inference.py --checkpoint /path/to/checkpoint --device npu:0
# 5. CPU vs NPU 精度对比
python inference.py --checkpoint /path/to/checkpoint --compare --device npu:0合成观测(3×480×640 平滑渐变图像 + 6 维状态 + 语言指令 put the annotated object in the box),固定同一 flow-matching noise:
| 指标 | 值 |
|---|---|
| cosine_similarity (CPU vs NPU) | 0.999997 |
| max_abs_diff | 4.32e-01(动作幅值 ~30,属 flow-matching 正常数值差) |
| NPU 单次推理 | 约 2~4 s(含 10 步 denoise) |
vla_so101_pick_n_place_full_expert/
├── inference.py # 推理脚本(CPU/NPU + --compare 精度对比)
├── README.md # 本文件
├── requirements.txt # 环境依赖
├── smolvla/ # vendor 自包含模型包(改造自 lerobot 0.4.4)
│ ├── configuration_smolvla.py # 精简 config(去掉 lerobot.configs 依赖)
│ ├── modeling_smolvla.py # VLAFlowMatching(去掉 PreTrainedPolicy 依赖)
│ ├── smolvlm_with_expert.py # VLM + 动作专家交错注意力(官方源码,仅依赖 transformers)
│ └── __init__.py
└── assets/
├── agent_workflow.png # 部署/推理流程图(截图待补)
├── npu_device_call.png # NPU 设备调用证据(截图待补)
└── model_result.png # 推理结果输出(截图待补)observation.images.camera1/2/3:三路相机图像 (3, 480, 640),float [0,1]observation.state:6 维机器人状态task:语言指令(如 "put the annotated object in the box")(1, 50, 6),50 步 × 6 维(4 关节角 + 2 夹爪),反归一化后为真实动作值