w
gcw_uQ09W7jl/smolvla_base-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

lerobot/smolvla_base NPU

模型简介

  • 模型名称: lerobot/smolvla_base
  • 模型权重URL: https://huggingface.co/lerobot/smolvla_base (国内镜像 HF_ENDPOINT=https://hf-mirror.com)
  • 任务路由: manipulation-vla (图像/状态/语言 → 连续动作块)
  • 架构: SmolVLA (HuggingFaceTB/SmolVLM2-500M-Video-Instruct VLM 16层 + Action Expert, 450M 参数, flow-matching 10 steps, chunk_size 50, n_action_steps 50, max_state_dim 32, max_action_dim 32)
  • Revision: main (pin c83c3163b8ca9b7e67c509fffd9121e66cb96205)
  • 输入: observation.state [1,6] STATE MEAN_STD, observation.images.camera1/2/3 [1,3,256,256] VISUAL IDENTITY resize 512x512 with padding, observation.language.tokens [1,48] + mask (SmolVLM2 tokenizer)
  • 输出: action [1,50,6] 连续动作序列 (chunk 50, dim 6)

数据契约

  • 合成可复现数据: seed 42 生成图像/状态, seed 123 显式 noise [1,50,32]
  • 语言示例: pick up the red cube and place it in the box → tokens [18188,614,260,2382,20636,...] shape [1,48]
  • 状态示例: CPU [0.1104, -0.0610, -0.1973] NPU 相同 (共享 raw observation)
  • 归一化: VISUAL IDENTITY (2*img-1), STATE/ACTION MEAN_STD (config)
  • 输出语义: 连续动作 regression, 比较 max_abs/MAE

环境

  • 硬件: Ascend910_9362 NPU:0 x2, HBM 65536 MB (npu-smi 25.5.5, CANN 8.5.1)
  • 软件: Python 3.11.14, torch 2.9.0+cpu, torch_npu 2.9.0.post1, transformers 4.57.6, lerobot 0.4.4, safetensors 0.8.0
  • 环境变量: HF_ENDPOINT=https://hf-mirror.com
  • 显存占用: ~3110 MB

安装

pip install -r requirements.txt

NPU 推理

python inference.py
# 或
HF_ENDPOINT=https://hf-mirror.com python inference.py
SMOLVLA_MODEL_DIR=/opt/atomgit/adapt-npu-agent/model_cache/smolvla_base python inference.py

日志打印: model/revision/route/backend/device/dtype/首参数 device/输入摘要/输出摘要/同步耗时/PASS

真实结果

来自 python smolvla_base-NPU/inference.py 在 npu:0 (float32, torch.npu.synchronize 计时):

  • CPU: shape [1,50,6] finite true min -0.983694 max 0.413682 mean -0.233725 first [0.009113596752285957, -0.11461962759494781, -0.2841644585132599, -0.272083044052124, 0.40801364183425903, -0.4490728974342346]
  • NPU: shape [1,50,6] device npu:0 finite true min -0.983706 max 0.413677 mean -0.233733 first [0.00911309290677309, -0.11461970955133438, -0.2841640114784241, -0.2720806896686554, 0.40801337361335754, -0.44907146692276]
  • NPU first latency (含编译): 591.20 ms
  • NPU second run: ~300 ms

一致性

  • 工具: validate_policy_outputs.py --cpu /tmp/smolvla_cpu.json --npu /tmp/smolvla_npu.json --atol 1e-4 --rtol 1e-3
  • 指标: max_abs 0.000043, mae 0.000014, max_ref 0.983694
  • 阈值 FP32: atol 1e-4 rtol 1e-3 => tolerance 0.001084 → PASS (strict)
  • BF16: atol 5e-3 rtol 5e-2 => 0.054185 → PASS
  • 输入: CPU/NPU 共享同一 raw observation 与固定 noise, device 已验证均为 npu:0 (浮点输入) / npu:0 (noise/action)
  • 有限值、shape [1,50,6]、维度 horizon 50 action_dim 6 均通过

性能

  • 预热 3 次, 测量 10 次, 每轮 torch.npu.synchronize()
  • npu:0: first 591.20 ms, avg 304.53 ms, min 300.16 ms, max 319.56 ms, p50 300.30 ms, p90 319.56 ms, p95 319.56 ms
  • 吞吐: actions/s 164.19, chunks/s 3.28, horizon 50, batch 1, dtype torch.float32, steps 10
  • 编译与首轮差异已单独报告

证据图

  • agent workflow
  • npu device call
  • model result

限制

  • 必须 float32 (NPU 不支持 bf16 bucketize, 已通过 policy.float() 解决)
  • 合成数据一致性验证, 非全量数据集评测; 闭环 rollout 为额外评估不替代数值一致性
  • 单卡 npu:0, batch 1, 需 5GB 剩余空间

复现

HF_ENDPOINT=https://hf-mirror.com python smolvla_base-NPU/inference.py
python .opencode/skills/npu_adapt_robotics/scripts/validate_policy_outputs.py --cpu /tmp/smolvla_cpu.json --npu /tmp/smolvla_npu.json --atol 1e-4 --rtol 1e-3
python .opencode/skills/npu_adapt_robotics/scripts/benchmark_policy.py