#NPU
anikitakis/vla_so101_pick_n_place_full_expertlerobot/smolvla_base 微调, 训练数据集 anikitakis/pick_n_place_dagger_3cam_dagger_only (21 episodes, 127887 frames, 30 FPS, task "put the annotated object in the box")main / adda798b270742f820834daea0fc37718745f025observation.state [6] STATE MEAN_STD, observation.images.camera1/2/3 [3,480,640] VISUAL IDENTITY resize 512x512 with padding, task language instruction tokenized to observation.language.tokens [48] + attention_mask via HuggingFaceTB/SmolVLM2-500M-Video-Instruct tokenizer (max_length 48, pad to max_length)action [50,6] 连续动作块 (chunk_size 50, action_dim 6, SO101 follower 6-DoF), 需经 MEAN_STD unnormalizer 后映射到真实关节manipulation-vla (图像/状态/语言 → 连续动作块), 按 references/task-adaptation.md 的 SmolVLA 契约验证反归一化前后动作SmolVLAPolicy.from_pretrained + make_pre_post_processors + predict_action_chunkobservation.state: float32 [1,6] 示例 [0.0336,0.0128,0.0234,0.0230,...] 经 normalizer -> [2.16,-2.41,2.86,-5.72,0.34,-2.31] (MEAN_STD)observation.images.camera1/2/3: float32 [1,3,480,640] 范围 [0,1] 随机 0.5±, 经 resize 512x512 padding + normalizetask: string "[put the annotated object in the box\n]" -> observation.language.tokens int64 [1,48] 示例 tokens 前5 [...] + attention_mask bool [1,48]fixed_noise: float32 [1,50,32] (chunk 50, max_action_dim 32) seed 0, 显式传入以消除 flow-matching 随机性, 保证 CPU/NPU 确定性比较actions [1,50,6] float32, 示例 CPU 首步 [1.5925,-1.6460,1.8915,-2.9737,0.3324,-0.3880] vs NPU [1.5925,-1.6460,1.8915,-2.9737,0.3324,-0.3880] (max_abs 3.1e-05)model.safetensors + 2 processor safetensorsaction 6维连续控制, 验收 shape [50,6], finite, action_dim/horizon, MAE/max-abstorch.manual_seed(42) + torch.randn 在 inference.py 内Ascend910_9362 NPU:0 (device_count 2), HBM 65536 MB, 单卡可载 450M (峰值 ~3111 MB)/usr/local/Ascend/cann-8.5.1, npu-smi 25.5.5, Ubuntu 22.04.5 LTS aarch64HF_ENDPOINT=https://hf-mirror.com (禁止覆盖), 代理 via NO_PROXY, 权重本地 /opt/atomgit/adapt-npu-agent/model_cache/vla_so101_pick_n_place_full_expertnpu:0 并通过 torch.npu.is_available() + torch.npu.get_device_name(0) + next(policy.parameters()).device + batch.*.device + actions.device 多级验证, 无 CPU fallbackpip install -r requirements.txt
# 或
pip install torch torch_npu transformers safetensors huggingface_hub lerobot numpy pillow accelerate datasets pyarrow num2words默认命令 (真实 NPU, 已在 npu:0 验证):
python inference.py等价显式:
HF_ENDPOINT=https://hf-mirror.com python inference.py
# 或指定本地目录
LOCAL_DIR=/opt/atomgit/adapt-npu-agent/model_cache/vla_so101_pick_n_place_full_expert python inference.py日志至少打印: model_name anikitakis/vla_so101_pick_n_place_full_expert, revision main, route manipulation-vla, backend SmolVLA, backend_dtype float32, npu_available, device_name Ascend910_9362, device npu:0, first param device, 输入摘要 (state/images/task/tokens), 固定 noise, CPU/NPU action shape/device/dtype/finite/min/max/mean, 首/末 action, 同步耗时 torch.npu.synchronize(), 一致性 max_abs/mae/tolerance, benchmark 10次, 最终 [RESULT] PASS/FAIL。
来自本次真实 NPU 执行 (npu:0, float32, 同步计时, /opt/atomgit/adapt-npu-agent/work_vla_logs/model_result.log):
torch.Size([1,50,6]) first [1.5925,-1.6460,1.8915,-2.9737,0.3324,-0.3880] last [1.1414,-0.8221,0.1730,0.2817,0.4029,-0.7522] finite True time ~50s load + inference (含 VLM 加载, 未同步计时)[1.5925,-1.6460,1.8915,-2.9737,0.3324,-0.3880] 与 CPU 极近torch.npu.synchronize()):
predict_action_chunk 输出 [1,50,6] (未 postprocess 前, 保证相同 preprocessor, 相同 fixed_noise [1,50,32] seed 0, 相同 dtype float32)inference.py 内联计算 max_abs/mae + torch.isfinite, 阈值 FP32 atol=1e-4 rtol=1e-3, BF16 atol=5e-3 rtol=5e-2 (BF16 用于文档说明, 实际为 FP32)/tmp/smolvla_cpu.json vs /tmp/smolvla_npu.json 各 300 values 已保存, 可复核torch.npu.synchronize() 计时, 含预处理 (resize 512)assets/agent_workflow.png — 完整工作流日志 (环境检查 npu-smi/check_npu -> 获取模型 ls/inspect -> 分析 route manipulation-vla -> NPU验证 inference PASS -> 性能 benchmark -> 校验 validate_submission)assets/npu_device_call.png — npu:0 设备调用与 NPU 推理日志片段 (npu-smi, torch.npu.is_available, device_name Ascend910_9362, policy_npu device npu:0, batch devices npu:0, NPU action device npu:0)assets/model_result.png — 默认 python inference.py 的模型/route/backend、真实输入 (state/images/task)、动作摘要 (first/last, finite, min/max/mean)、同步耗时 (first 583ms, avg 318ms)、一致性 (max_abs 3.1e-05 PASS)、最终 [RESULT] PASSpolicy.float() + policy.to(dtype=float32) 解决, 原始权重 bfloat16)push_checkpoints_to_hub/revision 需移除以适配 lerobot 0.4.4, 已 patch model_cache/.../config.jsoncompile_model (SmolVLA 默认 false), 若启用 max-autotune 需另测HF_ENDPOINT=https://hf-mirror.com python inference.py
# 输出应含 [RESULT] PASS, max_abs < 0.003, device npu:0
# 校验提交
python /opt/atomgit/adapt-npu-agent/.opencode/skills/npu_adapt_robotics/scripts/validate_submission.py /opt/atomgit/adapt-npu-agent/anikitakis-vla_so101_pick_n_place_full_expert-NPU
