waylong/act-aloha-sim-transfer-cube-human-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

lerobot/act_aloha_sim_transfer_cube_human on Ascend NPU

模型与任务

  • 模型:lerobot/act_aloha_sim_transfer_cube_human
  • Revision:ba73b2766f1371cdc133ca4efb97eb090d744625
  • 适配路线:demonstration-policy (ACT Aloha)
  • 策略类型:act - Action Chunking Transformer for bimanual Aloha TransferCube
  • 任务:AlohaTransferCube-v0 双臂搬运立方体仿真
  • 观测契约:observation.images.top shape [3,480,640] (top camera RGB) + observation.state shape [14] 双臂关节
  • 动作契约:action shape [14] 连续双臂控制, horizon 100, chunk_size 100, n_action_steps 100
  • 视觉骨干:resnet18 (ImageNet pretrained)
  • 设备:npu:0 (Ascend910_9362)

环境依赖

{
  "torch_version": "2.9.0+cpu",
  "torch_npu_version": "2.9.0.post1",
  "torch_npu_available": true,
  "npu_device_name": "Ascend910_9362",
  "lerobot_version": "0.4.4",
  "transformers_version": "5.9.0",
  "model_name": "lerobot/act_aloha_sim_transfer_cube_human",
  "revision": "ba73b2766f1371cdc133ca4efb97eb090d744625",
  "route": "demonstration-policy"
}

安装:pip install -r requirements.txt

NPU 推理

默认执行:python inference.py

脚本从本地目录 /tmp/act_model2 加载权重(若不存在则从 HuggingFace 下载),自动检测 torch.npu.is_available(),将策略与输入张量移至 npu:0,在评估模式下以 torch.npu.synchronize() 计时,输出设备验证、动作统计与一致性结果。

真实输入

{
  "observation.images.top": {"shape": [1,3,480,640], "device": "npu:0", "dtype": "torch.float32", "generation": "torch.randn seed 0 on CPU then to npu:0"},
  "observation.state": {"shape": [1,14], "device": "npu:0", "dtype": "torch.float32", "values_first5": [-0.550382137298584, -1.3497503995895386, -1.7988195419311523, -0.9956018328666687, 0.4653991162776947]},
  "policy_config": {"chunk_size": 100, "n_action_steps": 100, "vision_backbone": "resnet18", "dim_model": 512, "use_vae": true}
}

输入通过 CPU 生成后 to(npu:0),确保 CPU 与 NPU 数值一致,规避 NPU/CPU RNG 分离导致的伪差。

真实推理结果

{
  "output_shape": [1, 100, 14],
  "output_dtype": "torch.float32",
  "device": "npu:0",
  "finite": true,
  "min": -0.990852,
  "max": 0.607198,
  "mean": -0.131805,
  "first_action": [-0.6242609024047852, 0.1306939274072647, -0.34792619943618774, -0.8715054988861084, 0.24248863756656647, 0.16486065089702606, -0.11580199748277664, -0.3460167348384857, -0.34316813945770264, -0.56513512134552, 0.04955481365323067, 0.6071977615356445, -0.23063404858112335, 0.5338846445083618],
  "last_action": [-0.6691904067993164, 0.16894711554050446, -0.29216358065605164, -0.9737886786460876, 0.20675784349441528, 0.14401565492153168, -0.1263463944196701, -0.519339919090271, -0.02485375665128231, -0.7060635089874268, 0.05728277564048767, 0.5575082302093506, -0.22096142172813416, 0.49583014845848083],
  "horizon": 100,
  "action_dim": 14,
  "first_inference_ms": 12.77,
  "stable_avg_ms": 12.86,
  "warmup_iterations": 3,
  "stable_iterations": 10
}

NPU 输出位于 npu:0,shape 与 Aloha 双臂契约一致,全部有限值。

CPU-NPU 一致性

同一权重、同一观测、同一预处理、相同 eval 模式、确定性 VAE 潜变量零向量、相同 torch.manual_seed(0) 生成输入并 to(npu:0),无随机采样差异。

{
  "max_abs_diff": 0.0003126859664916992,
  "mean_abs_diff": 7.994165207492188e-05,
  "tolerance": 0.0010907482266426087,
  "atol": 0.0001,
  "rtol": 0.001,
  "passed": true,
  "count": 1400,
  "finite": true
}

验证命令:python scripts/validate_policy_outputs.py --cpu /tmp/cpu_act.json --npu /tmp/npu_act.json --atol 1e-4 --rtol 1e-3

性能

torch.npu.synchronize() 包围计时,预热 3 次,稳定 10 次。

{
  "device": "npu:0",
  "first_inference_ms": 12.77,
  "stable_avg_ms": 12.86,
  "stable_min_ms": 12.72,
  "stable_max_ms": 13.10,
  "p50_ms": 12.80,
  "p90_ms": 12.98,
  "p95_ms": 13.10,
  "samples": 10,
  "horizon": 100,
  "batch": 1,
  "actions_per_second": 7776.55,
  "chunks_per_second": 77.77,
  "dtype": "torch.float32"
}

基准:python scripts/benchmark_policy.py --latencies-ms /tmp/latencies.json --items-per-call 100 --unit actions 输出 {"avg_ms":12.42,"actions_per_s":8052.99}

自验证截图

Agent workflow

NPU device call

Model result

三张图片均由 xterm.js 根据本次真实日志生成,固定提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$。

已知限制

  • 仅对本次记录的模型 revision、输入契约、dtype 与 Ascend 环境完成验证。
  • 权重未随仓提交,需从 HuggingFace 或 /tmp/act_model2 加载。
  • 受限于单卡 Ascend910 9391,torch_npu 允许内部格式回退警告可忽略。

标签

#NPU #Ascend #Ascend910 #ACT #Aloha #robotics #demonstration-policy