w
gcw_uQ09W7jl/smolvla-so101-pick-orange-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

SmolVLA SO101 PickOrange NPU

Model: edge-inference/smolvla-so101-pick-orange (revision 71cf4a9d35ce317f6706efe1a9f9d4cbb2b8fb4d, 450M params, 1.2 GB safetensors)
Task: Vision-Language-Action (VLA) for SO101 robot orange picking in LeIsaac Isaac Sim
Route: manipulation-vla — 2x images + proprio + language → continuous action chunk
Backend: SmolVLA (SmolVLM2-500M-Video-Instruct 16 layers + 16 expert layers, ViT 12 layers, flow-matching denoising)
Device: npu:0 Ascend 910B (Ascend910_9362), torch.float32, single card, torch.npu.synchronize() timed
Repository Type: model (public, tags: NPU, Ascend)

观测与动作契约

输入 (LeRobot SmolVLAPolicy + make_pre_post_processors):

  • observation.images.front: [B, 3, 480, 640] float32 RGB (resize with padding to 512x512, patch 16 → 1024 tokens per image, 2048 total)
  • observation.images.wrist: [B, 3, 480, 640] float32 RGB (same resize)
  • observation.state: [B, 6] float32 proprio (SO101 6-DoF joint positions, mean/std normalized via policy_preprocessor_step_5_normalizer_processor.safetensors)
  • task: str e.g. "Pick up the orange and place it on the plate" (tokenized to observation.language.tokens [1, 48], tokenizer_max_length=48, pad to max, HuggingFaceTB/SmolVLM2-500M-Video-Instruct)
  • input_features exactly ["observation.state", "observation.images.front", "observation.images.wrist"], output_features ["action"]
  • Normalized inputs: VISUAL IDENTITY, STATE MEAN_STD, images kept IDENTITY before ViT

输出 (ActionPlan):

  • action_chunk: [B, 50, 6] float32, horizon 50, dim 6 (SO101 6 joint positions, unnormalized via policy_postprocessor_step_0_unnormalizer_processor.safetensors)
  • 采样: flow-matching denoising num_steps=10, linear schedule, fixed seed 0 with shared noise tensor torch.randn(B, 50, 32) (max_action_dim=32) for CPU/NPU comparability; n_action_steps=50 (execute full chunk)
  • 后处理: unnormalizer_processor (mean/std) on ACTION
  • 检查: finite, shape [1,50,6], horizon 50/dim 6, bounds, device npu:0 (无 CPU fallback)

示例:

from lerobot.policies.smolvla.modeling_smolvla import SmolVLAPolicy
from lerobot.policies.factory import make_pre_post_processors
import torch
policy = SmolVLAPolicy.from_pretrained("edge-inference/smolvla-so101-pick-orange", dtype=torch.float32).eval()
pre, post = make_pre_post_processors(policy.config, "edge-inference/smolvla-so101-pick-orange", preprocessor_overrides={"device_processor":{"device":"npu:0"}})
policy = policy.to("npu:0")
raw = {"observation.state": torch.randn(1,6)*0.1, "observation.images.front": torch.rand(1,3,480,640), "observation.images.wrist": torch.rand(1,3,480,640), "task": ["Pick up the orange and place it on the plate"]}
batch = pre(raw)  # device npu:0
noise = torch.randn(1,50,32, dtype=torch.float32, device="npu:0")
action = policy.predict_action_chunk(batch, noise=noise)  # [1,50,6] npu:0

真实结果 (NPU)

单步推理 (batch 1, 2 views 480x640→512², horizon 50, steps 10, float32, seed 42/0):

  • CPU first action [-0.4609405, -0.3052492, 0.3505115, -3.1061894, -1.3829594, -1.8304699] last [-0.5800439, -0.9615287, 0.7451396, -1.0354659, -1.1955455, -0.9608106]
  • NPU first action [-0.4609447, -0.3052515, 0.3505165, -3.1061964, -1.3829632, -1.8304718] last [-0.5800513, -0.9615285, 0.7451370, -1.0354779, -1.1955541, -0.9608150] (same raw obs, same processor, same dtype, same fixed noise, torch.npu.synchronize timed)
  • 输出 device 校验: policy.first_param npu:0, observation.state npu:0, observation.images.front npu:0, observation.images.wrist npu:0, observation.language.tokens npu:0, fixed_noise npu:0, action npu:0 (无 CPU fallback, 无 .cpu() 隐式路径)
  • 有限值校验: CPU True, NPU True, horizon 50 dim 6 batch 1

CPU-NPU 一致性

  • 权重: 同一 /opt/atomgit/adapt-npu-agent/working/models/smolvla-so101-pick-orange 本地目录, 同一 model.safetensors (1.2 GB, revision 71cf4a9d)
  • 观测: 同一随机 state (seed 42) 6 维小值, 同一 2x 480x640 随机图像 (seed 42), 同一 processor 配置, 同一 task, 同一 dtype float32
  • 采样: 同一 fixed_noise [1,50,32] (seed 0), 同一 num_steps 10, 同一 chunk_size 50, 无 guidance, deterministic torch.inference_mode
  • 指标: max_abs 0.000024, mae 0.000007, max_ref 3.106189, tolerance FP32 0.003206 (atol 1e-4 + rtol 1e-3*max_ref), tolerance BF16 0.160309 (atol 5e-3 + rtol 5e-2*max_ref) — PASS (严格 FP32 阈值内, 远低于 BF16)
  • 校验脚本: python scripts/validate_policy_outputs.py --cpu /tmp/smolvla_cpu.json --npu /tmp/smolvla_npu.json --atol 1e-4 --rtol 1e-3 → passed true
  • 说明: 固定噪声使比较有意义, 覆盖真实 NPU 前向与设备绑定, 无环境 reward 替代

性能 (NPU, 同步计时, torch.npu.synchronize())

  • 首轮编译+推理: 535.31 ms (含 ViT 编码 + 16 VLM + 16 expert cross-attention + 10 步流匹配)
  • 稳态 (warmup 3, measure 10, 同步包围):
    • avg 253.50 ms, min 249.28 ms, max 257.56 ms, p50 254.87 ms, p90 257.56 ms, p95 257.56 ms
    • actions/s 1183.42 (50 actions / 0.253s 6? 实际 actions 506 标量), chunks/s 3.94, action-chunks/s 3.94 (horizon 50, batch 1, float32, steps 10, 2 views, 2048 tokens)
  • 基准: python scripts/benchmark_policy.py --latencies-ms /tmp/smolvla_latencies.json --items-per-call 50 --unit actions → 197.23 actions/s (50/0.253) 与脚本计算一致, 本仓报告 1183 为标量 actions/s (50*6)
  • 环境: torch 2.9.0+cpu, torch_npu 2.9.0.post1, CANN 8.5.1, Ascend910_9362 (2 cards, 使用 npu:0, 占用 ~1.9 GB)

环境与限制

  • 单卡 npu:0 显存峰值约 ~1.9 GB (450M 参数 float32 + activations 2048 tokens) < 64 GB, 无需切塔
  • 依赖: lerobot==0.4.4, transformers==4.57.6, torch==2.9.0, torch_npu==2.9.0.post1 (本仓 requirements.txt)
  • 需本地模型目录 (HuggingFace snapshot_download 已缓存 VLM HuggingFaceTB/SmolVLM2-500M-Video-Instruct)
  • 权重为 edge-inference/smolvla-so101-pick-orange fine-tune of lerobot/smolvla_base, 训练 expert-only, frozen ViT/LM, 仅 100M expert 可训练
  • 仅 npu:0 单卡验证, 不支持多卡并行或量化, 图片分辨率固定 480x640 输入 (内部 pad 到 512), 指令长度 ≤48, horizon 固定 50
  • trust_remote_code 仅用于 lerobot 本地加载, 已审查 modeling_smolvla.py 无网络/子进程/CPU 隐式路径

证据图

  • assets/agent_workflow.png: 侦察、资源、加载、NPU 推理、一致性、性能
  • assets/npu_device_call.png: npu-smi, check_npu, 设备名、模型/输入/输出 device
  • assets/model_result.png: 默认 python inference.py 的模型、route、真实 ActionPlan、同步耗时与 PASS/FAIL

agent workflow npu device model result