K-ON111111/X-VLA-Pt
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

2toINF/X-VLA-Pt — 昇腾 NPU 适配模型

赛事: 昇腾 Model Agent 模型适配大赛(第二季) 引擎: torch_npu + transformers 硬件: Ascend 310P / 910B 标签: npu ascend pytorch robotics vision-language-action

📖 模型简介

X-VLA 0.9B(Foundation Edition)是基于软提示(Soft Prompt)的跨具身 Vision-Language-Action(VLA)模型,采用 Flow-Matching 动作生成框架。 架构为 Florence-2 视觉语言骨干 + SoftPromptedTransformer 时间/动作头, 通过领域专属可学习嵌入实现跨机器人平台的高效适应(arXiv 2510.10274)。

属性值
原始模型https://huggingface.co/2toINF/X-VLA-Pt
参数量0.9 B
任务类型机器人视觉-语言-动作(VLA)
输入格式观测图像 + 语言指令 + 域 ID + proprio
输出格式动作序列(流匹配迭代去噪,shape [B, 30, 20])

🔧 环境依赖

pip install -r requirements.txt -i https://repo.huaweicloud.com/repository/pypi/simple/

🚀 推理步骤

⚠️ 本仓库不包含模型权重(交付件仅 inference.py / readme.md / requirements.txt / assets/), 推理前必须先从原始模型仓单独下载权重。

# 1. 下载模型权重(仓库不含权重,必须单独下载)
git clone https://gitcode.com/hf_mirrors/2toINF/X-VLA-Pt.git ./X-VLA-Pt

# 2. 运行 NPU 推理
python3 inference.py --model_path ./X-VLA-Pt \
  --image obs.png --instruction "Move the object to the target." \
  --domain_id 0 --steps 5 --device npu:0 --output inference_result.json

🧪 测试用例

用例 1: 图像 + 指令 → 动作序列

python3 inference.py --model_path ./X-VLA-Pt \
  --image test_obs.png --instruction "Move the object to the target." \
  --domain_id 0 --steps 5 --device npu:0 --output inference_result.json

预期输出:

[Model Agent] ✅ NPU 设备就绪: Ascend310P3
[Model Agent] ✅ 模型加载完成 → npu:0
[Model Agent] ✅ 动作生成完成: 形状 (1, 30, 20), 推理耗时 162.190s
[Model Agent] ✅ 结果已保存 → inference_result.json

推理结果摘要:

{
  "model": "2toINF/X-VLA-Pt",
  "engine": "torch_npu",
  "device": "npu:0",
  "instruction": "Move the object to the target.",
  "denoising_steps": 5,
  "action_shape": [1, 30, 20],
  "inference_time_s": 162.19
}

📁 目录结构

.
├── inference.py          # NPU 推理脚本
├── readme.md             # 本文件
├── requirements.txt      # 依赖清单
└── assets/               # 截图素材

📝 适配说明

本模型由 昇腾 Model Agent 自动完成 NPU 适配:

  • SDPA 兼容补丁:torch_npu 不支持 F.scaled_dot_product_attention, 全局替换为手动 matmul 实现(覆盖 Florence-2 与 SoftPromptedTransformer)
  • transformers 兼容补丁:Florence-2 远程代码的 _supports_sdpa 属性改为类属性
  • IndexPutV2 补丁:action space 的原地索引赋值改用 index_fill/index_copy
  • proprio 维度修正:按 action space 的 dim_proprio 传入(避免 BatchMatMul 形状错误)
  • 已在 Ascend 310P3 上端到端实跑验证通过(图像+指令 → 动作序列),输出合法