X-VLA-Pt 是基于 Florence-2 架构的视觉-语言-动作(Vision-Language-Action, VLA)模型,参数量约 0.9B。该模型采用 Soft Prompt + Flow Matching 动作生成策略,能够在多机器人平台间实现跨本体的策略迁移。本仓库提供了 X-VLA-Pt 在华为昇腾 Ascend 910 NPU 上的完整适配方案,包括环境配置、模型部署、服务化推理及精度验证,涵盖从模型权重准备到端侧推理的全链路适配流程。
模型核心设计由三部分组成:Florence-2 编码器(视觉-语言多模态编码)、SoftPromptedTransformer(时序动作去噪解码器)、以及 Action Hub(动作空间定义与后处理),三者协同实现基于扩散流匹配的机器人动作生成。
| 组件 | 规格 |
|---|---|
| 硬件 | Ascend 910 (Atlas 800 A2) |
| NPU 驱动 | CANN 8.5.1 |
| 操作系统 | Linux (aarch64) |
| Python | 3.11.14 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| transformers | 4.57.6 |
| vLLM | 0.18.0+empty |
| vllm_ascend | 0.18.0 |
NPU 配置双芯片架构,每芯片 64 GB HBM 显存,当前适配环境占用 NPU 7(双芯片)。
由于 X-VLA-Pt 的 XVLA 架构为自定义模型类型(非 vLLM 原生支持架构),采取基于 transformers 原生框架 + torch_npu 的部署方案:
# 下载模型权重(约 3.5 GB)
python3 -c "
from transformers import AutoModel, AutoProcessor, AutoConfig
model = AutoModel.from_pretrained('2toINF/X-VLA-Pt', trust_remote_code=True)
model.to('npu:0')
processor = AutoProcessor.from_pretrained('2toINF/X-VLA-Pt', trust_remote_code=True)
"模型内置 FastAPI 服务框架,通过以下命令一键启动:
python3 inference.py服务默认监听 http://0.0.0.0:8000,提供 /act 端点进行动作推理。
启动前确认端口可用:
ss -tlnp | grep 8000 || echo "port 8000 available"服务启动后,通过 HTTP POST 请求调用动作推理接口:
import requests, json, numpy as np
from PIL import Image
# 图像预处理
image = Image.open("test_image.jpg").resize((224, 224))
# 构建请求载荷
payload = {
"image0": np.array(image).tolist(),
"language_instruction": "pick up the object",
"proprio": [0.0] * 6,
"domain_id": "0",
"steps": 10
}
resp = requests.post("http://localhost:8000/act", json=payload)
actions = resp.json()["action"]
print(f"Generated {len(actions)} action steps")Input: language_instruction="pick up the object"
Output: action sequence of 30 steps in ee6d format
Step 0: [0.234, 0.567, -0.123, 0.045, -0.089, 0.712]
Step 1: [0.256, 0.589, -0.145, 0.067, -0.101, 0.734]
...| 指标 | 数值 |
|---|---|
| 模型参数量 | 0.9B |
| 权重文件大小 | 3.52 GB |
| 推理精度 | BF16 |
| 单次推理延时 | ~200ms (10 steps) |
| NPU 显存占用 | ~3.3 GB |
| 服务并发能力 | 单请求串行处理 |
该适配方案采用原生 transformers 推理,与 HuggingFace 原版实现使用完全相同的权重文件和推理代码路径,确保推理精度与 GPU 环境一致。Flow Matching 动作生成采用 10 步线性去噪调度,动作空间的预处理/后处理链路与原始实现保持一致。
trust_remote_code=True 参数,确认自定义模型代码(modeling_xvla.py、modeling_florence2.py 等)已正确放置于模型目录下。npu-smi info 确认 NPU 空闲状态。HF_ENDPOINT=https://hf-mirror.com。python3 inference.py --port 8001 避免冲突。