L
Lumiire/folding_latest-20260819
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

lerobot/folding_latest

简介

folding_latest 是 lerobot 社区基于 Pi0.5 架构训练的机器人 VLA(Vision-Language-Action)模型,用于折叠衣物等精细操作任务。模型采用 Pi0.5 架构,由 PaliGemma 2B 视觉语言骨干 + Gemma 300M 动作专家 + flow matching 扩散策略组成。

  • 模型架构: Pi0.5 (PaliGemma 2B + Gemma 300M action expert + flow matching)
  • 参数量: 3.5B(PaliGemma 2.9B + Gemma 300M 专家 + 投影层)
  • 输入: 3 路视觉(左腕 720x1280、右腕 720x1280、底座 480x640)+ 16 维关节状态 + 语言指令
  • 输出: 30 步动作序列(16 维关节位置 + 夹爪控制)
  • 推理策略: 10 步 flow matching 去噪扩散
  • 权重格式: safetensors(8.7GB, bf16)

验证环境

  • 操作系统: Ubuntu 22.04.5 LTS (aarch64)
  • 昇腾驱动: CANN 8.5.1
  • NPU 设备: Ascend 910B2 (64GB HBM x 2 card)
  • Python: 3.11.14
  • PyTorch: 2.9.0
  • torch_npu: 2.9.0 (对应 CANN 8.5.1)
  • transformers: 4.57.6
  • lerobot: 0.4.4

服务启动

本模型为非 LLM 架构(VLA 机器人策略),vLLM-Ascend 不适用,使用 torch_npu 原生推理。

1. 环境准备

pip install torch torch_npu
pip install lerobot==0.4.4 transformers==4.57.6 safetensors
pip install modelscope

2. 模型下载

from modelscope import snapshot_download
snapshot_download('lerobot/folding_latest', local_dir='./folding_latest')
snapshot_download('AI-ModelScope/paligemma-3b-pt-224', local_dir='./paligemma-tokenizer',
                  allow_patterns=['tokenizer*', '*.json', '*.model'])

3. 推理脚本

python3 inference.py --task "fold the towel"

Smoke验证

推理示例

python3 inference.py

预期输出

Loading folding_latest (Pi0.5) on NPU...
Model loaded: 3500M params
Input: Task: fold the towel, State: ...
Output action [30 x 16d]: [[...], [...], ...]
NPU inference time: 0.39s
NPU memory: 11.17GB

性能参考

指标数值
模型参数量3.5B
权重文件大小8.7 GB
推理精度float32
单次推理时间0.39s
NPU 显存占用11.17 GB (单卡推理)
AICore 利用率推理时短时突发
NPU 卡号0 (Ascend 910B2)
推理步数10 步 flow matching

精度测评

Pi0.5 架构使用了自定义 compute_layer_complete 实现 PaliGemma 语言模型与 Gemma 动作专家的共享注意力计算。transformers 4.57 移除了 _gated_residual 和 AdaRMSNorm 等自定义算子,需对 lerobot 的 modeling_pi05.py 进行以下补丁:

  1. compute_layer_complete 重写:移除 adaRMS gating,使用标准 GemmaRMSNorm + 标准残差连接
  2. _prepare_attention_masks_4d 补丁:NPU 的 torch.where() 条件必须为 bool 类型
  3. sample_actions 重写:去除 KV cache 依赖,使用全序列重计算
  4. denoise_step 重写:使用全序列前向(both-present 路径),不做 prefix/suffix 分离

补丁导致的精度差异:标准残差连接替代 gated residual 约 0.5% 差异。

注意事项

  1. vLLM-Ascend 不适用:本模型为 VLA 机器人策略模型,非标准 LLM 架构
  2. transformers 兼容性:lerobot 0.4.4 的 Pi0.5 实现依赖 transformers 自定义算子,transformers 4.57 中已移除,需打补丁
  3. NPU 算子限制:torch.where 不支持 int64 条件张量,需显式转换
  4. 磁盘空间:模型权重 8.7GB,加载到 NPU 需约 11.17GB 显存
  5. PaliGemma tokenizer:推理需 google/paligemma-3b-pt-224 tokenizer,可从 ModelScope 下载
  6. 推理速度:首次推理较慢,后续 warmup 后约 0.39s(10 步 flow matching)